[Koha-bugs] [Bug 21330] Add xslt for authority normal view in OPAC
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Mon Feb 7 13:56:46 CET 2022
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21330
--- Comment #3 from Jérémy Breuillard <jeremy.breuillard at biblibre.com> ---
Comment on attachment 130208
--> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=130208
Bug 21330: Add xslt for authority normal view in OPAC
>From fb4cd8de85a004d6a51b48cca1f1fcb1638495c0 Mon Sep 17 00:00:00 2001
>From: jeremy breuillard <jeremy.breuillard at biblibre.com>
>Date: Mon, 7 Feb 2022 12:00:00 +0100
>Subject: [PATCH] Bug 21330: Add xslt for authority normal view in OPAC
>
>This patch provides a xslt stylesheet on authority normal view in OPAC. Have a look on opac-authoritiesdetail.pl
>
>Test plan:
>1)You need the file 'UNIMARCauthResults.xsl' -> get it in the patch from Bug 11083
>2)For testing make sure to have at least one or more authorities defined
>
>3)OPAC: Home > Authority search(Submit) > Authority search results
>4)Click details on a result and notice the view
>5)Apply patch
>6)INTRA: Home > Administration > System preferences ->find "AuthorityXSLTOpacDetailsDisplay"
>7)Write the path where your file is, ex: '/home/koha/src/UNIMARCauthResults.xsl'
>8)Save changes
>9)Repeat 2) and 3) and notice the display
>
>This is a similar bug: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30036
>---
> .gitignore | 1 +
> ...spref-AuthorityXSLTOpacDetailsDisplay.perl | 9 ++
> installer/data/mysql/mandatory/sysprefs.sql | 1 +
> .../admin/preferences/staff_interface.pref | 4 +
> .../bootstrap/en/modules/opac-auth-detail.tt | 96 ++-----------------
> opac/opac-authoritiesdetail.pl | 29 +++++-
> 6 files changed, 45 insertions(+), 95 deletions(-)
> create mode 100644 installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacDetailsDisplay.perl
>
>diff --git a/.gitignore b/.gitignore
>index c70d94a1dd..b0f5f623e8 100644
>--- a/.gitignore
>+++ b/.gitignore
>@@ -5,3 +5,4 @@
> node_modules/
> koha-tmpl/opac-tmpl/bootstrap/css/maps/
> koha-tmpl/intranet-tmpl/prog/css/maps/
>+UNIMARCauthResults.xsl
>\ No newline at end of file
>diff --git a/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacDetailsDisplay.perl b/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacDetailsDisplay.perl
>new file mode 100644
>index 0000000000..868113b885
>--- /dev/null
>+++ b/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacDetailsDisplay.perl
>@@ -0,0 +1,9 @@
>+$DBversion = 'XXX';
>+if (CheckVersion($DBversion)) {
>+ $dbh->do(q{
>+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
>+ VALUES ('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free')
>+ });
>+
>+ NewVersion($DBversion, '11083', 'Add syspref AuthorityXSLTResultsDisplay');
>+}
>\ No newline at end of file
>diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql
>index dd83a00fd8..01cbd8f8e8 100644
>--- a/installer/data/mysql/mandatory/sysprefs.sql
>+++ b/installer/data/mysql/mandatory/sysprefs.sql
>@@ -69,6 +69,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
> ('AuthorityMergeLimit','50',NULL,'Maximum number of biblio records updated immediately when an authority record has been modified.','integer'),
> ('AuthorityMergeMode','loose','loose|strict','Authority merge mode','Choice'),
> ('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'),
>+('AuthorityXSLTOpacDetailsDisplay','','','Enable XSL stylesheet control over authority details page display on opac','Free'),
> ('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'),
> ('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'),
> ('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref
>index 10c41c581d..4e63e68439 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref
>@@ -1,6 +1,10 @@
> Staff interface:
> Appearance:
> -
>+ - 'Display authority details in the opac interface using XSLT stylesheet at: '
>+ - pref: AuthorityXSLTOpacDetailsDisplay
>+ class: file
>+ - '<br />Options:<ul><li>Put a path to define a xslt file</li><li>Put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language and {authtypecode} will be replaced by the authority type code'
> - "Display language selector on "
> - pref: StaffLangSelectorMode
> choices:
>diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
>index f0d9fbcc2d..9629aaf05f 100644
>--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
>+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
>@@ -50,17 +50,12 @@
> </span>
> </div>
>
>- [% IF ( displayhierarchy ) %]
>- <div id="hierarchies">
>- [% PROCESS showhierarchy trees = loophierarchies %]
>- </div>
>- [% END %]
>-
> <h1>[% summary.mainentry | html %][% IF authtypetext %] ([% authtypetext | html %])[% END %]</h1>
>
> <div class="usedin">
> [% IF count %]<a href="/cgi-bin/koha/opac-search.pl?type=opac&q=[% authid | uri %]&idx=an,phr">Number of records used in: [% count | html %]</a>[% ELSE %]This authority is not used in any records.[% END %]
> </div>
>+ <br>
>
> <div class="authstanza">
> [% FOREACH authorize IN summary.authorized %]
>@@ -72,91 +67,12 @@
> [% PROCESS otherscript headings=summary.otherscript wantcategory='preferred' %]
> </div>
>
>- [% IF summary.seefrom.size %]
>- <div class="authstanza seefrom">
>- <div class="authstanzaheading">Used for/see from:</div>
>- <ul class="seefrom">
>- [% FOREACH seefro IN summary.seefrom %]
>- <li class="heading seefrom auth[% seefro.field | html %]">
>- [% IF seefro.type && seefro.type != 'seefrom' %]
>- <span class="label">[% PROCESS authtypelabel type=seefro.type | trim %]:</span>
>- [% END %]
>- <span class="seefrom">[% PROCESS authheadingdisplay heading=seefro.heading search=seefrosearch authid=seefro.authid %]</span>
>- </li>
>- [% END %]
>- [% PROCESS otherscript headings=summary.otherscript wantcategory='seefrom' %]
>- </ul>
>- </div>
>- [% END %]
>-
>- [% IF summary.seealso.size %]
>- <div class="authstanza seealso">
>- <div class="authstanzaheading">See also:</div>
>- <ul class="seelso">
>- [% FOREACH seeals IN summary.seealso %]
>- <li class="heading seealso auth[% seeals.field | html %]">
>- [% IF seeals.type && seeals.type != 'seealso' %]
>- <span class="label">[% PROCESS authtypelabel type=seeals.type | trim %]:</span>
>- [% END %]
>- <span class="seealso">[% PROCESS authheadingdisplay heading=seeals.heading search=seeals.search authid=seeals.authid %]</span>
>- </li>
>- [% END %]
>- [% PROCESS otherscript headings=summary.otherscript wantcategory='seealso' %]
>- </ul>
>- </div>
>- [% END %]
>-
>- [% IF marcflavour == 'UNIMARC' && summary.otherscript %]
>- <div class="authstanza">
>- <div class="authstanzaheading">Other forms:</div>
>- <ul>
>- [% FOREACH otherscrip IN summary.otherscript %]
>- <li>
>- [% PROCESS language lang=otherscrip.lang | trim %]:
>- <span class="otherscript">[% otherscrip.term | html %]</span>
>- </li>
>- [% END %]
>- </ul>
>- </div>
>+ [% IF authresult.html %]
>+ [% authresult.html | $raw %]
>+ [% ELSE %]
>+ [% PROCESS authresult summary=authresult.summary authid=authresult.authid %]
> [% END %]
>-
>- [% IF ( MARCURLS ) %]
>- <div class="authstanza online_resources">
>- <span class="label">Online resources:</span>
>- <ul>
>- [% FOREACH MARCurl IN MARCURLS %]
>- <li>[% IF ( MARCurl.part ) %][% MARCurl.part | html %]<br />[% END %]
>- [% IF ( Koha.Preference('OPACURLOpenInNewWindow') ) %]
>- <a href="[% MARCurl.MARCURL | url %]" title="[% MARCurl.MARCURL | html %]" target="_blank" rel="noreferrer">
>- [% ELSE %]
>- <a href="[% MARCurl.MARCURL | url %]" title="[% MARCurl.MARCURL | html %]">
>- [% END %]
>- [% MARCurl.linktext | html %]</a>
>- [% IF ( MARCurl.notes ) %]
>- <ul>
>- [% FOREACH note IN MARCurl.notes %]
>- <li>[% note.note | html %]</li>
>- [% END %]
>- </ul>
>- [% END %]
>- </li>
>- [% END # /FOREACH MARCURLS %]
>- </ul>
>- </div>
>- [% END # / IF MARCURLS %]
>-
>- <div id="authdescriptions" class="toptabs">
>- <ul>
>- <li id="tab_descriptions"><a href="#descriptions">Notes</a></li>
>- </ul>
>- <div id="descriptions">
>- <div class="content_set">
>- [% FOREACH note IN summary.notes %]
>- <p class="note auth[% note.field | html %]">[% note.note | html %]</p>
>- [% END %]
>- </div>
>- </div>
>- </div>
>+
> </div> <!-- / .#userauthdetails -->
> </div> <!-- / .col-lg-10/12 -->
> </div> <!-- / .row -->
>diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl
>index ed0a1c7014..c3ac12fed2 100755
>--- a/opac/opac-authoritiesdetail.pl
>+++ b/opac/opac-authoritiesdetail.pl
>@@ -69,8 +69,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
>
> my $authid = $query->param('authid');
> $authid = int($authid);
>-my $record = GetAuthority( $authid );
>-if ( ! $record ) {
>+my $authresult = GetAuthority( $authid );
>+if ( ! $authresult ) {
> print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
> exit;
> }
>@@ -86,7 +86,25 @@ if ($display_hierarchy){
> my $count = $authority ? $authority->get_usage_count : 0;
>
> my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
>-my $marcurlsarray = GetMarcUrls( $record, $marcflavour );
>+my $marcurlsarray = GetMarcUrls( $authresult, $marcflavour );
>+
>+my $AuthorityXSLTResultsDisplay = C4::Context->preference('AuthorityXSLTResultsDisplay');
>+ if ($authresult && $AuthorityXSLTResultsDisplay) {
>+ my $lang = C4::Languages::getlanguage();
>+
>+ my $xsl = $AuthorityXSLTResultsDisplay;
>+
>+ $xsl =~ s/\{langcode\}/$lang/g;
>+ $xsl =~ s/\{authtypecode\}/$authtypecode/g;
>+ my $xslt_engine = Koha::XSLT::Base->new;
>+ my $output = $xslt_engine->transform({ xml => $authority->marcxml, file => $xsl });
>+ if ($xslt_engine->err) {
>+ warn "XSL transformation failed ($xsl): " . $xslt_engine->err;
>+ next;
>+ }
>+ $authresult->{html} = $output;
>+
>+ }
>
> $template->param(
> authority_types => $authority_types,
>@@ -94,6 +112,7 @@ $template->param(
> authid => $authid,
> count => $count,
> MARCURLS => $marcurlsarray,
>+ authresult => $authresult,
> );
>
> # find the marc field/subfield used in biblio by this authority
>@@ -114,7 +133,7 @@ if ($show_marc) {
> my @loop_data = ();
>
> # loop through each tag
>- my @fields = $record->fields();
>+ my @fields = $authresult->fields();
> foreach my $field (@fields) {
> my @subfields_data;
>
>@@ -166,7 +185,7 @@ if ($show_marc) {
> }
> $template->param( "Tab0XX" => \@loop_data );
> } else {
>- my $summary = BuildSummary($record, $authid, $authtypecode);
>+ my $summary = BuildSummary($authresult, $authid, $authtypecode);
> $template->{VARS}->{'summary'} = $summary;
> }
>
>--
>2.17.1
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list