@@ -, +, @@ defined Notice the normal view of results "AuthorityXSLTOpacResultsDisplay" .../koha/koha-tmpl/intranet-tmpl/prog/en/XSLT/UNIMARCauthResults.xsl --- .../data/mysql/atomicupdate/bug-30036.pl | 15 ++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/staff_interface.pref | 5 ++++ .../opac-authoritiessearchresultlist.tt | 8 ++++++- opac/opac-authorities-home.pl | 23 +++++++++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug-30036.pl --- a/installer/data/mysql/atomicupdate/bug-30036.pl +++ a/installer/data/mysql/atomicupdate/bug-30036.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => '30036', + description => 'Add syspref AuthorityXSLTOpacResultsDisplay', + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $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') + }); + }, +}; --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/installer/data/mysql/mandatory/sysprefs.sql @@ -70,6 +70,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'), ('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','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'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref @@ -1,5 +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 authority results in the staff interface using XSLT stylesheet at: ' - pref: AuthorityXSLTResultsDisplay --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt @@ -106,7 +106,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 ) %] --- a/opac/opac-authorities-home.pl +++ a/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( --