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