Lines 852-857
sub get_marc_notes {
Link Here
|
852 |
return \@marcnotes; |
852 |
return \@marcnotes; |
853 |
} |
853 |
} |
854 |
|
854 |
|
|
|
855 |
=head3 get_authors_from_MARC |
856 |
|
857 |
my $authors = $biblio->get_authors_from_MARC; |
858 |
|
859 |
Get all authors from the MARC record and returns them in an array. |
860 |
The authors are stored in different fields depending on MARC flavour |
861 |
|
862 |
=cut |
863 |
|
864 |
sub get_authors_from_MARC { |
865 |
my ( $self, $params ) = @_; |
866 |
|
867 |
my ( $mintag, $maxtag, $fields_filter ); |
868 |
my $marcflavour = C4::Context->preference('marcflavour'); |
869 |
|
870 |
# tagslib useful only for UNIMARC author responsibilities |
871 |
my $tagslib; |
872 |
if ( $marcflavour eq "UNIMARC" ) { |
873 |
# FIXME : we don't have the framework available, we take the default framework. May be buggy on some setups, will be usually correct. |
874 |
$tagslib = C4::Biblio::GetMarcStructure( 1, '', { unsafe => 1 }); |
875 |
$mintag = "700"; |
876 |
$maxtag = "712"; |
877 |
$fields_filter = '7..'; |
878 |
} else { # marc21/normarc |
879 |
$mintag = "700"; |
880 |
$maxtag = "720"; |
881 |
$fields_filter = '7..'; |
882 |
} |
883 |
|
884 |
my @marcauthors; |
885 |
my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator'); |
886 |
|
887 |
foreach my $field ( $self->metadata->record->field($fields_filter) ) { |
888 |
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; |
889 |
my @subfields_loop; |
890 |
my @link_loop; |
891 |
my @subfields = $field->subfields(); |
892 |
my $count_auth = 0; |
893 |
|
894 |
# if there is an authority link, build the link with Koha-Auth-Number: subfield9 |
895 |
my $subfield9 = $field->subfield('9'); |
896 |
if ($subfield9) { |
897 |
my $linkvalue = $subfield9; |
898 |
$linkvalue =~ s/(\(|\))//g; |
899 |
@link_loop = ( { 'limit' => 'an', 'link' => $linkvalue } ); |
900 |
} |
901 |
|
902 |
# other subfields |
903 |
my $unimarc3; |
904 |
for my $authors_subfield (@subfields) { |
905 |
next if ( $authors_subfield->[0] eq '9' ); |
906 |
|
907 |
# unimarc3 contains the $3 of the author for UNIMARC. |
908 |
# For french academic libraries, it's the "ppn", and it's required for idref webservice |
909 |
$unimarc3 = $authors_subfield->[1] if $marcflavour eq 'UNIMARC' and $authors_subfield->[0] =~ /3/; |
910 |
|
911 |
# don't load unimarc subfields 3, 5 |
912 |
next if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /3|5/ ) ); |
913 |
|
914 |
my $code = $authors_subfield->[0]; |
915 |
my $value = $authors_subfield->[1]; |
916 |
my $linkvalue = $value; |
917 |
$linkvalue =~ s/(\(|\))//g; |
918 |
# UNIMARC author responsibility |
919 |
if ( $marcflavour eq 'UNIMARC' and $code eq '4' ) { |
920 |
$value = C4::Biblio::GetAuthorisedValueDesc( $field->tag(), $code, $value, '', $tagslib ); |
921 |
$linkvalue = "($value)"; |
922 |
} |
923 |
# if no authority link, build a search query |
924 |
unless ($subfield9) { |
925 |
push @link_loop, { |
926 |
limit => 'au', |
927 |
'link' => $linkvalue, |
928 |
operator => (scalar @link_loop) ? ' and ' : undef |
929 |
}; |
930 |
} |
931 |
my @this_link_loop = @link_loop; |
932 |
# do not display $0 |
933 |
unless ( $code eq '0') { |
934 |
push @subfields_loop, { |
935 |
tag => $field->tag(), |
936 |
code => $code, |
937 |
value => $value, |
938 |
link_loop => \@this_link_loop, |
939 |
separator => (scalar @subfields_loop) ? $AuthoritySeparator : '' |
940 |
}; |
941 |
} |
942 |
} |
943 |
push @marcauthors, { |
944 |
MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop, |
945 |
authoritylink => $subfield9, |
946 |
unimarc3 => $unimarc3 |
947 |
}; |
948 |
} |
949 |
return \@marcauthors; |
950 |
} |
951 |
|
855 |
=head3 to_api |
952 |
=head3 to_api |
856 |
|
953 |
|
857 |
my $json = $biblio->to_api; |
954 |
my $json = $biblio->to_api; |