View | Details | Raw Unified | Return to bug 11944
Collapse All | Expand All

(-)a/C4/Templates.pm (-42 / +1 lines)
Lines 115-133 sub output { Link Here
115
        C4::Context->preference('opaclayoutstylesheet');
115
        C4::Context->preference('opaclayoutstylesheet');
116
116
117
    # add variables set via param to $vars for processing
117
    # add variables set via param to $vars for processing
118
    # and clean any utf8 mess
119
    for my $k ( keys %{ $self->{VARS} } ) {
118
    for my $k ( keys %{ $self->{VARS} } ) {
120
        $vars->{$k} = $self->{VARS}->{$k};
119
        $vars->{$k} = $self->{VARS}->{$k};
121
        if (ref($vars->{$k}) eq 'ARRAY'){
122
            utf8_arrayref($vars->{$k});
123
        }
124
        elsif (ref($vars->{$k}) eq 'HASH'){
125
            utf8_hashref($vars->{$k});
126
        }
127
        else {
128
            utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k});
129
        }
130
    }
120
    }
121
131
    my $data;
122
    my $data;
132
    binmode( STDOUT, ":utf8" );
123
    binmode( STDOUT, ":utf8" );
133
    $template->process( $self->filename, $vars, \$data )
124
    $template->process( $self->filename, $vars, \$data )
Lines 135-171 sub output { Link Here
135
    return $data;
126
    return $data;
136
}
127
}
137
128
138
sub utf8_arrayref {
139
    my $arrayref = shift;
140
    foreach my $element (@$arrayref){
141
        if (ref($element) eq 'ARRAY'){
142
            utf8_arrayref($element);
143
            next;
144
        }
145
        if (ref($element) eq 'HASH'){
146
            utf8_hashref($element);
147
            next;
148
        }
149
        utf8::encode($element) if utf8::is_utf8($element);
150
    }        
151
}         
152
153
sub utf8_hashref {
154
    my $hashref = shift;
155
    for my $key (keys %{$hashref}){
156
        if (ref($hashref->{$key}) eq 'ARRAY'){
157
            utf8_arrayref($hashref->{$key});
158
            next;
159
        }
160
        if (ref($hashref->{$key}) eq 'HASH'){
161
            utf8_hashref($hashref->{$key});
162
            next;
163
        }
164
        utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key});
165
    }
166
}
167
        
168
        
169
# FIXME - this is a horrible hack to cache
129
# FIXME - this is a horrible hack to cache
170
# the current known-good language, temporarily
130
# the current known-good language, temporarily
171
# put in place to resolve bug 4403.  It is
131
# put in place to resolve bug 4403.  It is
172
- 

Return to bug 11944