diff --git a/C4/Templates.pm b/C4/Templates.pm index 6a9d48b345..2c5771820c 100644 --- a/C4/Templates.pm +++ b/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); } diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 84a2065ab4..b4835840d5 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -236,6 +236,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'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 20b7c93e15..3739f38cd3 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8911,6 +8911,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) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index bd7b59fca2..6b25a0134b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -5,6 +5,13 @@ OPAC: - pref: opacthemes 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