Lines 67-72
sub new {
Link Here
|
67 |
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'):'',, |
68 |
INCLUDE_PATH => \@includes, |
68 |
INCLUDE_PATH => \@includes, |
69 |
FILTERS => {}, |
69 |
FILTERS => {}, |
|
|
70 |
ENCODING => 'utf8', |
70 |
} |
71 |
} |
71 |
) or die Template->error(); |
72 |
) or die Template->error(); |
72 |
my $self = { |
73 |
my $self = { |
Lines 90-96
sub output {
Link Here
|
90 |
my $self = shift; |
91 |
my $self = shift; |
91 |
my $vars = shift; |
92 |
my $vars = shift; |
92 |
|
93 |
|
93 |
# my $file = $self->htdocs . '/' . $self->theme .'/'.$self->lang.'/'.$self->filename; |
|
|
94 |
my $template = $self->{TEMPLATE}; |
94 |
my $template = $self->{TEMPLATE}; |
95 |
if ( $self->interface eq 'intranet' ) { |
95 |
if ( $self->interface eq 'intranet' ) { |
96 |
$vars->{themelang} = '/intranet-tmpl'; |
96 |
$vars->{themelang} = '/intranet-tmpl'; |
Lines 114-169
sub output {
Link Here
|
114 |
C4::Context->preference('opaclayoutstylesheet'); |
114 |
C4::Context->preference('opaclayoutstylesheet'); |
115 |
|
115 |
|
116 |
# add variables set via param to $vars for processing |
116 |
# add variables set via param to $vars for processing |
117 |
# and clean any utf8 mess |
|
|
118 |
for my $k ( keys %{ $self->{VARS} } ) { |
117 |
for my $k ( keys %{ $self->{VARS} } ) { |
119 |
$vars->{$k} = $self->{VARS}->{$k}; |
118 |
$vars->{$k} = $self->{VARS}->{$k}; |
120 |
if (ref($vars->{$k}) eq 'ARRAY'){ |
|
|
121 |
utf8_arrayref($vars->{$k}); |
122 |
} |
123 |
elsif (ref($vars->{$k}) eq 'HASH'){ |
124 |
utf8_hashref($vars->{$k}); |
125 |
} |
126 |
else { |
127 |
utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k}); |
128 |
} |
129 |
} |
119 |
} |
130 |
my $data; |
120 |
my $data; |
131 |
# binmode( STDOUT, ":utf8" ); |
|
|
132 |
$template->process( $self->filename, $vars, \$data ) |
121 |
$template->process( $self->filename, $vars, \$data ) |
133 |
|| die "Template process failed: ", $template->error(); |
122 |
|| die "Template process failed: ", $template->error(); |
|
|
123 |
utf8::encode($data) if utf8::is_utf8($data); |
134 |
return $data; |
124 |
return $data; |
135 |
} |
125 |
} |
136 |
|
|
|
137 |
sub utf8_arrayref { |
138 |
my $arrayref = shift; |
139 |
foreach my $element (@$arrayref){ |
140 |
if (ref($element) eq 'ARRAY'){ |
141 |
utf8_arrayref($element); |
142 |
next; |
143 |
} |
144 |
if (ref($element) eq 'HASH'){ |
145 |
utf8_hashref($element); |
146 |
next; |
147 |
} |
148 |
utf8::encode($element) if utf8::is_utf8($element); |
149 |
} |
150 |
} |
151 |
|
152 |
sub utf8_hashref { |
153 |
my $hashref = shift; |
154 |
for my $key (keys %{$hashref}){ |
155 |
if (ref($hashref->{$key}) eq 'ARRAY'){ |
156 |
utf8_arrayref($hashref->{$key}); |
157 |
next; |
158 |
} |
159 |
if (ref($hashref->{$key}) eq 'HASH'){ |
160 |
utf8_hashref($hashref->{$key}); |
161 |
next; |
162 |
} |
163 |
utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); |
164 |
} |
165 |
} |
166 |
|
167 |
|
126 |
|
168 |
# FIXME - this is a horrible hack to cache |
127 |
# FIXME - this is a horrible hack to cache |
169 |
# the current known-good language, temporarily |
128 |
# the current known-good language, temporarily |
170 |
- |
|
|