@@ -, +, @@
$a source
$2 number
$6 link to the source
---
Koha/Authority.pm | 30 ++++++++++++
.../bootstrap/en/modules/opac-auth-detail.tt | 29 +++++++++++-
.../bootstrap/en/modules/opac-detail.tt | 33 +++++++++++++
opac/opac-authoritiesdetail.pl | 6 +++
opac/opac-detail.pl | 18 +++++++
t/db_dependent/Koha/Authorities.t | 47 ++++++++++++++++++-
6 files changed, 161 insertions(+), 2 deletions(-)
--- a/Koha/Authority.pm
+++ a/Koha/Authority.pm
@@ -114,6 +114,36 @@ sub controlled_indicators {
});
}
+=head3 get_identifiers
+
+ my $identifiers = $author->get_identifiers;
+
+Return a list of identifiers of the authors which are in 024$2$a
+
+=cut
+
+sub get_identifiers {
+ my ( $self, $params ) = @_;
+
+ my $flavour =
+ C4::Context->preference('marcflavour') eq 'UNIMARC'
+ ? 'UNIMARCAUTH'
+ : 'MARC21';
+ my $record =
+ MARC::Record->new_from_xml( $self->marcxml, 'UTF-8', $flavour );
+
+ my @identifiers;
+ for my $field ( $record->field('024') ) {
+ my $sf_2 = $field->subfield('2');
+ my $sf_a = $field->subfield('a');
+ my $sf_6 = $field->subfield('6');
+ next unless $sf_2 && $sf_a;
+ push @identifiers, {source => $sf_2, number => $sf_a, linkage => $sf_6};
+ }
+
+ return \@identifiers;
+}
+
=head2 Class Methods
=head3 type
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
@@ -43,7 +43,13 @@
[% INCLUDE 'navigation.inc' %]
-
+ [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
+
+ [% ELSE %]
+
+ [% END %]
+ [% ELSIF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
+
[% ELSE %]
[% END %]
@@ -170,6 +176,27 @@
+ [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
+ [% IF ( OpacNav || OpacNavBottom ) %]
+
+ [% ELSE %]
+
+ [% END %]
+
+
Identifiers
+
+ [% FOR identifier IN author_identifiers %]
+ -
+ [% SWITCH identifier.source.lower %]
+ [% CASE 'orcid' %]ORCID: [% identifier.number | html %]
+ [% CASE %][% identifier.source | html %]: [% identifier.number | html %]
+ [% END %]
+
+ [% END %]
+
+
+
+ [% END %]
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
@@ -494,6 +494,11 @@
[% END %]
+
+ [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
+ Author identifiers
+ [% END %]
+
@@ -953,6 +958,34 @@
[% END # / IF OPACLocalCoverImages && localimages.size %]
+ [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
+
+ [% FOR author IN author_identifiers %]
+
+
[% author.name | html %]
+
+ [% FOR identifier IN author.identifiers %]
+ -
+ [% SWITCH identifier.source.lower %]
+ [% CASE 'orcid' %]ORCID:
+ [% CASE 'scopus' %]ScopusID:
+ [% CASE 'loop' %]loop:
+ [% CASE 'rid' %]Publons:
+ [% CASE %][% identifier.source | html %]:
+ [% END %]
+ [% IF identifier.linkage %]
+ [% identifier.number | html %]
+ [% ELSE %]
+ [% identifier.number | html %]
+ [% END %]
+
+ [% END %]
+
+
+ [% END %]
+
+ [% END %]
+
[% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %]
--- a/opac/opac-authoritiesdetail.pl
+++ a/opac/opac-authoritiesdetail.pl
@@ -168,6 +168,12 @@ if ($show_marc) {
} else {
my $summary = BuildSummary($record, $authid, $authtypecode);
$template->{VARS}->{'summary'} = $summary;
+
+ if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
+ my $authority = Koha::Authorities->find($authid);
+ my $identifiers = $authority->get_identifiers;
+ $template->param( author_identifiers => $identifiers );
+ }
}
output_html_with_http_headers $query, $cookie, $template->output;
--- a/opac/opac-detail.pl
+++ a/opac/opac-detail.pl
@@ -1255,4 +1255,22 @@ $template->param(
'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
);
+if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
+ my @author_identifiers;
+ for my $author ( @{ $biblio->get_marc_authors } ) {
+ my $authid = $author->{authoritylink};
+ my $authority = Koha::Authorities->find($authid);
+ next unless $authority;
+ my $identifiers = $authority->get_identifiers;
+ next unless $identifiers && @$identifiers;
+ my ($name) =
+ map { $_->{value} }
+ grep { $_->{code} eq 'a' ? $_ : () }
+ @{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} };
+ push @author_identifiers,
+ { authid => $authid, name => $name, identifiers => $identifiers };
+ }
+ $template->param( author_identifiers => \@author_identifiers );
+}
+
output_html_with_http_headers $query, $cookie, $template->output;
--- a/t/db_dependent/Koha/Authorities.t
+++ a/t/db_dependent/Koha/Authorities.t
@@ -19,7 +19,7 @@
use Modern::Perl;
-use Test::More tests => 7;
+use Test::More tests => 8;
use MARC::Field;
use MARC::File::XML;
use MARC::Record;
@@ -242,4 +242,49 @@ sub few_marc_records {
return [ $marc ];
}
+subtest 'get_identifiers' => sub {
+ plan tests => 1;
+
+ t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
+ my $record = MARC::Record->new();
+ $record->add_fields(
+ [
+ '100', ' ', ' ',
+ a => 'Lastname, Firstname',
+ b => 'b',
+ c => 'c',
+ i => 'i'
+ ],
+ [
+ '024', '', '',
+ a => '0000-0002-1234-5678',
+ 2 => 'orcid',
+ 6 => 'https://orcid.org/0000-0002-1234-5678'
+ ],
+ [
+ '024', '', '',
+ a => '01234567890',
+ 2 => 'scopus',
+ 6 => 'https://www.scopus.com/authid/detail.uri?authorId=01234567890'
+ ],
+ );
+ my $authid = C4::AuthoritiesMarc::AddAuthority($record, undef, 'PERSO_NAME');
+ my $authority = Koha::Authorities->find($authid);
+ is_deeply(
+ $authority->get_identifiers,
+ [
+ {
+ source => 'orcid',
+ number => '0000-0002-1234-5678',
+ linkage => 'https://orcid.org/0000-0002-1234-5678'
+ },
+ {
+ source => 'scopus',
+ number => '01234567890',
+ linkage => 'https://www.scopus.com/authid/detail.uri?authorId=01234567890'
+ }
+ ]
+ );
+};
+
$schema->storage->txn_rollback;
--