From 657c54d8c38ce1b52d8ae95320d1f537db6d9d98 Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Fri, 15 Apr 2022 16:51:14 +0200 Subject: [PATCH] MT 36361: Wrong display of authorities records in the Authority search plugin With this patch the display of the authorities records is available at XSLT format Test plan: 1)Make sure to have at least one Authority Type defined 2)Home > Cataloging > New record > tab.7 Field 700$a 3)Click on the Tag editor button 4)Click on Search button and notice the displaying of the results 5)Apply patch and repeat 3) and 4) 6)The results are now displayed at XSLT format https://bugs.koha-community.org/show_bug.cgi?id=30554 --- authorities/auth_finder.pl | 23 +++++++++++++++++++ .../authorities/searchresultlist-auth.tt | 8 ++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index ed6774f599..9630026651 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -135,6 +135,29 @@ if ( $op eq "do_search" ) { $to = ( ( $startfrom + 1 ) * $resultsperpage ); } + my $AuthorityXSLTResultsDisplay = C4::Context->preference('AuthorityXSLTResultsDisplay'); + if ($results && $AuthorityXSLTResultsDisplay) { + 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 = $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; + } + + $result->{html} = $output; + } + } + $template->param( result => $results ) if $results; $template->param( orderby => $orderby, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt index 94db09dfec..1f92e4f201 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt @@ -50,7 +50,13 @@ [% FOREACH resul IN result %] - [% PROCESS authresult summary=resul.summary authid=resul.authid %] + + [% IF resul.html %] + [% resul.html | $raw %] + [% ELSE %] + [% PROCESS authresult summary=resul.summary authid=resul.authid %] + [% END %] + [% resul.summary.label | html %] [% resul.used | html %] times -- 2.17.1