View | Details | Raw Unified | Return to bug 29897
Collapse All | Expand All

(-)a/Koha/Authority.pm (+30 lines)
Lines 114-119 sub controlled_indicators { Link Here
114
    });
114
    });
115
}
115
}
116
116
117
=head3 get_identifiers
118
119
    my $identifiers = $author->get_identifiers;
120
121
Return a list of identifiers of the authors which are in 024$2$a
122
123
=cut
124
125
sub get_identifiers {
126
    my ( $self, $params ) = @_;
127
128
    my $flavour =
129
      C4::Context->preference('marcflavour') eq 'UNIMARC'
130
      ? 'UNIMARCAUTH'
131
      : 'MARC21';
132
    my $record =
133
      MARC::Record->new_from_xml( $self->marcxml, 'UTF-8', $flavour );
134
135
    my @identifiers;
136
    for my $field ( $record->field('024') ) {
137
        my $sf_2 = $field->subfield('2');
138
        my $sf_a = $field->subfield('a');
139
        my $sf_6 = $field->subfield('6');
140
        next unless $sf_2 && $sf_a;
141
        push @identifiers, {source => $sf_2, number => $sf_a, linkage => $sf_6};
142
    }
143
144
    return \@identifiers;
145
}
146
117
=head2 Class Methods
147
=head2 Class Methods
118
148
119
=head3 type
149
=head3 type
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt (-1 / +28 lines)
Lines 43-49 Link Here
43
                            [% INCLUDE 'navigation.inc' %]
43
                            [% INCLUDE 'navigation.inc' %]
44
                        </div>
44
                        </div>
45
                    </div>
45
                    </div>
46
                    <div class="col-lg-10 order-first order-md-first order-lg-2">
