annotate Lib/DOM/Providers/Page.pm @ 14:65a7bb156fb7

Дом модель и схема
author Sergey
date Fri, 04 Sep 2009 16:38:15 +0400
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 package DOM::Providers::Page;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 use Template::Provider;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5 #use PerfCounter;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 use DOM::Page;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 use Encode;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 our @ISA= qw(Object Exporter);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12 our $UseIndexPage; #optional
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 our $PagesPath; #required
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14 our $IncludesPath; #optional
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 our $CacheSize; #optional
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 our $CachePath; #optional
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17 our $Encoding; #optional
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 our $AllowExtPath; #optional
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 our $PageResolver; #optional
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 BEGIN {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 DeclareProperty('PageResolver');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 DeclareProperty('PagesBase');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 DeclareProperty('IndexPage');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 DeclareProperty('TemplatesProvider');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 DeclareProperty('PageEnc');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 sub as_list {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 return( map { UNIVERSAL::isa($_,'ARRAY') ? @{$_} : defined $_ ? $_ : () } @_ );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 sub GetProviderInfo {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35 return {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36 Name => 'Page',
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 Host => 'DOM::Site',
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38 Methods => {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39 LoadPage => \&SiteLoadPage,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40 ReleasePage => \&SiteReleasePage,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
42 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
43 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
44
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
46 my ($this,%args) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
47
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
48 $this->{$PageResolver} = $args{'PageResolver'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
49 $this->{$PagesBase} = $args{'TemplatesPath'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
50 $this->{$IndexPage} = $args{'IndexPage'} || 'index.html';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
51 $this->{$PageEnc} = $args{'Encoding'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
52 $this->{$TemplatesProvider} = new Template::Provider( INCLUDE_PATH => [$this->{$PagesBase}, as_list($args{'IncludePath'}) ], COMPILE_DIR => $args{'CachePath'}, CACHE_SIZE => $args{'CacheSize'}, ENCODING => $args{'Encoding'}, ABSOLUTE => $AllowExtPath, RELATIVE => $AllowExtPath, INTERPOLATE => 1, PRE_CHOMP => 3);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
53 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
54
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
55 sub ResolveId {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
56 my ($this,$pageId) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
57
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
58 if ($this->{$PageResolver} && UNIVERSAL::can($this->{$PageResolver},'ResolveId')) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
59 return $this->{$PageResolver}->ResolveId($pageId);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
60 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
61 return grep { $_ } split /\//,$pageId;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
62 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
63 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
64
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
65 sub MakePageId {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
66 my ($this,$raPath) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
67
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
68 if ($this->{$PageResolver} && UNIVERSAL::can($this->{$PageResolver},'MakeId')) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
69 return $this->{$PageResolver}->MakeId($raPath);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
70 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
71 return join '/',@$raPath;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
72 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
73 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
74
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
75 sub PageIdToURL {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
76 my ($this,$pageId) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
77
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
78 if ($this->{$PageResolver} && UNIVERSAL::can($this->{$PageResolver},'PageIdToURL')) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
79 return $this->{$PageResolver}->PageIdToURL($pageId);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
80 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
81 return '/'.$pageId;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
82 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
83 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
84
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
85 sub SiteLoadPage {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
86 my ($this,$site,$pageId) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
87
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
88 return $site->RegisterObject('Page', $this->LoadPage($pageId, Site => $site));
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
89 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
90 sub LoadPage {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
91 my ($this,$pageId,%args) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
92
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
93 #StartTimeCounter('LoadPageTime');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
94
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
95 my @pathPage = $this->ResolveId($pageId);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
96
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
97 my $pageNode = $this->LoadNode(\@pathPage);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
98
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
99 pop @pathPage;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
100
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
101 my @pathNode;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
102
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
103 # ,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
104 my @NavChain = map { push @pathNode, $_; $this->LoadNode(\@pathNode); } ('.',@pathPage);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
105
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
106 if ($pageNode->{'Type'} eq 'Section') {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
107 push @NavChain,$pageNode;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
108 $pageNode = $this->LoadNode($pageNode->{'pathIndexPage'});
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
109 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
110
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
111 #
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
112 my %PageMenus;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
113 foreach my $MenuSet (map { $_->{'Menus'}} @NavChain, $pageNode->{'Menus'} ) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
114 foreach my $menuName (keys %$MenuSet) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
115 if ($PageMenus{$menuName}) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
116 $PageMenus{$menuName}->Merge($MenuSet->{$menuName});
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
117 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
118 $PageMenus{$menuName} = $MenuSet->{$menuName};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
119 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
120 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
121 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
122
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
123 #
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
124 my @keywords;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
125 my %Props;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
126 foreach my $PropSet ( (map { $_->{'Props'}} @NavChain), $pageNode->{'Props'} ) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
127 if(ref $PropSet->{'Keywords'} eq 'ARRAY') {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
128 push @keywords, @{$PropSet->{'Keywords'}};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
129 } elsif (not ref $PropSet->{'Keywords'} and exists $PropSet->{'Keywords'}) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
130 push @keywords, $PropSet->{'Keywords'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
131 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
132
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
133 while (my ($prop,$value) = each %$PropSet) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
134 next if $prop eq 'Keywords';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
135 $Props{$prop} = $value;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
136 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
137 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
138
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
139 #StopTimeCounter('LoadPageTime');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
140 #
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
141
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
142 #StartTimeCounter('FetchTime');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
143 my ($Template,$error) = $this->{$TemplatesProvider}->fetch($pageNode->{'TemplateFileName'});
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
144 die new Exception("Failed to load page $pageId",$Template ? $Template->as_string : 'Failed to parse') if $error;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
145 #StopTimeCounter('FetchTime');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
146
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
147 my $page = new DOM::Page(TemplatesProvider => $this->{$TemplatesProvider}, Properties => \%Props, Menus => \%PageMenus, NavChain => \@NavChain, Template => $Template, %args);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
148 $page->Properties->{url} = $this->PageIdToURL($pageId);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
149 return $page;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
150 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
151
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
152 sub LoadNode {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
153 my ($this,$refNodePath) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
154
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
155 my $fileNameNode = $this->{$PagesBase} . join('/',grep $_, @$refNodePath);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
156 my $fileNameMenus;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
157 my $fileNameProps;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
158
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
159 my %Node;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
160
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
161 if ( -d $fileNameNode ) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
162 $Node{'Type'} = 'Section';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
163 $fileNameMenus = $fileNameNode . '/.menu.pl';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
164 $fileNameProps = $fileNameNode . '/.prop.pl';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
165 } elsif ( -e $fileNameNode ) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
166 $Node{'Type'} = 'Page';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
167 $Node{'TemplateFileName'} = join('/',@$refNodePath);;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
168 $fileNameMenus = $fileNameNode . '.menu.pl';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
169 $fileNameProps = $fileNameNode . '.prop.pl';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
170 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
171 die new Exception("Page not found: $fileNameNode");
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
172 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
173
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
174 if ( -f $fileNameProps ) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
175 local ${^ENCODING};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
176 my $dummy = '';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
177 open my $hnull,'>>',\$dummy;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
178 local (*STDOUT,*STDIN) = ($hnull,$hnull);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
179 $Node{'Props'} = do $fileNameProps or warn "can't parse $fileNameProps: $@";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
180 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
181
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
182 if ( -f $fileNameMenus ) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
183 local ${^ENCODING};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
184 my $dummy = '';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
185 open my $hnull,'>>',\$dummy;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
186 local (*STDOUT,*STDIN) = ($hnull,$hnull);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
187 $Node{'Menus'} = do $fileNameMenus or warn "can't parse $fileNameMenus: $@";
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
188 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
189
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
190 if ($Node{'Menus'}) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
191 my %Menus;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
192 foreach my $menu (keys %{$Node{'Menus'}}) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
193 $Menus{$menu} = new DOM::PageMenu( DATA => $Node{'Menus'}->{$menu} );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
194 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
195 $Node{'Menus'} = \%Menus;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
196 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
197
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
198 $Node{'pathIndexPage'} = [@$refNodePath, $Node{'Props'}->{'IndexPage'} || $this->{$IndexPage}] if $Node{'Type'} eq 'Section';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
199
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
200 return \%Node;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
201 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
202
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
203 sub SiteReleasePage {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
204 my ($this,$site) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
205
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
206 my $page = $site->Objects()->{'Page'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
207 $page->Release() if $page;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
208
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
209 return 1;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
210 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
211
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
212 sub construct {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
213 my $self = shift;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
214
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
215 return new DOM::Providers::Page(TemplatesPath => $PagesPath, IncludePath => $IncludesPath, IndexPage => $UseIndexPage, CachePath => $CachePath, CacheSize => $CacheSize, Encoding => $Encoding);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
216 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
217
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
218 sub DecodeData {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
219 my ($Encoding, $data) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
220
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
221 if (ref $data) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
222 if (ref $data eq 'SCALAR') {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
223 my $decoded = Encode::decode($Encoding,$$data,Encode::LEAVE_SRC);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
224 return \$decoded;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
225 } elsif (UNIVERSAL::isa($data, 'HASH')) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
226 return {map {Encode::decode($Encoding,$_,Encode::LEAVE_SRC),DecodeData($Encoding,$data->{$_})} keys %$data };
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
227 } elsif (UNIVERSAL::isa($data, 'ARRAY')) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
228 return [map {DecodeData($Encoding,$_)} @$data];
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
229 } elsif (ref $data eq 'REF') {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
230 my $decoded = DecodeData($Encoding,$$data);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
231 return \$decoded;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
232 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
233 die new Exception('Cant decode data type', ref $data);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
234 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
235 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
236 return Encode::decode($Encoding,$data,Encode::LEAVE_SRC);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
237 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
238 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
239
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
240 1;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
241
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
242 =pod
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
243 .
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
244
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
245 ,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
246
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
247 Keywords
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
248 Name
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
249 IndexPage
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
250
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
251 ,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
252
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
253 ,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
254 ,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
255 keywords ,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
256 ,
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
257
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
258 =cut