From 6b6c8e1dea2ce27add41672faf81eb49fd1d5559 Mon Sep 17 00:00:00 2001 From: Mason James Date: Fri, 13 Feb 2009 12:15:57 +1300 Subject: [PATCH] corrected patch for bug 2951 Signed-off-by: Galen Charlton --- C4/Biblio.pm | 68 +++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 572b4580b9..786b3515ca 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1125,44 +1125,48 @@ Assumes web resources (not uncommon in MARC21 to omit resource type ind) =cut sub GetMarcUrls { - my ($record, $marcflavour) = @_; + my ( $record, $marcflavour ) = @_; + my @marcurls; - for my $field ($record->field('856')) { + for my $field ( $record->field('856') ) { my $marcurl; - my $url = $field->subfield('u'); my @notes; - for my $note ( $field->subfield('z')) { - push @notes , {note => $note}; - } - if($marcflavour eq 'MARC21') { - my $s3 = $field->subfield('3'); - my $link = $field->subfield('y'); - unless($url =~ /^\w+:/) { - if($field->indicator(1) eq '7') { - $url = $field->subfield('2') . "://" . $url; - } elsif ($field->indicator(1) eq '1') { - $url = 'ftp://' . $url; - } else { - # properly, this should be if ind1=4, - # however we will assume http protocol since we're building a link. - $url = 'http://' . $url; - } - } - # TODO handle ind 2 (relationship) - $marcurl = { MARCURL => $url, - notes => \@notes, - }; - $marcurl->{'linktext'} = $link || $s3 || C4::Context->preference('URLLinkText') || $url ;; - $marcurl->{'part'} = $s3 if($link); - $marcurl->{'toc'} = 1 if($s3 =~ /^[Tt]able/) ; - } else { - $marcurl->{'linktext'} = $field->subfield('z') || C4::Context->preference('URLLinkText') || $url; - $marcurl->{'MARCURL'} = $url ; + for my $note ( $field->subfield('z') ) { + push @notes, { note => $note }; + } + my @urls = $field->subfield('u'); + foreach my $url (@urls) { + if ( $marcflavour eq 'MARC21' ) { + my $s3 = $field->subfield('3'); + my $link = $field->subfield('y'); + unless ( $url =~ /^\w+:/ ) { + if ( $field->indicator(1) eq '7' ) { + $url = $field->subfield('2') . "://" . $url; + } elsif ( $field->indicator(1) eq '1' ) { + $url = 'ftp://' . $url; + } else { + # properly, this should be if ind1=4, + # however we will assume http protocol since we're building a link. + $url = 'http://' . $url; + } + } + # TODO handle ind 2 (relationship) + $marcurl = { + MARCURL => $url, + notes => \@notes, + }; + $marcurl->{'linktext'} = $link || $s3 || C4::Context->preference('URLLinkText') || $url; + $marcurl->{'part'} = $s3 if ($link); + $marcurl->{'toc'} = 1 if ( $s3 =~ /^[Tt]able/ ); + } else { + $marcurl->{'linktext'} = $field->subfield('z') || C4::Context->preference('URLLinkText') || $url; + $marcurl->{'MARCURL'} = $url; + } + push @marcurls, $marcurl; } - push @marcurls, $marcurl; } return \@marcurls; -} #end GetMarcUrls +} =head2 GetMarcSeries -- 2.39.5