From cbd681a20c7dea4c3b5d39638eda1351d720fb5f Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Mon, 7 Jul 2014 15:30:02 -0300 Subject: [PATCH] Bug 12539: PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm This patch removes hardcoded 'prog' from themelanguage on C4/Templates.pm Now that function only provides a fallback to 'en' on active theme (opac & intranet) Also removes a test already done on themelanguage This also breaks definitely CCSR To test: 1) Apply the patch 2) CCSR is now broken, prog & bootstrap must work as usual 3) Need to test language fallback a) translate for your preferred language (xx-YY) b) enable language on opac c) go to opac, select that language d) login on opac, go to personal details e) remove koha-tmpl/opac-tmpl/bootstrap/xx-YY/modules/opac-memberentry.tt d) reload page, must load in English f) click other member options, must load on translated language (can use other pages, prog or bootstrap) 4) Do a similar test but for a staff page, enable lang, switch to it, rm koha-tmpl/intranet-tmpl/prog/xx-YY/modules/admin/admin-home.tt, any page must be translated except for admin home. --- C4/Templates.pm | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index b326f53..5d31f96 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -202,13 +202,8 @@ sub _get_template_file { my $is_intranet = $interface eq 'intranet'; my $htdocs = C4::Context->config($is_intranet ? 'intrahtdocs' : 'opachtdocs'); my ($theme, $lang, $availablethemes) = themelanguage($htdocs, $tmplbase, $interface, $query); - - # if the template doesn't exist, load the English one as a last resort my $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; - unless (-f $filename) { - $lang = 'en'; - $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; - } + return ($htdocs, $theme, $lang, $filename); } @@ -266,6 +261,7 @@ sub gettemplate { #--------------------------------------------------------------------------------------------------------- # FIXME - POD +# FIXME - Rewritten to remove hardcoded theme with minimal changes, need to be rethinked sub themelanguage { my ($htdocs, $tmpl, $interface, $query) = @_; ($query) or warn "no query in themelanguage"; @@ -273,20 +269,17 @@ sub themelanguage { # Select a language based on cookie, syspref available languages & browser my $lang = C4::Languages::getlanguage($query); - # Select theme - my $is_intranet = $interface eq 'intranet'; - my @themes = split(" ", C4::Context->preference( - $is_intranet ? "template" : "opacthemes" )); - push @themes, 'prog'; - - # Try to find first theme for the selected language - for my $theme (@themes) { - if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { - return ($theme, $lang, \@themes) - } + # Get theme + my $theme = C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'opacthemes' ); + my @themes = ($theme); + + # Return theme for selected language, otherwise return same theme for English 'en' + if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { + return ($theme, $lang, \@themes); + } + else { + return ($theme, 'en', \@themes); } - # Otherwise, return prog theme in English 'en' - return ('prog', 'en', \@themes); } -- 1.7.9.5