Bug 29948: Display authors information along with the identifiers

Sponsored-by: Orex Digital

Signed-off-by: Signed-off-by: Hugo Agud <hagud@orex.es>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-03-13 16:07:47 +01:00 committed by Katrin Fischer
parent 11cdeb0889
commit 070f720aae
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
6 changed files with 250 additions and 7 deletions

View file

@ -150,7 +150,7 @@ Return a list of identifiers of the authors which are in 024$2$a
=cut
sub get_identifiers {
my ( $self, $params ) = @_;
my ( $self ) = @_;
my $record = $self->record;
@ -165,6 +165,112 @@ sub get_identifiers {
return \@identifiers;
}
=head3 get_information
my $information = $author->get_information;
Return a list of information of the authors (syspref OPACAuthorInformation)
=cut
sub get_information {
my ($self) = @_;
my $record = $self->record;
# FIXME UNIMARC not supported yet.
return if C4::Context->preference('marcflavour') eq 'UNIMARC';
my $information;
for my $info ( split ',', C4::Context->preference('OPACAuthorInformation') ) {
if ( $info eq 'activity' ) {
# activity: Activity (372$a$s$t)
for my $field ( $record->field('372') ) {
my $sf_a = $field->subfield('a');
my $sf_s = $field->subfield('s');
my $sf_t = $field->subfield('t');
push @{ $information->{activity} },
{ field_of_activity => $sf_a, start_period => $sf_s, end_period => $sf_t, };
}
} elsif ( $info eq 'address' ) {
# address: Address (371$a$b$d$e)
for my $field ( $record->field('371') ) {
my $sf_a = $field->subfield('a');
my $sf_b = $field->subfield('b');
my $sf_d = $field->subfield('d');
my $sf_e = $field->subfield('e');
push @{ $information->{address} },
{ address => $sf_a, city => $sf_b, country => $sf_d, postal_code => $sf_e, };
}
} elsif ( $info eq 'associated_group' ) {
# associated_group: Associated group (373$a$s$t$u$v$0)
for my $field ( $record->field('373') ) {
my $sf_a = $field->subfield('a');
my $sf_s = $field->subfield('s');
my $sf_t = $field->subfield('t');
my $sf_u = $field->subfield('u');
my $sf_v = $field->subfield('v');
my $sf_0 = $field->subfield('0');
push @{ $information->{associated_group} },
{
associated_group => $sf_a, start_period => $sf_s, end_period => $sf_t, uri => $sf_u,
source_of_information => $sf_v, authority_record_number => $sf_0,
};
}
} elsif ( $info eq 'email_address' ) {
# email_address: Electronic mail address (371$m)
for my $field ( $record->field('371') ) {
my $sf_m = $field->subfield('m');
push @{ $information->{email_address} }, { email_address => $sf_m, };
}
} elsif ( $info eq 'occupation' ) {
# occupation: Occupation (374$a$s$t$u$v$0)
for my $field ( $record->field('374') ) {
my $sf_a = $field->subfield('a');
my $sf_s = $field->subfield('s');
my $sf_t = $field->subfield('t');
my $sf_u = $field->subfield('u');
my $sf_v = $field->subfield('v');
my $sf_0 = $field->subfield('0');
push @{ $information->{occupation} },
{
occupation => $sf_a, start_period => $sf_s, end_period => $sf_t, uri => $sf_u,
source_of_information => $sf_v, authority_record_number => $sf_0,
};
}
} elsif ( $info eq 'place_of_birth' ) {
# place_of_birth: Place of birth (370$a)
for my $field ( $record->field('370') ) {
my $sf_a = $field->subfield('a');
push @{ $information->{place_of_birth} }, { place_of_birth => $sf_a, };
}
} elsif ( $info eq 'place_of_death' ) {
# place_of_death: Place of death (370$b)
for my $field ( $record->field('370') ) {
my $sf_b = $field->subfield('b');
push @{ $information->{place_of_death} }, { place_of_death => $sf_b, };
}
} elsif ( $info eq 'uri' ) {
# uri: URI (371$u)
for my $field ( $record->field('371') ) {
my $sf_u = $field->subfield('u');
push @{ $information->{uri} }, { uri => $sf_u, };
}
}
}
return $information;
}
=head3 record
my $record = $authority->record()

View file

@ -0,0 +1,16 @@
use Modern::Perl;
return {
bug_number => "29948",
description => "Display author information for researchers",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
$dbh->do(q{
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
('OPACAuthorInformation','0','','Display author information on the OPAC detail page','multiple_sortable')
});
say $out "Added new system preference 'OPACAuthorInformation'";
},
};

View file

@ -533,6 +533,18 @@ OPAC:
- "identifiers for authors and contributors to the detail pages in the OPAC."
- "This feature requires authorities with 024$2 and 024$a."
- "Valid source codes in $2 are currently: orcid, scopus, loop, rid and viaf."
-
- "Display the following information for authors and contributors to the detail pages in the OPAC."
- pref: OPACAuthorInformation
multiple:
activity: Activity (372$a$s$t)
address: Address (371$a$b$d$e)
associated_group: Associated group (373$a$s$t$u$v$0)
email_address: Electronic mail address (371$m)
occupation: Occupation (374$a$s$t$u$v$0)
place_of_birth: Place of birth (370$a)
place_of_death: Place of death (370$b)
uri: URI (371$u)
-
- "Calculate the amount a patron has 'saved' by using the library based on replacement prices, and display:"
- pref: OPACShowSavings

