Bugzilla – Attachment 163167 Details for
Bug 29948
Display author information for researchers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29948: Display authors information along with the identifiers
Bug-29948-Display-authors-information-along-with-t.patch (text/plain), 15.91 KB, created by
Jonathan Druart
on 2024-03-15 08:05:41 UTC
(
hide
)
Description:
Bug 29948: Display authors information along with the identifiers
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-03-15 08:05:41 UTC
Size:
15.91 KB
patch
obsolete
>From 0991d0f713c744f754e1e0a8c46b47c0b8429422 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 13 Mar 2024 16:07:47 +0100 >Subject: [PATCH] Bug 29948: Display authors information along with the > identifiers > >Sponsored-by: Orex Digital >--- > Koha/Authority.pm | 108 +++++++++++++++++- > .../data/mysql/atomicupdate/bug_29948.pl | 16 +++ > .../en/modules/admin/preferences/opac.pref | 12 ++ > .../en/includes/authority-information.inc | 74 ++++++++++++ > .../bootstrap/en/modules/opac-detail.tt | 29 ++++- > opac/opac-detail.pl | 18 +++ > 6 files changed, 250 insertions(+), 7 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_29948.pl > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc > >diff --git a/Koha/Authority.pm b/Koha/Authority.pm >index 509d2f9ae71..18146b8b565 100644 >--- a/Koha/Authority.pm >+++ b/Koha/Authority.pm >@@ -122,7 +122,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; > >@@ -137,6 +137,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_a = $field->subfield('a'); >+ push @{ $information->{place_of_death} }, { place_of_death => $sf_a, }; >+ } >+ } 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() >diff --git a/installer/data/mysql/atomicupdate/bug_29948.pl b/installer/data/mysql/atomicupdate/bug_29948.pl >new file mode 100755 >index 00000000000..3b8f0a682b3 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_29948.pl >@@ -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'"; >+ }, >+}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 1056c79a155..e45f637a82f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -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 >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc >new file mode 100644 >index 00000000000..9f1f5c6d71e >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc >@@ -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 %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index dd4114d0b2d..2dbf747e433 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -493,9 +493,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 %] > >@@ -941,8 +947,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> >@@ -953,7 +970,7 @@ > </ul> > </div> > [% END %] >- [% END # /tab_panel#author_identifiers %] >+ [% END # /tab_panel#author_identifiers_info %] > [% END %] > > [% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index b9c644e38d7..f8f7c3666de 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -1245,4 +1245,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; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29948
:
163167
|
163168
|
163169
|
163696
|
163697
|
163698
|
163699
|
163700
|
166166
|
166167
|
166168
|
166169
|
166181
|
166183
|
166184
|
166185
|
166186
|
166197
|
166198
|
166199
|
166200
|
166201
|
166202
|
166203
|
166205
|
166206
|
166207
|
166208
|
166209
|
166210
|
166211
|
166594
|
166595
|
166596
|
166597
|
166598
|
166599
|
166600
|
166642