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 170-175 Link Here
170
                        </div>
176
                        </div>
171
                    </div> <!-- / .#userauthdetails -->
177
                    </div> <!-- / .#userauthdetails -->
172
                </div> <!-- / .col-lg-10/12 -->
178
                </div> <!-- / .col-lg-10/12 -->
179
                [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
180
                    [% IF ( OpacNav || OpacNavBottom ) %]
181
                        <div class="col-lg-5 order-lg-3">
182
                    [% ELSE %]
183
                        <div class="col-lg-6 order-lg-3">
184
                    [% END %]
185
                        <div class="author_identifier">
186
                            <span>Identifiers</span>
187
                            <ul>
188
                            [% FOR identifier IN author_identifiers %]
189
                                <li>
190
                                [% SWITCH identifier.source.lower %]
191
                                [% CASE 'orcid' %]ORCID: <a href="https://orcid.org/[% identifier.number | url %]">[% identifier.number | html %]</a>
192
                                [% CASE %][% identifier.source | html %]: [% identifier.number | html %]
193
                                [% END %]
194
                                </li>
195
                            [% END %]
196
                            </ul>
197
                        </div>
198
                    </div>
199
                [% END %]
173
            </div> <!-- / .row -->
200
            </div> <!-- / .row -->
174
        </div> <!-- / .container-fluid -->
201
        </div> <!-- / .container-fluid -->
175
    </div> <!-- / .main -->
202
    </div> <!-- / .main -->
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (+33 lines)
Lines 494-499 Link Here
494
                                </a>
494
                                </a>
495
                            </li>
495
                            </li>
496
                        [% END %]
496
                        [% END %]
497
498
                        [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
499
                            <li id="tab_author_identifiers"><a href="#author_identifiers">Author identifiers</a></li>
500
                        [% END %]
501
497
                    </ul>
502
                    </ul>
498
503
499
                    <div class="tab-content">
504
                    <div class="tab-content">
Lines 953-958 Link Here
953
                                </div><!-- / #images -->
958
                                </div><!-- / #images -->
954
                            [% END # / IF OPACLocalCoverImages && localimages.size %]
959
                            [% END # / IF OPACLocalCoverImages && localimages.size %]
955
960
961
                            [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
962
                                <div id="author_identifiers">
963
                                    [% FOR author IN author_identifiers %]
964
                                        <div class="author_identifier">
965
                                            <span class="author_name"><a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% author.authid | uri %]">[% author.name | html %]</a></span>
966
                                            <ul>
967
                                            [% FOR identifier IN author.identifiers %]
968
                                                <li>
969
                                                [% SWITCH identifier.source.lower %]
970
                                                [% CASE 'orcid' %]ORCID:
971
                                                [% CASE 'scopus' %]ScopusID:
972
                                                [% CASE 'loop' %]loop:
973
                                                [% CASE 'rid' %]Publons:
974
                                                [% CASE %][% identifier.source | html %]:
975
                                                [% END %]
976
                                                [% IF identifier.linkage %]
977
                                                    <a href="[% identifier.linkage | uri %]">[% identifier.number | html %]</a>
978
                                                [% ELSE %]
979
                                                    [% identifier.number | html %]
980
                                                [% END %]
981
                                                </li>
982
                                            [% END %]
983
                                            </ul>
984
                                        </div>
985
                                    [% END %]
986
                                </div>
987
                            [% END %]
988
956
                    </div> <!-- / #bibliodescriptions -->
989
                    </div> <!-- / #bibliodescriptions -->
957
990
958
                    [% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %]
991
                    [% 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 1255-1258 $template->param( Link Here
1255
    'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1255
    'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1256
);
1256
);
1257
1257
1258
if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
1259
    my @author_identifiers;
1260
    for my $author ( @{ $biblio->get_marc_authors } ) {
1261
        my $authid    = $author->{authoritylink};
1262
        my $authority = Koha::Authorities->find($authid);
1263
        next unless $authority;
1264
        my $identifiers = $authority->get_identifiers;
1265
        next unless $identifiers && @$identifiers;
1266
        my ($name) =
1267
          map  { $_->{value} }
1268
          grep { $_->{code} eq 'a' ? $_ : () }
1269
          @{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} };
1270
        push @author_identifiers,
1271
          { authid => $authid, name => $name, identifiers => $identifiers };
1272
    }
1273
    $template->param( author_identifiers => \@author_identifiers );
1274
}
1275
1258
output_html_with_http_headers $query, $cookie, $template->output;
1276
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