Lines 966-971
sub get_marc_notes {
Link Here
|
966 |
return \@marcnotes; |
966 |
return \@marcnotes; |
967 |
} |
967 |
} |
968 |
|
968 |
|
|
|
969 |
=head3 get_authors_from_MARC |
970 |
|
971 |
my $authors = $biblio->get_authors_from_MARC; |
972 |
|
973 |
Get all authors from the MARC record and returns them in an array. |
974 |
The authors are stored in different fields depending on MARC flavour |
975 |
|
976 |
=cut |
977 |
|
978 |
sub get_authors_from_MARC { |
979 |
my ( $self, $params ) = @_; |
980 |
|
981 |
my ( $mintag, $maxtag, $fields_filter ); |
982 |
my $marcflavour = C4::Context->preference('marcflavour'); |
983 |
|
984 |
# tagslib useful only for UNIMARC author responsibilities |
985 |
my $tagslib; |
986 |
if ( $marcflavour eq "UNIMARC" ) { |
987 |
# FIXME : we don't have the framework available, we take the default framework. May be buggy on some setups, will be usually correct. |
988 |
$tagslib = C4::Biblio::GetMarcStructure( 1, '', { unsafe => 1 }); |
989 |
$mintag = "700"; |
990 |
$maxtag = "712"; |
991 |
$fields_filter = '7..'; |
992 |
} else { # marc21/normarc |
993 |
$mintag = "700"; |
994 |
$maxtag = "720"; |
995 |
$fields_filter = '7..'; |
996 |
} |
997 |
|
998 |
my @marcauthors; |
999 |
my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator'); |
1000 |
|
1001 |
foreach my $field ( $self->metadata->record->field($fields_filter) ) { |
1002 |
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; |
1003 |
my @subfields_loop; |
1004 |
my @link_loop; |
1005 |
my @subfields = $field->subfields(); |
1006 |
my $count_auth = 0; |
1007 |
|
1008 |
# if there is an authority link, build the link with Koha-Auth-Number: subfield9 |
1009 |
my $subfield9 = $field->subfield('9'); |
1010 |
if ($subfield9) { |
1011 |
my $linkvalue = $subfield9; |
1012 |
$linkvalue =~ s/(\(|\))//g; |
1013 |
@link_loop = ( { 'limit' => 'an', 'link' => $linkvalue } ); |
1014 |
} |
1015 |
|
1016 |
# other subfields |
1017 |
my $unimarc3; |
1018 |
for my $authors_subfield (@subfields) { |
1019 |
next if ( $authors_subfield->[0] eq '9' ); |
1020 |
|
1021 |
# unimarc3 contains the $3 of the author for UNIMARC. |
1022 |
# For french academic libraries, it's the "ppn", and it's required for idref webservice |
1023 |
$unimarc3 = $authors_subfield->[1] if $marcflavour eq 'UNIMARC' and $authors_subfield->[0] =~ /3/; |
1024 |
|
1025 |
# don't load unimarc subfields 3, 5 |
1026 |
next if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /3|5/ ) ); |
1027 |
|
1028 |
my $code = $authors_subfield->[0]; |
1029 |
my $value = $authors_subfield->[1]; |
1030 |
my $linkvalue = $value; |
1031 |
$linkvalue =~ s/(\(|\))//g; |
1032 |
# UNIMARC author responsibility |
1033 |
if ( $marcflavour eq 'UNIMARC' and $code eq '4' ) { |
1034 |
$value = C4::Biblio::GetAuthorisedValueDesc( $field->tag(), $code, $value, '', $tagslib ); |
1035 |
$linkvalue = "($value)"; |
1036 |
} |
1037 |
# if no authority link, build a search query |
1038 |
unless ($subfield9) { |
1039 |
push @link_loop, { |
1040 |
limit => 'au', |
1041 |
'link' => $linkvalue, |
1042 |
operator => (scalar @link_loop) ? ' and ' : undef |
1043 |
}; |
1044 |
} |
1045 |
my @this_link_loop = @link_loop; |
1046 |
# do not display $0 |
1047 |
unless ( $code eq '0') { |
1048 |
push @subfields_loop, { |
1049 |
tag => $field->tag(), |
1050 |
code => $code, |
1051 |
value => $value, |
1052 |
link_loop => \@this_link_loop, |
1053 |
separator => (scalar @subfields_loop) ? $AuthoritySeparator : '' |
1054 |
}; |
1055 |
} |
1056 |
} |
1057 |
push @marcauthors, { |
1058 |
MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop, |
1059 |
authoritylink => $subfield9, |
1060 |
unimarc3 => $unimarc3 |
1061 |
}; |
1062 |
} |
1063 |
return \@marcauthors; |
1064 |
} |
1065 |
|
969 |
=head3 to_api |
1066 |
=head3 to_api |
970 |
|
1067 |
|
971 |
my $json = $biblio->to_api; |
1068 |
my $json = $biblio->to_api; |