Merge branch 'opac-tt-poc' of ssh://yeti.esilibrary.com/home/evergreen/evergreen...
authorsenator <lebbeous@esilibrary.com>
Mon, 14 Mar 2011 21:57:04 +0000 (17:57 -0400)
committersenator <lebbeous@esilibrary.com>
Mon, 14 Mar 2011 21:57:04 +0000 (17:57 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/CGIUTF8.pm [deleted file]
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/CGIUTF8.pm [deleted file]
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/CGI_utf8.pm [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/header.tt2

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/CGIUTF8.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/CGIUTF8.pm
deleted file mode 100644 (file)
index baa43eb..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package OpenILS::WWW::CGIUTF8;
-use strict;
-use warnings;
-use base qw(CGI);
-use Encode;
-
-sub param {
-    my ($self, $k) = @_;
-
-    return map { Encode::decode_utf8($_) } CGI::param($k) if wantarray;
-    return Encode::decode_utf8(CGI::param($k));
-}
-
-sub param_bin {
-    my $self = shift;
-
-    return CGI::param(@_);
-}
-
-1;
index 941efa1..ebfbbec 100644 (file)
@@ -13,7 +13,7 @@ use OpenILS::Application::AppUtils;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use OpenILS::Utils::Fieldmapper;
 use DateTime::Format::ISO8601;
-use OpenILS::WWW::CGIUTF8;
+use CGI qw(:all -utf8);
 
 # EGCatLoader sub-modules 
 use OpenILS::WWW::EGCatLoader::Util;
@@ -33,7 +33,7 @@ sub new {
 
     $self->apache($apache);
     $self->ctx($ctx);
-    $self->cgi(new OpenILS::WWW::CGIUTF8);
+    $self->cgi(new CGI);
 
     OpenILS::Utils::CStoreEditor->init; # just in case
     $self->editor(new_editor());
index 6a7f49a..67e419d 100644 (file)
@@ -53,7 +53,7 @@ sub handler {
         DEBUG => $ctx->{debug_template},
         PLUGINS => {
             EGI18N => 'OpenILS::WWW::EGWeb::I18NFilter',
-            CGIUTF8 => 'OpenILS::WWW::EGWeb::CGIUTF8'
+            CGI_utf8 => 'OpenILS::WWW::EGWeb::CGI_utf8'
         }
     });
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/CGIUTF8.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/CGIUTF8.pm
deleted file mode 100644 (file)
index e90d5d9..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package OpenILS::WWW::EGWeb::CGIUTF8;
-
-# This is just a wrapper for TT around the real package,
-# which is OpenILS::WWW::CGIUTF8
-
-use strict;
-use warnings;
-use base 'Template::Plugin';
-use OpenILS::WWW::CGIUTF8;
-
-sub new {
-    my $class   = shift;
-    my $context = shift;
-    new OpenILS::WWW::CGIUTF8(@_);
-}
-
-1;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/CGI_utf8.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/CGI_utf8.pm
new file mode 100644 (file)
index 0000000..0239e1b
--- /dev/null
@@ -0,0 +1,44 @@
+package OpenILS::WWW::EGWeb::CGI_utf8;
+
+# The code in this module is copied from (except for a tiny modification)
+# Template::Plugin::CGI, which is written by:
+#
+# Andy Wardley E<lt>abw@wardley.orgE<gt> L<http://wardley.org/>
+#
+# Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
+#
+# This module is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+
+use strict;
+use warnings;
+use base 'Template::Plugin';
+use CGI qw(:all -utf8);
+
+sub new {
+    my $class   = shift;
+    my $context = shift;
+    new CGI(@_);
+}
+
+# monkeypatch CGI::params() method to Do The Right Thing in TT land
+
+sub CGI::params {
+    my $self = shift;
+    local $" = ', ';
+
+    return $self->{ _TT_PARAMS } ||= do {
+        # must call Vars() in a list context to receive
+        # plain list of key/vals rather than a tied hash
+        my $params = { $self->Vars() };
+
+        # convert any null separated values into lists
+        @$params{ keys %$params } = map { 
+            /\0/ ? [ split /\0/ ] : $_ 
+        } values %$params;
+
+        $params;
+    };
+}
+
+1;
index b09ae69..03dbcf1 100644 (file)
@@ -1,6 +1,6 @@
 [%- USE money = format(l('$%.2f'));
     USE date;
-    USE CGI = CGIUTF8;
+    USE CGI = CGI_utf8;
     USE EGI18N;
     USE POSIX;
     SET DATE_FORMAT = l('%m/%d/%Y');