Lines 797-802
sub cover_images {
Link Here
|
797 |
return Koha::CoverImages->_new_from_dbic($cover_images_rs); |
797 |
return Koha::CoverImages->_new_from_dbic($cover_images_rs); |
798 |
} |
798 |
} |
799 |
|
799 |
|
|
|
800 |
=head3 get_authors_from_MARC |
801 |
|
802 |
my $authors = $biblio->get_authors_from_MARC; |
803 |
|
804 |
Get all authors from the MARC record and returns them in an array. |
805 |
The authors are stored in different fields depending on MARC flavour |
806 |
|
807 |
=cut |
808 |
|
809 |
sub get_authors_from_MARC { |
810 |
my ( $self, $params ) = @_; |
811 |
|
812 |
my ( $mintag, $maxtag, $fields_filter ); |
813 |
my $marcflavour = C4::Context->preference('marcflavour'); |
814 |
|
815 |
# tagslib useful only for UNIMARC author responsibilities |
816 |
my $tagslib; |
817 |
if ( $marcflavour eq "UNIMARC" ) { |
818 |
# FIXME : we don't have the framework available, we take the default framework. May be buggy on some setups, will be usually correct. |
819 |
$tagslib = C4::Biblio::GetMarcStructure( 1, '', { unsafe => 1 }); |
820 |
$mintag = "700"; |
821 |
$maxtag = "712"; |
822 |
$fields_filter = '7..'; |
823 |
} else { # marc21/normarc |
824 |
$mintag = "700"; |
825 |
$maxtag = "720"; |
826 |
$fields_filter = '7..'; |
827 |
} |
828 |
|
829 |
my @marcauthors; |
830 |
my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator'); |
831 |
|
832 |
foreach my $field ( $self->metadata->record->field($fields_filter) ) { |
833 |
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; |
834 |
my @subfields_loop; |
835 |
my @link_loop; |
836 |
my @subfields = $field->subfields(); |
837 |
my $count_auth = 0; |
838 |
|
839 |
# if there is an authority link, build the link with Koha-Auth-Number: subfield9 |
840 |
my $subfield9 = $field->subfield('9'); |
841 |
if ($subfield9) { |
842 |
my $linkvalue = $subfield9; |
843 |
$linkvalue =~ s/(\(|\))//g; |
844 |
@link_loop = ( { 'limit' => 'an', 'link' => $linkvalue } ); |
845 |
} |
846 |
|
847 |
# other subfields |
848 |
my $unimarc3; |
849 |
for my $authors_subfield (@subfields) { |
850 |
next if ( $authors_subfield->[0] eq '9' ); |
851 |
|
852 |
# unimarc3 contains the $3 of the author for UNIMARC. |
853 |
# For french academic libraries, it's the "ppn", and it's required for idref webservice |
854 |
$unimarc3 = $authors_subfield->[1] if $marcflavour eq 'UNIMARC' and $authors_subfield->[0] =~ /3/; |
855 |
|
856 |
# don't load unimarc subfields 3, 5 |
857 |
next if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /3|5/ ) ); |
858 |
|
859 |
my $code = $authors_subfield->[0]; |
860 |
my $value = $authors_subfield->[1]; |
861 |
my $linkvalue = $value; |
862 |
$linkvalue =~ s/(\(|\))//g; |
863 |
# UNIMARC author responsibility |
864 |
if ( $marcflavour eq 'UNIMARC' and $code eq '4' ) { |
865 |
$value = C4::Biblio::GetAuthorisedValueDesc( $field->tag(), $code, $value, '', $tagslib ); |
866 |
$linkvalue = "($value)"; |
867 |
} |
868 |
# if no authority link, build a search query |
869 |
unless ($subfield9) { |
870 |
push @link_loop, { |
871 |
limit => 'au', |
872 |
'link' => $linkvalue, |
873 |
operator => (scalar @link_loop) ? ' and ' : undef |
874 |
}; |
875 |
} |
876 |
my @this_link_loop = @link_loop; |
877 |
# do not display $0 |
878 |
unless ( $code eq '0') { |
879 |
push @subfields_loop, { |
880 |
tag => $field->tag(), |
881 |
code => $code, |
882 |
value => $value, |
883 |
link_loop => \@this_link_loop, |
884 |
separator => (scalar @subfields_loop) ? $AuthoritySeparator : '' |
885 |
}; |
886 |
} |
887 |
} |
888 |
push @marcauthors, { |
889 |
MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop, |
890 |
authoritylink => $subfield9, |
891 |
unimarc3 => $unimarc3 |
892 |
}; |
893 |
} |
894 |
return \@marcauthors; |
895 |
} |
800 |
|
896 |
|
801 |
=head3 to_api |
897 |
=head3 to_api |
802 |
|
898 |
|