Lines 36-42
use C4::Languages qw(getTranslatedLanguages get_bidi regex_lang_subtags language
Link Here
|
36 |
|
36 |
|
37 |
use C4::Context; |
37 |
use C4::Context; |
38 |
|
38 |
|
39 |
__PACKAGE__->mk_accessors(qw( theme lang filename htdocs interface vars)); |
39 |
__PACKAGE__->mk_accessors(qw( theme activethemes preferredtheme lang filename htdocs interface vars)); |
40 |
|
40 |
|
41 |
|
41 |
|
42 |
|
42 |
|
Lines 53-69
sub new {
Link Here
|
53 |
else { |
53 |
else { |
54 |
$htdocs = C4::Context->config('intrahtdocs'); |
54 |
$htdocs = C4::Context->config('intrahtdocs'); |
55 |
} |
55 |
} |
56 |
my ($theme, $lang)= themelanguage( $htdocs, $tmplbase, $interface, $query); |
56 |
my ($theme, $lang, $activethemes)= themelanguage( $htdocs, $tmplbase, $interface, $query); |
|
|
57 |
my @includes; |
58 |
foreach (@$activethemes) { |
59 |
push @includes, "$htdocs/$_/$lang/includes"; |
60 |
push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en'; |
61 |
} |
57 |
my $template = Template->new( |
62 |
my $template = Template->new( |
58 |
{ EVAL_PERL => 1, |
63 |
{ EVAL_PERL => 1, |
59 |
ABSOLUTE => 1, |
64 |
ABSOLUTE => 1, |
60 |
PLUGIN_BASE => 'Koha::Template::Plugin', |
65 |
PLUGIN_BASE => 'Koha::Template::Plugin', |
61 |
COMPILE_EXT => C4::Context->config('template_cache_dir')?'.ttc':'', |
66 |
COMPILE_EXT => C4::Context->config('template_cache_dir')?'.ttc':'', |
62 |
COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',, |
67 |
COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',, |
63 |
INCLUDE_PATH => [ |
68 |
INCLUDE_PATH => \@includes, |
64 |
"$htdocs/$theme/$lang/includes", |
|
|
65 |
"$htdocs/$theme/en/includes" |
66 |
], |
67 |
FILTERS => {}, |
69 |
FILTERS => {}, |
68 |
} |
70 |
} |
69 |
) or die Template->error(); |
71 |
) or die Template->error(); |
Lines 74-79
sub new {
Link Here
|
74 |
bless $self, $class; |
76 |
bless $self, $class; |
75 |
$self->theme($theme); |
77 |
$self->theme($theme); |
76 |
$self->lang($lang); |
78 |
$self->lang($lang); |
|
|
79 |
$self->activethemes($activethemes); |
80 |
$self->preferredtheme($activethemes->[0]); |
77 |
$self->filename($filename); |
81 |
$self->filename($filename); |
78 |
$self->htdocs($htdocs); |
82 |
$self->htdocs($htdocs); |
79 |
$self->interface($interface); |
83 |
$self->interface($interface); |
Lines 95-101
sub output {
Link Here
|
95 |
$vars->{themelang} = '/opac-tmpl'; |
99 |
$vars->{themelang} = '/opac-tmpl'; |
96 |
} |
100 |
} |
97 |
$vars->{lang} = $self->lang; |
101 |
$vars->{lang} = $self->lang; |
98 |
$vars->{themelang} .= '/' . $self->theme . '/' . $self->lang; |
102 |
$vars->{themelang} .= '/' . $self->preferredtheme . '/' . $self->lang; |
99 |
$vars->{yuipath} = |
103 |
$vars->{yuipath} = |
100 |
( C4::Context->preference("yuipath") eq "local" |
104 |
( C4::Context->preference("yuipath") eq "local" |
101 |
? $vars->{themelang} . "/lib/yui" |
105 |
? $vars->{themelang} . "/lib/yui" |
Lines 211-217
sub _get_template_file {
Link Here
|
211 |
|
215 |
|
212 |
my $is_intranet = $interface eq 'intranet'; |
216 |
my $is_intranet = $interface eq 'intranet'; |
213 |
my $htdocs = C4::Context->config($is_intranet ? 'intrahtdocs' : 'opachtdocs'); |
217 |
my $htdocs = C4::Context->config($is_intranet ? 'intrahtdocs' : 'opachtdocs'); |
214 |
my ($theme, $lang) = themelanguage($htdocs, $tmplbase, $interface, $query); |
218 |
my ($theme, $lang, $availablethemes) = themelanguage($htdocs, $tmplbase, $interface, $query); |
215 |
|
219 |
|
216 |
# if the template doesn't exist, load the English one as a last resort |
220 |
# if the template doesn't exist, load the English one as a last resort |
217 |
my $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; |
221 |
my $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; |
Lines 231-249
sub gettemplate {
Link Here
|
231 |
my ($htdocs, $theme, $lang, $filename) |
235 |
my ($htdocs, $theme, $lang, $filename) |
232 |
= _get_template_file($tmplbase, $interface, $query); |
236 |
= _get_template_file($tmplbase, $interface, $query); |
233 |
my $template = C4::Templates->new($interface, $filename, $tmplbase, $query); |
237 |
my $template = C4::Templates->new($interface, $filename, $tmplbase, $query); |
234 |
my $is_intranet = $interface eq 'intranet'; |
238 |
# NOTE: Commenting these out rather than deleting them so that those who need |
235 |
my $themelang = |
239 |
# to know how we previously shimmed these directories will be able to understand. |
236 |
($is_intranet ? '/intranet-tmpl' : '/opac-tmpl') . |
240 |
# my $is_intranet = $interface eq 'intranet'; |
237 |
"/$theme/$lang"; |
241 |
# my $themelang = |
238 |
$template->param( |
242 |
# ($is_intranet ? '/intranet-tmpl' : '/opac-tmpl') . |
239 |
themelang => $themelang, |
243 |
# "/$theme/$lang"; |
240 |
yuipath => C4::Context->preference("yuipath") eq "local" |
244 |
# $template->param( |
241 |
? "$themelang/lib/yui" |
245 |
# themelang => $themelang, |
242 |
: C4::Context->preference("yuipath"), |
246 |
# yuipath => C4::Context->preference("yuipath") eq "local" |
243 |
interface => $is_intranet ? '/intranet-tmpl' : '/opac-tmpl', |
247 |
# ? "$themelang/lib/yui" |
244 |
theme => $theme, |
248 |
# : C4::Context->preference("yuipath"), |
245 |
lang => $lang |
249 |
# interface => $is_intranet ? '/intranet-tmpl' : '/opac-tmpl', |
246 |
); |
250 |
# theme => $theme, |
|
|
251 |
# lang => $lang |
252 |
# ); |
247 |
|
253 |
|
248 |
# Bidirectionality |
254 |
# Bidirectionality |
249 |
my $current_lang = regex_lang_subtags($lang); |
255 |
my $current_lang = regex_lang_subtags($lang); |
Lines 286-296
sub themelanguage {
Link Here
|
286 |
for my $theme (@themes) { |
292 |
for my $theme (@themes) { |
287 |
if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { |
293 |
if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { |
288 |
$_current_language = $lang; |
294 |
$_current_language = $lang; |
289 |
return ($theme, $lang) |
295 |
return ($theme, $lang, \@themes) |
290 |
} |
296 |
} |
291 |
} |
297 |
} |
292 |
# Otherwise, return prog theme in English 'en' |
298 |
# Otherwise, return prog theme in English 'en' |
293 |
return ('prog', 'en'); |
299 |
return ('prog', 'en', \@themes); |
294 |
} |
300 |
} |
295 |
|
301 |
|
296 |
|
302 |
|