comparison Lib/IMPL/Web/QueryHandler/PageFormat.pm @ 146:60fd224f3e3c

fixed cgi parameters processing Added parameters inflating feature Added preprocessed templates, reformatting output
author wizard
date Mon, 26 Jul 2010 03:19:06 +0400
parents b56ebc31bf18
children eb478083f72b
comparison
equal deleted inserted replaced
145:bd10093bb122 146:60fd224f3e3c
8 use IMPL::Class::Property; 8 use IMPL::Class::Property;
9 use IMPL::Web::TT::Document; 9 use IMPL::Web::TT::Document;
10 use Template::Plugin::URL; 10 use Template::Plugin::URL;
11 use IMPL::Security::Context; 11 use IMPL::Security::Context;
12 use File::Spec; 12 use File::Spec;
13 use HTML::TreeBuilder;
13 use Error qw(:try); 14 use Error qw(:try);
14 15
15 $Template::Plugin::URL::JOINT = '&'; 16 $Template::Plugin::URL::JOINT = '&';
16 17
17 BEGIN { 18 BEGIN {
18 public property templatesCharset => prop_all; 19 public property templatesCharset => prop_all;
19 public property templatesBase => prop_all; 20 public property templatesBase => prop_all;
20 public property defaultTarget => prop_all; 21 public property defaultTarget => prop_all;
21 public property pathinfoPrefix => prop_all; 22 public property pathinfoPrefix => prop_all;
22 public property cache => prop_all; 23 public property cache => prop_all;
24 public property preprocess => prop_all;
25 public property formatOutput => prop_all;
23 } 26 }
24 27
25 sub CTOR { 28 sub CTOR {
26 my ($this) = @_; 29 my ($this) = @_;
27 30
31 } 34 }
32 35
33 sub Process { 36 sub Process {
34 my ($this,$action,$nextHandler) = @_; 37 my ($this,$action,$nextHandler) = @_;
35 38
36 my $doc = new IMPL::Web::TT::Document(cache => $this->cache); 39 my $doc = new IMPL::Web::TT::Document(cache => $this->cache, preprocess => $this->preprocess);
37 40
38 try { 41 try {
39 42
40 $this->templatesBase($ENV{DOCUMENT_ROOT}) unless $this->templatesBase; 43 $this->templatesBase($ENV{DOCUMENT_ROOT}) unless $this->templatesBase;
41 44
86 $doc->AddVar( escape_string => sub { $_[0] =~ s/"/"/g; $_[0] } ); 89 $doc->AddVar( escape_string => sub { $_[0] =~ s/"/"/g; $_[0] } );
87 90
88 91
89 $action->response->contentType('text/html'); 92 $action->response->contentType('text/html');
90 my $hOut = $action->response->streamBody; 93 my $hOut = $action->response->streamBody;
91 print $hOut $doc->Render(); 94 if ($this->formatOutput == 1) {
95 my $tree = new HTML::TreeBuilder();
96 try {
97 $tree->parse_content($doc->Render());
98 print $hOut $tree->as_HTML('<>&'," ",{});
99 } finally {
100 $tree->delete;
101 };
102 } elsif ($this->formatOutput() == 2 ) {
103 (my $data = $doc->Render()) =~ s/\s+/ /g;
104 print $hOut $data;
105 } else {
106 print $hOut $doc->Render();
107 }
92 } finally { 108 } finally {
93 $doc->Dispose; 109 $doc->Dispose;
94 }; 110 };
95 } 111 }
96 112