X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;ds=sidebyside;f=C4%2FTemplates.pm;h=7f50143279383b0d4d612fb624f4c6e2240ec4ca;hb=35f9a375597cfe730e1eaaf2fe49ee12d904bd85;hp=88b9b01687ad18a55204eea1099dce6a52639eb5;hpb=5eabc672fd818b312b3dbc8e2c19defcca97ed13;p=koha_fer diff --git a/C4/Templates.pm b/C4/Templates.pm index 88b9b01687..7f50143279 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -67,6 +67,7 @@ sub new { COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',, INCLUDE_PATH => \@includes, FILTERS => {}, + ENCODING => 'utf8', # templates don't have BOM, see Template::FAQ } ) or die Template->error(); my $self = { @@ -114,57 +115,16 @@ sub output { C4::Context->preference('opaclayoutstylesheet'); # add variables set via param to $vars for processing - # and clean any utf8 mess for my $k ( keys %{ $self->{VARS} } ) { $vars->{$k} = $self->{VARS}->{$k}; - if (ref($vars->{$k}) eq 'ARRAY'){ - utf8_arrayref($vars->{$k}); - } - elsif (ref($vars->{$k}) eq 'HASH'){ - utf8_hashref($vars->{$k}); - } - else { - utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k}); - } } my $data; -# binmode( STDOUT, ":utf8" ); $template->process( $self->filename, $vars, \$data ) || die "Template process failed: ", $template->error(); return $data; } -sub utf8_arrayref { - my $arrayref = shift; - foreach my $element (@$arrayref){ - if (ref($element) eq 'ARRAY'){ - utf8_arrayref($element); - next; - } - if (ref($element) eq 'HASH'){ - utf8_hashref($element); - next; - } - utf8::encode($element) if utf8::is_utf8($element); - } -} - -sub utf8_hashref { - my $hashref = shift; - for my $key (keys %{$hashref}){ - if (ref($hashref->{$key}) eq 'ARRAY'){ - utf8_arrayref($hashref->{$key}); - next; - } - if (ref($hashref->{$key}) eq 'HASH'){ - utf8_hashref($hashref->{$key}); - next; - } - utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); - } -} - - + # FIXME - this is a horrible hack to cache # the current known-good language, temporarily # put in place to resolve bug 4403. It is