Bug 12539: PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm

This patch removes hardcoded 'prog' from themelanguage on C4/Templates.pm
It adds a new syspref OPACFallback to hold the prefferred fallback
theme for new themes with minimal changes.

This does not brake CCSR if new syspref value is 'prog',
using 'bootstrap' works somehow, but with strange results.

To test:
1) Apply the patch
2) Run updatedatbase.pl
3) CCSR, prog & bootstrap must work as usual
4) Need to test theme/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, ccsr, prog or bootstrap)
5) 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.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
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>
This commit is contained in:
Bernardo Gonzalez Kriegel 2014-07-07 15:30:02 -03:00 committed by Chris Cormack
parent 075e9a64f9
commit 96bfcdcb86
4 changed files with 25 additions and 14 deletions

View File

@ -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);
}

View File

@ -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'),

View File

@ -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)

View File

@ -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