]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/CGI_utf8.pm
Merge branch 'master' of git.evergreen-ils.org:Evergreen into template-toolkit-opac
[Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / WWW / EGWeb / CGI_utf8.pm
1 package OpenILS::WWW::EGWeb::CGI_utf8;
2
3 # The code in this module is copied from (except for a tiny modification)
4 # Template::Plugin::CGI, which is written by:
5 #
6 # Andy Wardley E<lt>abw@wardley.orgE<gt> L<http://wardley.org/>
7 #
8 # Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
9 #
10 # This module is free software; you can redistribute it and/or
11 # modify it under the same terms as Perl itself.
12
13 use strict;
14 use warnings;
15 use base 'Template::Plugin';
16 use CGI qw(:all -utf8);
17
18 sub new {
19     my $class   = shift;
20     my $context = shift;
21     new CGI(@_);
22 }
23
24 # monkeypatch CGI::params() method to Do The Right Thing in TT land
25
26 sub CGI::params {
27     my $self = shift;
28     local $" = ', ';
29
30     return $self->{ _TT_PARAMS } ||= do {
31         # must call Vars() in a list context to receive
32         # plain list of key/vals rather than a tied hash
33         my $params = { $self->Vars() };
34
35         # convert any null separated values into lists
36         @$params{ keys %$params } = map { 
37             /\0/ ? [ split /\0/ ] : $_ 
38         } values %$params;
39
40         $params;
41     };
42 }
43
44 1;