View file

@ -0,0 +1,74 @@
[% FOREACH info IN information %]
[% SWITCH info_type %]
[% CASE 'activity' %]
<li>
<span>
Field of activity: [% info.field_of_activity | html %]
[% IF info.start_period || info.end_period %]
(
[%~ IF info.start_period %]from: [% info.start_period | html %][% END %]
[% IF info.end_period %]until: [% info.end_period | html %][% END ~%]
)
[% END %]
</span>
</li>
[% CASE 'address' %]
<li>
<span>Address: [% info.address | html %] [% info.postal_code | html %] [% info.city | html %] [% info.country | html %]</span>
</li>
[% CASE 'associated_group' %]
<li>
<span>
Associated group: [% info.associated_group | html %]
[% IF info.start_period || info.end_period %]
(
[%~ IF info.start_period %]from: [% info.start_period | html %][% END %]
[% IF info.end_period %]until: [% info.end_period | html %][% END ~%]
)
[% END %]
[% IF info.uri %]<p>URI: [% info.uri | html %]</p>[% END %]
[% IF info.source_of_information %]<p>Source of information: [% info.source_of_information | html %]</p> [% END %]
[% IF info.authority_record_number %]<p>Authority record control number or standard number: [% info.authority_record_number | html %]</p>[% END %]
</span>
</li>
[% CASE 'email_address' %]
<li>
<span>
Email address: [% info.email_address | html %]
</span>
</li>
[% CASE 'occupation' %]
<li>
<span>
Occupation: [% info.occupation | html %]
[% IF info.start_period || info.end_period %]
(
[%~ IF info.start_period %]from: [% info.start_period | html %][% END %]
[% IF info.end_period %]until: [% info.end_period | html %][% END ~%]
)
[% END %]
[% IF info.uri %]<p>URI: [% info.uri | html %]</p>[% END %]
[% IF info.source_of_information %]<p>Source of information: [% info.source_of_information | html %]</p> [% END %]
[% IF info.authority_record_number %]<p>Authority record control number or standard number: [% info.authority_record_number | html %]</p>[% END %]
</span>
</li>
[% CASE 'place_of_birth' %]
<li>
<span>
Place of birth: [% info.place_of_birth | html %]
</span>
</li>
[% CASE 'place_of_death' %]
<li>
<span>
Place of death: [% info.place_of_death | html %]
</span>
</li>
[% CASE 'uri' %]
<li>
<span>
URI: [% info.uri | $raw | html %]
</span>
</li>
[% END %]
[% END %]

View file

@ -494,9 +494,15 @@
[% END %]
[% END %]
[% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
[% WRAPPER tab_item tabname= "author_identifiers" %]
<span>Author identifiers</span>
[% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size || Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
[% WRAPPER tab_item tabname= "author_identifiers_info" %]
[% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size && Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
<span>Author identifiers/information</span>
[% ELSIF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
<span>Author identifiers</span>
[% ELSIF Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
<span>Author information</span>
[% END %]
[% END %]
[% END %]
@ -942,8 +948,19 @@
[% END # /tab_panel#images %]
[% END # / IF OPACLocalCoverImages && localimages.size %]
[% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
[% WRAPPER tab_panel tabname="author_identifiers" %]
[% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size || Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
[% WRAPPER tab_panel tabname="author_identifiers_info" %]
[% FOR author IN author_information %]
<div class="author_information">
<span class="author_name"><a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% author.authid | uri %]">[% author.name | html %]</a></span>
<ul>
[% FOR info IN author.information.keys %]
[% PROCESS "authority-information.inc" information => author.information.$info, info_type => info %]
[% END %]
</ul>
</div>
[% END %]
[% FOR author IN author_identifiers %]
<div class="author_identifier">
<span class="author_name"><a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% author.authid | uri %]">[% author.name | html %]</a></span>
@ -954,7 +971,7 @@
</ul>
</div>
[% END %]
[% END # /tab_panel#author_identifiers %]
[% END # /tab_panel#author_identifiers_info %]
[% END %]
[% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %]

View file

@ -1251,4 +1251,22 @@ if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
$template->param( author_identifiers => \@author_identifiers );
}
if ( C4::Context->preference('OPACAuthorInformation') ) {
my @author_information;
for my $author ( @{ $biblio->get_marc_authors } ) {
my $authid = $author->{authoritylink};
my $authority = Koha::Authorities->find($authid);
next unless $authority;
my $information = $authority->get_information;
next unless $information;
my ($name) =
map { $_->{value} }
grep { $_->{code} eq 'a' ? $_ : () }
@{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} };
push @author_information,
{ authid => $authid, name => $name, information => $information };
}
$template->param( author_information => \@author_information );
}
output_html_with_http_headers $query, $cookie, $template->output;