@@ -, +, @@
---
C4/Biblio.pm | 41 ++++++++++++++++++-----------------------
t/db_dependent/Biblio.t | 10 ++++------
2 files changed, 22 insertions(+), 29 deletions(-)
--- a/C4/Biblio.pm
+++ a/C4/Biblio.pm
@@ -1768,10 +1768,11 @@ sub GetMarcISSN {
=head2 GetMarcNotes
- $marcnotesarray = GetMarcNotes( $record, $marcflavour );
+ $marcnotesarray = GetMarcNotes( $record, $marcflavour );
-Get all notes from the MARC record and returns them in an array.
-The note are stored in different fields depending on MARC flavour
+ 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.
=cut
@@ -1781,34 +1782,28 @@ sub GetMarcNotes {
carp 'GetMarcNotes called on undefined record';
return;
}
- my $scope;
- if ( $marcflavour eq "UNIMARC" ) {
- $scope = '3..';
- } else { # assume marc21 if not unimarc
- $scope = '5..';
- }
+
+ my $scope = $marcflavour eq "UNIMARC"? '3..': '5..';
my @marcnotes;
- my $note = "";
- my $tag = "";
- my $marcnote;
- my %blacklist = map { $_ => 1 } split(/,/,C4::Context->preference('NotesBlacklist'));
+ my %blacklist = map { $_ => 1 }
+ split( /,/, C4::Context->preference('NotesBlacklist'));
foreach my $field ( $record->field($scope) ) {
my $tag = $field->tag();
- next if $blacklist{$tag};
-
- my $value = $field->as_string();
+ next if $blacklist{ $tag };
if( $marcflavour ne 'UNIMARC' && $tag =~ /555/ ) {
- my @sub= $field->subfield('u');
- foreach my $s (@sub) {
- next if $s !~ /^http/;
- my $i= index( $value, $s);
- $value= substr( $value,0, $i) . "$s" . substr( $value, $i + length($s) );
+ # 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') };
+ foreach my $sub ( $field->subfield('u') ) {
+ push @marcnotes, { marcnote => $sub };
}
+ } else {
+ push @marcnotes, { marcnote => $field->as_string() };
}
- push @marcnotes, { marcnote => $value };
}
return \@marcnotes;
-} # end GetMarcNotes
+}
=head2 GetMarcSubjects
--- a/t/db_dependent/Biblio.t
+++ a/t/db_dependent/Biblio.t
@@ -213,18 +213,16 @@ sub run_tests {
} else {
$biblioitemnumbertotest = $updatedrecord->field($biblioitem_tag)->subfield($biblioitem_subfield);
}
- is ($newincbiblioitemnumber, $biblioitemnumbertotest);
+ is ($newincbiblioitemnumber, $biblioitemnumbertotest, 'Check newincbiblioitemnumber');
# test for GetMarcNotes
my $a1= GetMarcNotes( $marc_record, $marcflavour );
my $field2 = MARC::Field->new( $marcflavour eq 'UNIMARC'? 300: 555, 0, '', a=> 'Some text', u=> 'http://url-1.com', u=> 'nohttp://something_else' );
$marc_record->append_fields( $field2 );
my $a2= GetMarcNotes( $marc_record, $marcflavour );
- my $last= @$a2? $a2->[@$a2-1]->{marcnote}: '';
- is( @$a2 == @$a1 + 1 && (
- ( $marcflavour eq 'UNIMARC' && $last eq $field2->as_string() ) ||
- ( $marcflavour ne 'UNIMARC' && $last =~ /\