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