46
                    [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
47
                        <div class="col-lg-5 order-first order-md-first order-lg-2">
48
                    [% ELSE %]
49
                        <div class="col-lg-10 order-first order-md-first order-lg-2">
50
                    [% END %]
51
                [% ELSIF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
52
                    <div class="col-lg-6 order-first order-md-first order-lg-2">
47
                [% ELSE %]
53
                [% ELSE %]
48
                    <div class="col order-first order-md-first order-lg-2">
54
                    <div class="col order-first order-md-first order-lg-2">
49
                [% END %]
55
                [% END %]
Lines 166-171 Link Here
166
                        </div>
172
                        </div>
167
                    </div> <!-- / .#userauthdetails -->
173
                    </div> <!-- / .#userauthdetails -->
168
                </div> <!-- / .col-lg-10/12 -->
174
                </div> <!-- / .col-lg-10/12 -->
175
                [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
176
                    [% IF ( OpacNav || OpacNavBottom ) %]
177
                        <div class="col-lg-5 order-lg-3">
178
                    [% ELSE %]
179
                        <div class="col-lg-6 order-lg-3">
180
                    [% END %]
181
                        <div class="author_identifier">
182
                            <span>Identifiers</span>
183
                            <ul>
184
                            [% FOR identifier IN author_identifiers %]
185
                                <li>
186
                                [% SWITCH identifier.source.lower %]
187
                                [% CASE 'orcid' %]ORCID: <a href="https://orcid.org/[% identifier.number | url %]">[% identifier.number | html %]</a>
188
                                [% CASE %][% identifier.source | html %]: [% identifier.number | html %]
189
                                [% END %]
190
                                </li>
191
                            [% END %]
192
                            </ul>
193
                        </div>
194
                    </div>
195
                [% END %]
169
            </div> <!-- / .row -->
196
            </div> <!-- / .row -->
170
        </div> <!-- / .container-fluid -->
197
        </div> <!-- / .container-fluid -->
171
    </div> <!-- / .main -->
198
    </div> <!-- / .main -->
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (+32 lines)
Lines 469-474 Link Here
469
                            [% IF ( defaulttab == 'media' ) %]<li id="tab_html5media" class="ui-tabs-active">[% ELSE %]<li id="tab_html5media">[% END %]<a href="#html5media">Play media</a></li>
469
                            [% IF ( defaulttab == 'media' ) %]<li id="tab_html5media" class="ui-tabs-active">[% ELSE %]<li id="tab_html5media">[% END %]<a href="#html5media">Play media</a></li>
470
                        [% END %]
470
                        [% END %]
471
471
472
                        [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
473
                            <li id="tab_author_identifiers"><a href="#author_identifiers">Author identifiers</a></li>
474
                        [% END %]
475
472
                    </ul>
476
                    </ul>
473
477
474
                    [% IF ( serialcollection ) %]
478
                    [% IF ( serialcollection ) %]
Lines 927-932 Link Here
927
                            </div><!-- / #images -->
931
                            </div><!-- / #images -->
928
                        [% END # / IF OPACLocalCoverImages && localimages.size %]
932
                        [% END # / IF OPACLocalCoverImages && localimages.size %]
929
933
934
                        [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
935
                            <div id="author_identifiers">
936
                                [% FOR author IN author_identifiers %]
937
                                    <div class="author_identifier">
938
                                        <span class="author_name"><a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% author.authid | uri %]">[% author.name | html %]</a></span>
939
                                        <ul>
940
                                        [% FOR identifier IN author.identifiers %]
941
                                            <li>
942
                                            [% SWITCH identifier.source.lower %]
943
                                            [% CASE 'orcid' %]ORCID:
944
                                            [% CASE 'scopus' %]ScopusID:
945
                                            [% CASE 'loop' %]loop:
946
                                            [% CASE 'rid' %]Publons:
947
                                            [% CASE %][% identifier.source | html %]:
948
                                            [% END %]
949
                                            [% IF identifier.linkage %]
950
                                                <a href="[% identifier.linkage | uri %]">[% identifier.number | html %]</a>
951
                                            [% ELSE %]
952
                                                [% identifier.number | html %]
953
                                            [% END %]
954
                                            </li>
955
                                        [% END %]
956
                                        </ul>
957
                                    </div>
958
                                [% END %]
959
                            </div>
960
                        [% END %]
961
930
                </div> <!-- / #bibliodescriptions -->
962
                </div> <!-- / #bibliodescriptions -->
931
963
932
                [% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %]
964
                [% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %]
(-)a/opac/opac-authoritiesdetail.pl (+6 lines)
Lines 168-173 if ($show_marc) { Link Here
168
} else {
168
} else {
169
    my $summary = BuildSummary($record, $authid, $authtypecode);
169
    my $summary = BuildSummary($record, $authid, $authtypecode);
170
    $template->{VARS}->{'summary'} = $summary;
170
    $template->{VARS}->{'summary'} = $summary;
171
172
    if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
173
        my $authority = Koha::Authorities->find($authid);
174
        my $identifiers = $authority->get_identifiers;
175
        $template->param( author_identifiers => $identifiers );
176
    }
171
}
177
}
172
178
173
output_html_with_http_headers $query, $cookie, $template->output;
179
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/opac-detail.pl (+18 lines)
Lines 1245-1248 $template->param( Link Here
1245
    'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1245
    'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1246
);
1246
);
1247
1247
1248
if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
1249
    my @author_identifiers;
1250
    for my $author ( @{ $biblio->get_marc_authors } ) {
1251
        my $authid    = $author->{authoritylink};
1252
        my $authority = Koha::Authorities->find($authid);
1253
        next unless $authority;
1254
        my $identifiers = $authority->get_identifiers;
1255
        next unless $identifiers && @$identifiers;
1256
        my ($name) =
1257
          map  { $_->{value} }
1258
          grep { $_->{code} eq 'a' ? $_ : () }
1259
          @{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} };
1260
        push @author_identifiers,
1261
          { authid => $authid, name => $name, identifiers => $identifiers };
1262
    }
1263
    $template->param( author_identifiers => \@author_identifiers );
1264
}
1265
1248
output_html_with_http_headers $query, $cookie, $template->output;
1266
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/t/db_dependent/Koha/Authorities.t (-2 / +46 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 7;
22
use Test::More tests => 8;
23
use MARC::Field;
23
use MARC::Field;
24
use MARC::File::XML;
24
use MARC::File::XML;
25
use MARC::Record;
25
use MARC::Record;
Lines 242-245 sub few_marc_records { Link Here
242
    return [ $marc ];
242
    return [ $marc ];
243
}
243
}
244
244
245
subtest 'get_identifiers' => sub {
246
    plan tests => 1;
247
248
    t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
249
    my $record = MARC::Record->new();
250
    $record->add_fields(
251
        [
252
            '100', ' ', ' ',
253
            a => 'Lastname, Firstname',
254
            b => 'b',
255
            c => 'c',
256
            i => 'i'
257
        ],
258
        [
259
            '024', '', '',
260
            a => '0000-0002-1234-5678',
261
            2 => 'orcid',
262
            6 => 'https://orcid.org/0000-0002-1234-5678'
263
        ],
264
        [
265
            '024', '', '',
266
            a => '01234567890',
267
            2 => 'scopus',
268
            6 => 'https://www.scopus.com/authid/detail.uri?authorId=01234567890'
269
        ],
270
    );
271
    my $authid = C4::AuthoritiesMarc::AddAuthority($record, undef, 'PERSO_NAME');
272
    my $authority = Koha::Authorities->find($authid);
273
    is_deeply(
274
        $authority->get_identifiers,
275
        [
276
            {
277
                source  => 'orcid',
278
                number  => '0000-0002-1234-5678',
279
                linkage => 'https://orcid.org/0000-0002-1234-5678'
280
            },
281
            {
282
                source => 'scopus',
283
                number => '01234567890',
284
                linkage => 'https://www.scopus.com/authid/detail.uri?authorId=01234567890'
285
            }
286
        ]
287
    );
288
};
289
245
$schema->storage->txn_rollback;
290
$schema->storage->txn_rollback;
246
- 

Return to bug 29897