From 763a104d2e38c66d4a2fdf4531e1e48955a56501 Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Mon, 7 Feb 2022 12:34:52 +0100 Subject: [PATCH] Bug 30036: Add xslt for authority results normal view in OPAC This patch provides a xslt stylesheet on authority results normal view in OPAC. Have a look on opac-authorities-home.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)Notice the normal view of results 5)Apply patch 6)INTRA: Home > Administration > System preferences ->find "AuthorityXSLTOpacResultsDisplay" 7)Write the path where your file is, ex: '/home/koha/src/UNIMARCauthResults.xsl' 8)Save changes 9)Repeat 3) and 4) and notice the xslt view of results --- .gitignore | 2 +- ...spref-AuthorityXSLTOpacResultsDisplay.perl | 9 ++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/staff_interface.pref | 4 ++++ .../opac-authoritiessearchresultlist.tt | 8 ++++++- opac/opac-authorities-home.pl | 23 +++++++++++++++++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacResultsDisplay.perl diff --git a/.gitignore b/.gitignore index c70d94a1dd..5c9d3a90c0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ /pm_to_blib node_modules/ koha-tmpl/opac-tmpl/bootstrap/css/maps/ -koha-tmpl/intranet-tmpl/prog/css/maps/ +koha-tmpl/intranet-tmpl/prog/css/maps/ \ No newline at end of file diff --git a/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacResultsDisplay.perl b/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacResultsDisplay.perl new file mode 100644 index 0000000000..27853975ea --- /dev/null +++ b/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTOpacResultsDisplay.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if (CheckVersion($DBversion)) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) + VALUES ('AuthorityXSLTOpacResultsDisplay','','','Enable XSL stylesheet control over authority results page display on opac','Free') + }); + + NewVersion($DBversion, '11083', 'Add syspref AuthorityXSLTOpacResultsDisplay'); +} \ No newline at end of file diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index dd83a00fd8..ffb2d7b5d5 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'), +('AuthorityXSLTOpacResultsDisplay','','','Enable XSL stylesheet control over authority results 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..ed3cc32b6b 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 results in the opac interface using XSLT stylesheet at: ' + - pref: AuthorityXSLTOpacResultsDisplay + class: file + - '
Options:{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-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt index 8415fb4360..fe51ca00ed 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt @@ -105,7 +105,13 @@ [% FOREACH resul IN result %] - [% PROCESS authresult summary=resul.summary %] + + [% IF resul.html %] + [% resul.html | $raw %] + [% ELSE %] + [% PROCESS authresult summary=resul.summary authid=resul.authid %] + [% END %] + Details [% resul.authtype | html %] [% UNLESS ( resul.isEDITORS ) %] diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl index eb795f4ed3..1f10c31835 100755 --- a/opac/opac-authorities-home.pl +++ b/opac/opac-authorities-home.pl @@ -28,6 +28,8 @@ use C4::Context; use C4::Output qw( pagination_bar output_html_with_http_headers ); use C4::Koha; use C4::Search::History; +use C4::Languages; +use Koha::XSLT::Base; use Koha::Authority::Types; use Koha::SearchEngine::Search; @@ -100,6 +102,27 @@ if ( $op eq "do_search" ) { $to = $startfrom * $resultsperpage; } + my $AuthorityXSLTOpacResultsDisplay = C4::Context->preference('AuthorityXSLTOpacResultsDisplay'); + if ($results && $AuthorityXSLTOpacResultsDisplay) { + my $lang = C4::Languages::getlanguage(); + foreach my $result (@$results) { + my $authority = Koha::Authorities->find($result->{authid}); + next unless $authority; + my $authtypecode = $authority->authtypecode; + my $xsl = $AuthorityXSLTOpacResultsDisplay; + + $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; + } + $result->{html} = $output; + } + } + $template->param( result => $results ) if $results; $template->param( -- 2.17.1