Bug 12539: Follow up to fix fallback theme
authorBernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Sun, 3 Aug 2014 12:41:37 +0000 (09:41 -0300)
committerChris Cormack <chrisc@catalyst.net.nz>
Wed, 29 Oct 2014 20:35:12 +0000 (09:35 +1300)
The is a problem in the logic, fallback must be:
1. Requested (theme, lang, tmpl)
a. return    (theme, lang, tmpl), if not
b. return    (fallback, lang, tmpl), if not
c. return    (theme, 'en', tmpl), if not as last resort
d. return    (fallback, 'en', tmpl)

Previous patch missed option 'c', worked for CCSR
but not bootstrap, sorry.

Signed-off-by: Petter Goksoyr Asen <boutrosboutrosboutros@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

C4/Templates.pm

index 2c57718..879249a 100644 (file)
@@ -256,14 +256,18 @@ sub themelanguage {
     my $fallback =   C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'OPACFallback' );
     push @themes, $fallback;
 
-    # Try to find first theme for the selected language
+    # Try to find first theme for the selected theme/lang, then for fallback/lang
     for my $theme (@themes) {
         if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) {
             return ($theme, $lang, \@themes);
         }
     }
-    # Otherwise, return fallback theme in English 'en'
-    return ($fallback, 'en', \@themes);
+    # Otherwise return theme/'en', last resort fallback/'en'
+    for my $theme (@themes) {
+        if ( -e "$htdocs/$theme/en/modules/$tmpl" ) {
+            return ($theme, 'en', \@themes);
+        }
+    }
 }