From 3faca7a3c06e3f179bab885169fe262d28471cbc Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 20 Dec 2022 12:10:57 -1000 Subject: [PATCH] Bug 32509: Embed see-also-from headings into bibliographic records export --- Koha/Exporter/Record.pm | 17 ++++++++++++++--- Koha/Filter/MARC/EmbedSeeFromHeadings.pm | 5 ++++- misc/export_records.pl | 7 +++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Koha/Exporter/Record.pm b/Koha/Exporter/Record.pm index c2dfc38c2f..56f84dc83e 100644 --- a/Koha/Exporter/Record.pm +++ b/Koha/Exporter/Record.pm @@ -122,15 +122,26 @@ sub _get_biblio_for_export { my $export_items = $params->{export_items} // 1; my $only_export_items_for_branches = $params->{only_export_items_for_branches}; my $embed_see_from_headings = $params->{embed_see_from_headings}; + my $embed_see_also_from_headings = $params->{embed_see_also_from_headings}; my $biblio = Koha::Biblios->find($biblionumber); my $record = eval { $biblio->metadata->record }; return if $@ or not defined $record; - if ($embed_see_from_headings) { - my $record_processor = Koha::RecordProcessor->new( { filters => 'EmbedSeeFromHeadings' } ); - $record_processor->process($record); + if ( $embed_see_from_headings || $embed_see_also_from_headings ) { + my @esfh_fields; + push '4..', @esfh_fields if $embed_see_from_headings; + push '5..', @esfh_fields if $embed_see_also_from_headings; + my $esfh_record_processor = Koha::RecordProcessor->new( + { + filters => 'EmbedSeeFromHeadings', + options => { + auth_fields => \@esfh_fields, + } + } + ); + $esfh_record_processor->process($record); } if ($export_items) { diff --git a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm b/Koha/Filter/MARC/EmbedSeeFromHeadings.pm index 9973db90de..678e94cfbf 100644 --- a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm +++ b/Koha/Filter/MARC/EmbedSeeFromHeadings.pm @@ -88,6 +88,9 @@ include in facets, sorting, or suggestion fields) sub fields { my ($self, $record) = @_; + my $params = $self->params; + my $auth_fields = $params->{options}->{auth_fields} || [ '4..' ]; + my ($item_tag) = GetMarcFromKohaField( "items.itemnumber" ); $item_tag ||= ''; @@ -102,7 +105,7 @@ sub fields { my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid); next unless $authority; my $auth_marc = $authority->record; - my @seefrom = $auth_marc->field('4..'); + my @seefrom = $auth_marc->field(@$auth_fields); foreach my $authfield (@seefrom) { my $tag = substr($field->tag(), 0, 1) . substr($authfield->tag(), 1, 2); next if MARC::Field->is_controlfield_tag($tag); diff --git a/misc/export_records.pl b/misc/export_records.pl index 08aba2d7e6..6bc08b99e4 100755 --- a/misc/export_records.pl +++ b/misc/export_records.pl @@ -55,6 +55,7 @@ my ( $end_accession, $marc_conditions, $embed_see_from_headings, + $embed_see_also_from_headings, $help ); @@ -80,6 +81,7 @@ GetOptions( 'end_accession=s' => \$end_accession, 'marc_conditions=s' => \$marc_conditions, 'embed_see_from_headings' => \$embed_see_from_headings, + 'embed_see_also_from_headings' => \$embed_see_also_from_headings, 'h|help|?' => \$help ) || pod2usage(1); @@ -259,6 +261,7 @@ else { export_items => (not $dont_export_items), clean => $clean || 0, embed_see_from_headings => $embed_see_from_headings || 0, + embed_see_also_from_headings => $embed_see_also_from_headings || 0, } ); } @@ -392,6 +395,10 @@ Print a brief help message. --embed_see_from_headings Embed see from (non-preferred form) headings in bibliographic record. +=item B<--embed_see_from_headings> + + --embed_see_also_from_headings Embed see also from (non-preferred form) headings in bibliographic record. + =back =head1 AUTHOR -- 2.39.0