@@ -, +, @@ C4/Templates.pm 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 --- C4/Templates.pm | 23 +++++++++------------- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ 4 files changed, 25 insertions(+), 14 deletions(-) --- a/C4/Templates.pm +++ a/C4/Templates.pm @@ -201,13 +201,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); } @@ -248,6 +243,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"; @@ -255,20 +251,19 @@ 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'; + # Get theme + my @themes = ( C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'opacthemes' ) ); + my $fallback = C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'OPACFallback' ); + push @themes, $fallback; # Try to find first theme for the selected language for my $theme (@themes) { if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { - return ($theme, $lang, \@themes) + return ($theme, $lang, \@themes); } } - # Otherwise, return prog theme in English 'en' - return ('prog', 'en', \@themes); + # Otherwise, return fallback theme in English 'en' + return ($fallback, 'en', \@themes); } --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -231,6 +231,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACdidyoumean',NULL,NULL,'Did you mean? configuration for the OPAC. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'), ('OPACDisplay856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding OPACXSLT option must be on','Choice'), ('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','','Define export options available on OPAC detail page.','free'), +('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'), ('OpacFavicon','','','Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'), ('OPACFineNoRenewals','100','','Fine limit above which user cannot renew books via OPAC','Integer'), ('OPACFinesTab','1','','If OFF the patron fines tab in the OPAC is disabled.','YesNo'), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -8589,6 +8589,14 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.17.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES + ('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes')"); + print "Upgrade to $DBversion done (Bug 12539 - PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -6,6 +6,13 @@ OPAC: choices: opac-templates - theme on the OPAC. - + - Use the + - pref: OPACFallback + choices: + bootstrap: bootstrap + prog: prog + - theme as the fallback theme on the OPAC. + - - "The OPAC is located at http://" - pref: OPACBaseURL class: url --