From 3de85f152b85f6136f7f66a09eb3fb102607f5b7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 10 Mar 2016 14:47:36 +0000 Subject: [PATCH] Bug 15263: (follow-up) XSLT display fetches sysprefs for every result processed Set variables ($sysxml, $xslfilename, $lang) if they are not passed to the subroutine. This happens from catalogue/detail.pl, opac/opac-shelves.pl, opac/opac-tags.pl and virtualshelves/shelves.pl. --- C4/Search.pm | 4 ++-- C4/XSLT.pm | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 2088586..31d7cca 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1867,7 +1867,7 @@ sub searchResults { my $xslsyspref = $interface . "XSLTResultsDisplay"; my $xslfile = C4::Context->preference($xslsyspref); my $lang = C4::Languages::getlanguage(); - my ($sysxml) = C4::XSLT::_get_xslt_sysprefs(); + my $sysxml = C4::XSLT::get_xslt_sysprefs(); # loop through all of the records we've retrieved for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) { @@ -2199,7 +2199,7 @@ sub searchResults { # XSLT processing of some stuff # we fetched the sysprefs already before the loop through all retrieved record! if (!$scan && $xslfile) { - $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile); + $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang); # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs } diff --git a/C4/XSLT.pm b/C4/XSLT.pm index eed1d09..7c91908 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -157,7 +157,7 @@ sub _get_best_default_xslt_filename { return $xslfilename; } -sub _get_xslt_sysprefs { +sub get_xslt_sysprefs { my $sysxml = "\n"; foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow DisplayOPACiconsXSLT URLLinkText viewISBD @@ -185,11 +185,14 @@ sub _get_xslt_sysprefs { sub XSLTParse4Display { my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_; - #my $xslfilename = C4::Context->preference($xslsyspref); + + $sysxml ||= C4::Context->preference($xslsyspref); + $xslfilename ||= C4::Context->preference($xslsyspref); + $lang ||= C4::Languages::getlanguage(); + if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { my $htdocs; my $theme; - # my $lang = C4::Languages::getlanguage(); my $xslfile; if ($xslsyspref eq "XSLTDetailsDisplay") { $htdocs = C4::Context->config('intrahtdocs'); @@ -216,7 +219,6 @@ sub XSLTParse4Display { } if ( $xslfilename =~ m/\{langcode\}/ ) { - my $lang = C4::Languages::getlanguage(); $xslfilename =~ s/\{langcode\}/$lang/; } -- 2.7.0