Bug 12237: Remove the "horrible hack" in C4::Templates
authorJulian Maurice <julian.maurice@biblibre.com>
Tue, 13 May 2014 08:21:43 +0000 (10:21 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 3 Jul 2014 13:34:11 +0000 (10:34 -0300)
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.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Templates.pm
C4/XSLT.pm
catalogue/showmarc.pl
opac/opac-showmarc.pl

index 8d13a49..b326f53 100644 (file)
@@ -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)
         }
     }
index 1d09010..bfacc65 100644 (file)
@@ -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/;
     }
 
index 9470019..28d43e4 100755 (executable)
@@ -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";
index 4197450..9b75ae7 100755 (executable)
@@ -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";