From 7c43f3a846c21ed3329b5ba08029ca95e3f041f7 Mon Sep 17 00:00:00 2001
From: Julian Maurice <julian.maurice@biblibre.com>
Date: Tue, 13 May 2014 10:21:43 +0200
Subject: [PATCH] [PASSED QA] Bug 12237: Remove the "horrible hack" in
C4::Templates
Use C4::Languages::getlanguage() instead of
C4::Templates::_current_language()
Test plan:
1/ Set one of the 4 XSLT sysprefs to 'default'
2/ Go to the corresponding page
3/ Switch language and check that the right XSLT is used
4/ Set the same syspref to something with '{langcode}' in it. For
example:
"../koha-tmpl/opac-tmpl/bootstrap/{langcode}/xslt/UNIMARCslim2OPACDetail.xsl"
5/ Go back to the corresponding page
6/ Switch language and check that the right XSLT is used
7/ Change a compact.xsl for a language (for example
koha-tmpl/intranet-tmpl/prog/fr-FR/xslt/compact.xsl) to be able to see
differences
8/ Go to a biblio detail page in staff interface and click on "MARC
Preview: Show"
9/ Close the popup, switch language and click again on the same link
10/ Check that the correct XSLT is used.
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Works as described following test plan.
No koha-qa errors
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
No problems found, passes tests and QA script.
---
C4/Templates.pm | 15 ---------------
C4/XSLT.pm | 4 ++--
catalogue/showmarc.pl | 2 +-
opac/opac-showmarc.pl | 2 +-
4 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/C4/Templates.pm b/C4/Templates.pm
index 8d13a49..b326f53 100644
--- a/C4/Templates.pm
+++ b/C4/Templates.pm
@@ -163,20 +163,6 @@ sub utf8_hashref {
utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key});
}
}
-
-
-# FIXME - this is a horrible hack to cache
-# the current known-good language, temporarily
-# put in place to resolve bug 4403. It is
-# used only by C4::XSLT::XSLTParse4Display;
-# the language is set via the usual call
-# to themelanguage.
-my $_current_language = 'en';
-
-sub _current_language {
- return $_current_language;
-}
-
# wrapper method to allow easier transition from HTML template pro to Template Toolkit
sub param {
@@ -296,7 +282,6 @@ sub themelanguage {
# Try to find first theme for the selected language
for my $theme (@themes) {
if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) {
- $_current_language = $lang;
return ($theme, $lang, \@themes)
}
}
diff --git a/C4/XSLT.pm b/C4/XSLT.pm
index 1d09010..bfacc65 100644
--- a/C4/XSLT.pm
+++ b/C4/XSLT.pm
@@ -162,7 +162,7 @@ sub XSLTParse4Display {
if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
my $htdocs;
my $theme;
- my $lang = C4::Templates::_current_language();
+ my $lang = C4::Languages::getlanguage();
my $xslfile;
if ($xslsyspref eq "XSLTDetailsDisplay") {
$htdocs = C4::Context->config('intrahtdocs');
@@ -189,7 +189,7 @@ sub XSLTParse4Display {
}
if ( $xslfilename =~ m/\{langcode\}/ ) {
- my $lang = C4::Templates::_current_language();
+ my $lang = C4::Languages::getlanguage();
$xslfilename =~ s/\{langcode\}/$lang/;
}
diff --git a/catalogue/showmarc.pl b/catalogue/showmarc.pl
index 9470019..28d43e4 100755
--- a/catalogue/showmarc.pl
+++ b/catalogue/showmarc.pl
@@ -55,7 +55,7 @@ if(!ref $record) {
}
if($view eq 'card') {
- my $themelang = '/' . C4::Templates::_current_language();
+ my $themelang = '/' . C4::Languages::getlanguage($input);
my $xmlrecord= $importid? $record->as_xml(): GetXmlBiblio($biblionumber);
my $xslfile =
C4::Context->config('intrahtdocs') . '/prog' . $themelang . "/xslt/compact.xsl";
diff --git a/opac/opac-showmarc.pl b/opac/opac-showmarc.pl
index 4197450..9b75ae7 100755
--- a/opac/opac-showmarc.pl
+++ b/opac/opac-showmarc.pl
@@ -57,7 +57,7 @@ if ($view eq 'card' || $view eq 'html') {
my $xslfilename;
my $htdocs = C4::Context->config('opachtdocs');
my $theme = C4::Context->preference("opacthemes");
- my $lang = C4::Templates::_current_language();
+ my $lang = C4::Languages::getlanguage($input);
if ($view eq 'card'){
$xslfile = "compact.xsl";
--
1.9.1