[open-ils-commits] r12389 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Mar 3 17:54:04 EST 2009
Author: erickson
Date: 2009-03-03 17:54:00 -0500 (Tue, 03 Mar 2009)
New Revision: 12389
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
Log:
plugged in some template toolkit helpers
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2009-03-03 21:49:34 UTC (rev 12388)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2009-03-03 22:54:00 UTC (rev 12389)
@@ -1,7 +1,11 @@
package OpenILS::Application::Trigger::Reactor;
use strict; use warnings;
use Template;
+use DateTime;
+use DateTime::Format::ISO8601;
+use OpenSRF::Utils qw/:datetime/;
use OpenSRF::Utils::Logger qw(:logger);
+use OpenILS::Application::AppUtils;
sub fourty_two { return 42 }
sub NOOP_True { return 1 }
@@ -17,10 +21,43 @@
my $output = '';
my $tt = Template->new;
+ $env->{format_date} = \&format_date;
+ $env->{escape_xml} = \&escape_xml;
+ $env->{user_locale} = \&user_locale;
+
$tt->process(\$env->{template}, $env, \$output) or
$logger->error("Error processing Trigger template: " . $tt->error);
return $output;
}
+# turns a date into something TT can understand
+sub format_date {
+ my $date = shift;
+ $date = DateTime::Format::ISO8601->new->parse_datetime(clense_ISO8601($date));
+ return sprintf(
+ "%0.2d:%0.2d:%0.2d %0.2d-%0.2d-%0.4d",
+ $due->hour,
+ $due->minute,
+ $due->second,
+ $due->day,
+ $due->month,
+ $due->year
+ );
+}
+
+sub escape_xml {
+ my $str = shift;
+ $str =~ s/&/&/sog;
+ $str =~ s/</</sog;
+ $str =~ s/>/>/sog;
+ return $str;
+}
+
+
+sub user_locale {
+ my $user_id = shift;
+ return OpenILS::Application::AppUtils->get_user_locale($user_id);
+}
+
1;
More information about the open-ils-commits
mailing list