1 package OpenILS::WWW::Reporter;
2 use strict; use warnings;
6 use Apache2::Const -compile => qw(OK REDIRECT :log);
7 use APR::Const -compile => qw(:error SUCCESS);
8 use Apache2::RequestRec ();
9 use Apache2::RequestIO ();
10 use Apache2::RequestUtil;
12 use Template qw(:template);
14 use OpenSRF::EX qw(:try);
20 # set the bootstrap config and template include directory when
21 # this module is loaded
26 my( $self, $bs_config, $tdir ) = @_;
27 $bootstrap = $bs_config;
28 $includes = [ $tdir ];
32 # our templates plugins are here
33 my $plugin_base = 'OpenILS::Template::Plugin';
36 warn "Initing child with bootstrap $bootstrap\n";
37 OpenSRF::System->bootstrap_client( config_file => $bootstrap );
44 my $path = $apache->path_info;
45 (my $ttk = $path) =~ s{^/?([a-zA-Z0-9_]+).*?$}{$1}o;
47 print "Content-type: text/html; charset=utf-8\n\n";
51 template => "$ttk.ttk",
54 return Apache2::Const::OK;
58 sub _process_template {
61 my $ttk = $params{template} || return undef;
62 my $apache = $params{apache} || undef;
63 my $param_hash = $params{params} || {};
67 $template = Template->new( {
71 PLUGIN_BASE => $plugin_base,
72 INCLUDE_PATH => $includes,
81 if( ! $template->process( $ttk, $param_hash ) ) {
82 warn "Error Processing Template: " . $template->error();
83 my $err = $template->error();
84 $err =~ s/\n/\<br\/\>/g;
85 warn "Error processing template $ttk\n";
86 my $string = "<br><b>Unable to process template:<br/><br/> " . $err . "!!!</b>";
87 print "ERROR: $string";
88 #$template->process( $error_ttk , { error => $string } );
93 warn "Error processing template $ttk: $e - $@ \n";
94 print "<center><br/><br/><b>Error<br/><br/> $e <br/><br/> $@ </b><br/></center>";