Mercurial > pub > Impl
annotate Lib/IMPL/Web/QueryHandler/PageFormat.pm @ 87:6d3bca490556
small fixes in the security moodules
author | wizard |
---|---|
date | Mon, 19 Apr 2010 23:20:46 +0400 |
parents | 9d24db321029 |
children | 964587c5183c |
rev | line source |
---|---|
62 | 1 package IMPL::Web::QueryHandler::PageFormat; |
64 | 2 use base qw(IMPL::Web::QueryHandler IMPL::Object::Autofill); |
62 | 3 |
4 __PACKAGE__->PassThroughArgs; | |
5 | |
6 use IMPL::Class::Property; | |
77 | 7 use IMPL::Web::TT::Document; |
65 | 8 use File::Spec; |
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
9 use Error qw(:try); |
62 | 10 |
64 | 11 BEGIN { |
65 | 12 public property templatesCharset => prop_all; |
13 public property templatesBase => prop_all; | |
64 | 14 } |
15 | |
16 sub CTOR { | |
17 my ($this) = @_; | |
18 | |
65 | 19 $this->templatesCharset('utf-8') unless $this->templatesCharset; |
20 $this->templatesBase('.') unless $this->templatesBase; | |
64 | 21 } |
22 | |
62 | 23 sub Process { |
24 my ($this,$action,$nextHandler) = @_; | |
25 | |
77 | 26 my $doc = new IMPL::Web::TT::Document(); |
62 | 27 |
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
28 try { |
65 | 29 my @path = split /\//, $ENV{PATH_TRANSLATED}; |
30 | |
77 | 31 $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset ); |
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
32 |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
33 $action->response->contentType('text/html'); |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
34 my $hOut = $action->response->streamBody; |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
35 |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
36 print $hOut $doc->Render(); |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
37 } finally { |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
38 $doc->Dispose; |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
39 }; |
62 | 40 } |
41 | |
65 | 42 1; |
43 | |
44 __END__ | |
45 | |
46 =pod | |
47 | |
48 =head1 NAME | |
49 | |
50 C<IMPL::Web::QueryHandler::PageFormat> - Выдача результатов в виде HTML страницы, построенной из шаблона. | |
51 | |
52 =head1 SYNOPSIS | |
53 | |
54 В файле конфигурации приложения | |
55 | |
56 =begin code xml | |
57 | |
58 <handlersQuery type="IMPL::Object::List"> | |
59 <item type="IMPL::Web::QueryHandler::PageFormat"> | |
60 <charsetTemplates>utf-8</charsetTemplates> | |
61 </item> | |
62 </handlersQuery> | |
63 | |
64 =end code xml | |
65 | |
66 Программно | |
67 | |
68 =begin code | |
69 | |
70 my $app = new IMPL::Web::Application(); | |
71 $app->handlersQuery->Add( | |
72 new IMPL::Web::QueryHandler::PageFormat( charsetTemplates=> 'utf-8' ); | |
73 ); | |
74 | |
75 =end | |
76 | |
77 =head1 DESCRIPTION | |
78 | |
79 Обработчик запроса для веб приложения. Загружает шаблон, путь к котрому берется | |
80 из C<ENV{PATH_INFO}> относительно пути из свойства C<templatesBase>. | |
81 | |
82 Наследуется от C<IMPL::Web::QueryHandler> для реализации функционала | |
83 обработчика запроса и переопределяет метод C<Process>. | |
84 | |
85 C<Serializable> | |
86 | |
87 =head1 MEMBERS | |
88 | |
89 =over | |
90 | |
91 =item C<CTOR(%props)> | |
92 | |
93 Создает новый экземпляр и заполняет свойства. | |
94 | |
95 =item C<[get,set] templatesCharset> | |
96 | |
97 Кодировка шаблонов. По умолчанию utf-8. | |
98 | |
99 =item C<[get,set] templatesBase> | |
100 | |
101 Каталог относительно которого ищется шаблон. | |
102 | |
103 =item C<[override] Process($action,$nextHandler)> | |
104 | |
105 Метод, переопределяющий C<IMPL::Web::QueryHandler->Process> и которому передается управление | |
106 для выполнения действий. | |
107 | |
108 =back | |
109 | |
110 =cut |