From 2ac9359ea7ec43f025bced01fb8a9258deab662f Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 2 Mar 2017 12:59:37 +0100 Subject: [PATCH] Bug 18198: MARC21: Further improve handling of 5XX$u in GetMarcNotes Content-Type: text/plain; charset=utf-8 Bug 14306 only handled field 555 in MARC21 as an URI. But a lot of other 5XX fields have a $u subfield for URIs; actually $u is not used in any other way. This patch generalizes the change made for 555 and extends it to all 5XX $u. Test plan: [1] Run t/Biblio.t [2] Run t/db_dependent/Biblio.t [3] Edit a MARC21 record. Add a URL into 505u, 520u, 555u. [4] Check presentation on opac-detail (tab Title notes) [5] Check presentation on catalogue/detail (tab Descriptions) Signed-off-by: Marcel de Rooy --- C4/Biblio.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index ef2e432..a780fd1 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1803,7 +1803,7 @@ sub GetMarcISSN { Get all notes from the MARC record and returns them in an array. The notes are stored in different fields depending on MARC flavour. - MARC21 field 555 gets special attention for the $u subfields. + MARC21 5XX $u subfields receive special attention as they are URIs. =cut @@ -1821,12 +1821,16 @@ sub GetMarcNotes { foreach my $field ( $record->field($scope) ) { my $tag = $field->tag(); next if $blacklist{ $tag }; - if( $marcflavour ne 'UNIMARC' && $tag =~ /555/ ) { - # Field 555$u contains URLs - # We first push the regular subfields and all $u's separately - # Leave further actions to the template - push @marcnotes, { marcnote => $field->as_string('abcd') }; + if( $marcflavour ne 'UNIMARC' && $field->subfield('u') ) { + # Field 5XX$u always contains URI + # Examples: 505u, 506u, 510u, 514u, 520u, 530u, 538u, 540u, 542u, 552u, 555u, 561u, 563u, 583u + # We first push the other subfields, then all $u's separately + # Leave further actions to the template (see e.g. opac-detail) + my $othersub = + join '', ( 'a' .. 't', 'v' .. 'z', '0' .. '9' ); # excl 'u' + push @marcnotes, { marcnote => $field->as_string($othersub) }; foreach my $sub ( $field->subfield('u') ) { + $sub =~ s/^\s+|\s+$//g; # trim push @marcnotes, { marcnote => $sub }; } } else { -- 2.1.4