Bugzilla – Attachment 23140 Details for
Bug 6554
Resolve encoding problems with corrected UTF8 handling in templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[ALT] Bug 6554: Template::output should deal with object
Bug-6554-Templateoutput-should-deal-with-object.patch (text/plain), 4.75 KB, created by
Jonathan Druart
on 2013-11-25 15:46:20 UTC
(
hide
)
Description:
[ALT] Bug 6554: Template::output should deal with object
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-11-25 15:46:20 UTC
Size:
4.75 KB
patch
obsolete
>From 7758e9b775941240d8bf6ac88addde9bdb8623a2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 25 Nov 2013 16:39:09 +0100 >Subject: [PATCH] Bug 6554: Template::output should deal with object > >if a ref is not HASH or ARRAY, C4::Template::output assumes it is a >scalar. Which is wrong, it could be an object. >--- > C4/Templates.pm | 63 +++++++++----------- > .../prog/en/includes/patron-toolbar.inc | 2 +- > 2 files changed, 29 insertions(+), 36 deletions(-) > >diff --git a/C4/Templates.pm b/C4/Templates.pm >index 2d2304f..6996a1a 100644 >--- a/C4/Templates.pm >+++ b/C4/Templates.pm >@@ -34,6 +34,7 @@ use Template; > use Template::Constants qw( :debug ); > use C4::Languages qw(getTranslatedLanguages get_bidi regex_lang_subtags language_get_description accept_language ); > >+use Encode; > use C4::Context; > > __PACKAGE__->mk_accessors(qw( theme activethemes preferredtheme lang filename htdocs interface vars)); >@@ -117,15 +118,7 @@ sub output { > # 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}); >- } >+ utf8_struct( $vars->{$k} ); > } > my $data; > # binmode( STDOUT, ":utf8" ); >@@ -134,37 +127,37 @@ sub output { > return $data; > } > >-sub utf8_arrayref { >- my $arrayref = shift; >- foreach my $element (@$arrayref){ >- if (ref($element) eq 'ARRAY'){ >- utf8_arrayref($element); >- next; >+sub utf8_struct { >+ my $element = shift; >+ my $ref = ref $element; >+ if ( $ref and $ref eq 'ARRAY' ) { >+ foreach my $elt ( @$element ) { >+ $elt = utf8_struct( $elt ); > } >- if (ref($element) eq 'HASH'){ >- utf8_hashref($element); >- next; >+ return $element; >+ } elsif ( $ref and $ref eq 'HASH' ) { >+ while ( my ($k, $val) = each %{$element} ) { >+ $element->{$k} = utf8_struct( $val ); > } >- 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; >+ return $element; >+ } else { >+ if ( not ref ( $element ) or not UNIVERSAL::can($element, 'can') ) { >+ return Encode::is_utf8($element) >+ ? Encode::encode_utf8($element) >+ : $element; >+ } else { >+ # FIXME It is not the best to create a whitelist or a blacklist here... >+ return $element if ref($element) =~ /^Date/; >+ return $element if ref($element) =~ /^Koha::Schema/; >+ while ( my ( $member, $value ) = each %$element ) { >+ $value = utf8_struct( $value ); >+ $element->{$member} = $value; >+ } >+ return $element; > } >- 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 >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc >index 8d36da3..c8ff82d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc >@@ -4,7 +4,7 @@ > <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-plus"></i> New patron <span class="caret"></span></button> > <ul class="dropdown-menu"> > [% IF ( AddPatronLists_categorycode ) %] >- [% FOREACH categorie IN categories %]<li><a href="/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=[% categorie.categorycode %]">[% categorie.description | html_entity %]</a></li>[% END %] >+ [% FOREACH categorie IN categories %]<li><a href="/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=[% categorie.categorycode %]">[% categorie.description %]</a></li>[% END %] > [% ELSE %] > <li><a href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=A">Adult patron</a></li> > <li><a href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=C">Child patron</a></li> >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6554
:
4558
|
4560
|
4561
|
4562
|
4563
|
4564
|
5962
|
6041
|
6065
|
6070
|
6071
|
6072
|
6073
|
6076
|
6077
|
6078
|
6079
|
6080
|
6083
|
6084
|
6085
|
6108
|
10118
|
16780
|
16797
|
16857
|
16905
|
16929
|
16930
|
16931
|
16932
|
16960
|
16961
|
16962
|
16963
|
16964
|
16966
|
16968
|
16969
|
16984
|
16985
|
16986
|
16987
|
16988
|
16989
|
17179
|
17186
|
17187
|
17327
|
17328
|
18746
|
18747
|
18749
|
18750
|
21318
|
21399
|
21478
|
21488
|
21506
|
21509
|
21581
|
21629
|
21631
|
21632
|
21682
|
21937
|
21955
|
21978
|
21980
|
21981
|
23107
|
23140