From: berick Date: Thu, 10 Feb 2011 16:56:59 +0000 (-0500) Subject: added i18n filter support for translating text blocks via filters; more login form... X-Git-Tag: opac-tt-poc-demo2~27^2~23 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2b9beb11b25603682e134af840af23fe24233005;p=evergreen%2Fequinox.git added i18n filter support for translating text blocks via filters; more login form cleanup; moved some global USE's into topnav --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index fb7291302a..3a62f4ff10 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -82,7 +82,7 @@ sub load { # ---------------------------------------------------------------- unless($self->cgi->https and $self->editor->requestor) { # If a secure resource is requested insecurely, redirect to the login page - my $url = 'https://' . $self->apache->hostname . $self->ctx->{base_path} . "/opac/login"; + my $url = 'https://' . $self->apache->hostname . $self->ctx->{opac_root} . "/login"; $self->apache->print($self->cgi->redirect(-url => $url)); return Apache2::Const::REDIRECT; } @@ -198,6 +198,7 @@ sub load_helpers { ); }; + # retrieve and cache org unit setting values $ctx->{get_org_setting} = sub { my($org_id, $setting) = @_; $cache{org_settings}{$org_id} = {} unless $cache{org_settings}{$org_id}; @@ -218,6 +219,8 @@ sub load_common { my $ctx = $self->ctx; $ctx->{referer} = $self->cgi->referer; + $ctx->{path_info} = $self->cgi->path_info; + $ctx->{opac_root} = $ctx->{base_path} . "/opac"; # absolute base url $ctx->{is_staff} = ($self->apache->headers_in->get('User-Agent') =~ 'oils_xulrunner'); if($e->authtoken($self->cgi->cookie('ses'))) { @@ -259,7 +262,7 @@ sub load_login { my $org_unit = $cgi->param('loc') || $ctx->{aou_tree}->()->id; my $persist = $cgi->param('persist'); - # initial log form loading + # initial log form only return Apache2::Const::OK unless $username and $password; my $seed = $U->simplereq( @@ -310,7 +313,7 @@ sub load_login { sub load_logout { my $self = shift; - my $url = 'http://' . $self->apache->hostname . $self->ctx->{base_path} . "/opac/home"; + my $url = 'http://' . $self->apache->hostname . $self->ctx->{opac_root} . "/home"; $self->apache->print( $self->cgi->redirect( diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index 807af477d7..63836f8f2f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -50,7 +50,8 @@ sub handler { my $tt = Template->new({ OUTPUT => ($as_xml) ? sub { parse_as_xml($r, $ctx, @_); } : $r, INCLUDE_PATH => $ctx->{template_paths}, - DEBUG => $ctx->{debug_template} + DEBUG => $ctx->{debug_template}, + PLUGINS => {EGI18N => 'OpenILS::WWW::EGWeb::I18NFilter'} }); unless($tt->process($template, {ctx => $ctx, l => set_text_handler($ctx, $r)})) { @@ -75,7 +76,8 @@ sub set_text_handler { $lh_cache{$locale} = $lh_cache{'en_US'}; } - return sub { return $lh_cache{$locale}->maketext(@_); }; + return $OpenILS::WWW::EGWeb::I18NFilter::maketext = + sub { return $lh_cache{$locale}->maketext(@_); }; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/I18NFilter.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/I18NFilter.pm new file mode 100644 index 0000000000..cc931fa59f --- /dev/null +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb/I18NFilter.pm @@ -0,0 +1,19 @@ +package OpenILS::WWW::EGWeb::I18NFilter; +use Template::Plugin::Filter; +use base qw(Template::Plugin::Filter); +our $DYNAMIC = 1; +our $maketext; + +sub filter { + my ($self, $text, $args) = @_; + return $maketext->($text, @$args); +} + +sub init { + my $self = shift; + $self->install_filter('l'); + return $self; +} + +1; + diff --git a/Open-ILS/web/templates/default/opac/login.tt2 b/Open-ILS/web/templates/default/opac/login.tt2 index 3b2e39285d..24522815d7 100644 --- a/Open-ILS/web/templates/default/opac/login.tt2 +++ b/Open-ILS/web/templates/default/opac/login.tt2 @@ -1,3 +1,4 @@ +[% USE CGI %] [% WRAPPER "default/opac/parts/base.tt2"; INCLUDE "default/opac/parts/topnav.tt2"; ctx.page_title = "Account Login" %] diff --git a/Open-ILS/web/templates/default/opac/parts/login/form.tt2 b/Open-ILS/web/templates/default/opac/parts/login/form.tt2 index 939cd1774b..38a6a2d0e6 100644 --- a/Open-ILS/web/templates/default/opac/parts/login/form.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/login/form.tt2 @@ -1,6 +1,5 @@ - - - -[% IF ctx.login_failed_event; +[% IF ctx.login_failed_event %] +
+[% IF ctx.login_failed_event.textcode == 'PATRON_CARD_INACTIVE'; l("The barcode used to login is marked as inactive. Please contact your local library."); ELSIF ctx.login_failed_event.textcode == 'PATRON_INACTIVE'; l("This account has been deactivated. Please contact your local library."); ELSE; - l("Login failed. The username or password provided was not valid. Ensure Caps-Lock is off and try again or contact your local library."); + l("Login failed. The username or password provided was not valid. + Ensure Caps-Lock is off and try again or contact your local library."); END; -END %] - +%] +
+[% END %]
@@ -84,8 +86,8 @@ END %] width="100%"> -

Log in to Your Account

- Please enter the following information: +

[% l('Log in to Your Account') %]

+ [% l('Please enter the following information:') %]

@@ -115,7 +117,9 @@ END %] [% l('PIN Number or Password') %]
- [% l('If this is your first time logging in, please enter [_1] the last 4 digits of your phone number. [_2] Example: 0926', '
', '
') %] + [% | l('
', '
') %] + If this is your first time logging in, please enter [_1] the last 4 digits of your phone number. [_2] Example: 0926 + [% END %]
@@ -123,13 +127,20 @@ END %]
- + [% + # If no redirect is offered or it's leading us back to the + # login form, redirect the user to My Account + redirect = CGI.param('redirect_to') || ctx.referer; + IF !redirect OR redirect.match(ctx.path_info _ '$'); + redirect = CGI.url('-full' => 1) _ '/opac/myopac/main'; + END; + redirect = redirect | replace('^http:', 'https:'); + %] + [% l('Remember Me?') %]
- + +[% + USE CGI; + USE EGI18N; +%]