Lines 201-213
sub _get_template_file {
Link Here
|
201 |
my $is_intranet = $interface eq 'intranet'; |
201 |
my $is_intranet = $interface eq 'intranet'; |
202 |
my $htdocs = C4::Context->config($is_intranet ? 'intrahtdocs' : 'opachtdocs'); |
202 |
my $htdocs = C4::Context->config($is_intranet ? 'intrahtdocs' : 'opachtdocs'); |
203 |
my ($theme, $lang, $availablethemes) = themelanguage($htdocs, $tmplbase, $interface, $query); |
203 |
my ($theme, $lang, $availablethemes) = themelanguage($htdocs, $tmplbase, $interface, $query); |
204 |
|
|
|
205 |
# if the template doesn't exist, load the English one as a last resort |
206 |
my $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; |
204 |
my $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; |
207 |
unless (-f $filename) { |
205 |
|
208 |
$lang = 'en'; |
|
|
209 |
$filename = "$htdocs/$theme/$lang/modules/$tmplbase"; |
210 |
} |
211 |
return ($htdocs, $theme, $lang, $filename); |
206 |
return ($htdocs, $theme, $lang, $filename); |
212 |
} |
207 |
} |
213 |
|
208 |
|
Lines 248-253
sub gettemplate {
Link Here
|
248 |
|
243 |
|
249 |
#--------------------------------------------------------------------------------------------------------- |
244 |
#--------------------------------------------------------------------------------------------------------- |
250 |
# FIXME - POD |
245 |
# FIXME - POD |
|
|
246 |
# FIXME - Rewritten to remove hardcoded theme with minimal changes, need to be rethinked |
251 |
sub themelanguage { |
247 |
sub themelanguage { |
252 |
my ($htdocs, $tmpl, $interface, $query) = @_; |
248 |
my ($htdocs, $tmpl, $interface, $query) = @_; |
253 |
($query) or warn "no query in themelanguage"; |
249 |
($query) or warn "no query in themelanguage"; |
Lines 255-274
sub themelanguage {
Link Here
|
255 |
# Select a language based on cookie, syspref available languages & browser |
251 |
# Select a language based on cookie, syspref available languages & browser |
256 |
my $lang = C4::Languages::getlanguage($query); |
252 |
my $lang = C4::Languages::getlanguage($query); |
257 |
|
253 |
|
258 |
# Select theme |
254 |
# Get theme |
259 |
my $is_intranet = $interface eq 'intranet'; |
255 |
my @themes = ( C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'opacthemes' ) ); |
260 |
my @themes = split(" ", C4::Context->preference( |
256 |
my $fallback = C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'OPACFallback' ); |
261 |
$is_intranet ? "template" : "opacthemes" )); |
257 |
push @themes, $fallback; |
262 |
push @themes, 'prog'; |
|
|
263 |
|
258 |
|
264 |
# Try to find first theme for the selected language |
259 |
# Try to find first theme for the selected language |
265 |
for my $theme (@themes) { |
260 |
for my $theme (@themes) { |
266 |
if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { |
261 |
if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { |
267 |
return ($theme, $lang, \@themes) |
262 |
return ($theme, $lang, \@themes); |
268 |
} |
263 |
} |
269 |
} |
264 |
} |
270 |
# Otherwise, return prog theme in English 'en' |
265 |
# Otherwise, return fallback theme in English 'en' |
271 |
return ('prog', 'en', \@themes); |
266 |
return ($fallback, 'en', \@themes); |
272 |
} |
267 |
} |
273 |
|
268 |
|
274 |
|
269 |
|