From 92f2232350f685178191f60d469edb457b37b220 Mon Sep 17 00:00:00 2001 From: George Veranis Date: Fri, 2 Jul 2021 16:41:24 +0200 Subject: [PATCH] Bug 27943: add support for 7XX equal terms on authorities marc21 display Currently when a MARC21 authority has 7XX field they do not display on authority search result page. 7XX is equal term of 1XX based on LC rules. Applying this patch will enable that feature, which is important for non latin catalogues. Test plan: 1) Add a new authority with 1XX and 7XX fields. 2) Try to search that authority and check if 7XX values are displayed 3) Apply this patch 4) Try to search that authority and you will see that 7XX values are displayed like "1XX = 7XX" Sponsored-by: Keratsini-Drapetsona Municipal Library, Greece Mentored-by: Andreas Roussos --- C4/AuthoritiesMarc.pm | 79 +++++++++++++++++++ .../includes/authorities-search-results.inc | 6 ++ .../includes/authorities-search-results.inc | 6 ++ 3 files changed, 91 insertions(+) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 1bb808bb9c..071e6207c6 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -875,6 +875,8 @@ sub BuildSummary { my @seefrom; my @seealso; my @otherscript; + my @equalterm; + if (C4::Context->preference('marcflavour') eq 'UNIMARC') { # construct UNIMARC summary, that is quite different from MARC21 one # accepted form @@ -928,6 +930,8 @@ sub BuildSummary { use C4::Heading::MARC21; my $handler = C4::Heading::MARC21->new(); my $subfields_to_report; + my $subfields_to_subdivision=""; + my $delimiter = " -- "; foreach my $field ($record->field('1..')) { my $tag = $field->tag(); next if "152" eq $tag; @@ -1004,6 +1008,80 @@ sub BuildSummary { foreach my $field ($record->field('6..')) { push @notes, { note => $field->as_string(), field => $field->tag() }; } + + foreach my $field ($record->field('7..')) + { + my $tag = $field->tag(); + + if ($tag eq '700') { + $subfields_to_report = 'abcdefghjklmnopqrst'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '710') { + $subfields_to_report = 'abcdefghklmnoprst'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '711') { + $subfields_to_report = 'acdefghklnpqst'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '730') { + $subfields_to_report = 'adfghklmnoprst'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '748') { + $subfields_to_report = 'ab'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '750') { + $subfields_to_report = 'ab'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '751') { + $subfields_to_report = 'a'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '755') { + $subfields_to_report = 'abvxyz'; + $subfields_to_subdivision='vxyz'; + $delimiter=" -- "; + } elsif ($tag eq '780') { + $subfields_to_report = 'vxyz'; + $delimiter=" "; + } elsif ($tag eq '781') { + $subfields_to_report = 'vxyz'; + $delimiter=" "; + } elsif ($tag eq '782') { + $subfields_to_report = 'vxyz'; + $delimiter=" "; + } elsif ($tag eq '785') { + $subfields_to_report = 'vxyz'; + $delimiter=" "; + } + + my $heading = $field->as_string($subfields_to_report); + + my $subheading = $field->as_string($subfields_to_subdivision,$delimiter); + if(length $subheading > 0 ) + { + $heading.=$delimiter.$subheading; + } + + if ($subfields_to_report) { + push @equalterm, { + heading => $heading, + hemain => ( $field->subfield( substr($subfields_to_report, 0, 1) ) // undef ), + field => $tag, + }; + } else { + push @equalterm, { + heading => $field->as_string(), + hemain => ( $field->subfield( 'a' ) // undef ), + field => $tag, + }; + } + } + foreach my $field ($record->field('880')) { my $linkage = $field->subfield('6'); my $category = substr $linkage, 0, 1; @@ -1031,6 +1109,7 @@ sub BuildSummary { $summary{seefrom} = \@seefrom; $summary{seealso} = \@seealso; $summary{otherscript} = \@otherscript; + $summary{equalterm} = \@equalterm; return \%summary; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc index 3e0c4904f1..cbf9a1f67d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc @@ -69,6 +69,12 @@ [% UNLESS loop.last %] | [% END %] [% END %] + [% IF summary.equalterm.size %] + [% FOREACH term IN summary.equalterm %] + = + [% term.heading %] + [% END %] + [% END %] [% IF ( marcflavour == 'UNIMARC' ) %] [% IF summary.notes %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc index 5cf2e6044b..c126e4a8fb 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc @@ -61,6 +61,12 @@ [% authorize.heading | html %] [% UNLESS loop.last %] | [% END %] [% END %] + [% IF summary.equalterm.size %] + [% FOREACH term IN summary.equalterm %] + = + [% term.heading %] + [% END %] + [% END %] [% IF ( marcflavour == 'UNIMARC' ) %] [% IF summary.notes %] -- 2.20.1