| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
################################################################################ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Apache::Voodoo::View::HTML |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# This modules is used internally by Voodoo for interfacing to HTML::Template. |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
################################################################################ |
|
8
|
|
|
|
|
|
|
package Apache::Voodoo::View::HTML; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = "3.0200"; |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
1761
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
73
|
|
|
13
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
60
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
11
|
use File::Spec; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
48
|
|
|
16
|
2
|
|
|
2
|
|
4348
|
use HTML::Template; |
|
|
2
|
|
|
|
|
34269
|
|
|
|
2
|
|
|
|
|
114
|
|
|
17
|
2
|
|
|
2
|
|
859
|
use Apache::Voodoo::Exception; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
63
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
16
|
use Exception::Class::DBI; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
66
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
12
|
use base ("Apache::Voodoo::View"); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
2317
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init { |
|
24
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
|
25
|
3
|
|
|
|
|
7
|
my $config = shift; |
|
26
|
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
18
|
$self->{'template_dir'} = $config->{'template_dir'}; |
|
28
|
3
|
|
|
|
|
11
|
$self->{'template_opts'} = $config->{'template_opts'}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
10
|
$self->{'template_opts'}->{'die_on_bad_params'} = 0; |
|
31
|
3
|
|
|
|
|
8
|
$self->{'template_opts'}->{'global_vars'} = 1; |
|
32
|
3
|
|
|
|
|
9
|
$self->{'template_opts'}->{'loop_context_vars'} = 1; |
|
33
|
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
15
|
$self->{'template_opts'}->{'path'} = [ $config->{'template_dir'} ]; |
|
35
|
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
10
|
$self->{'site_root'} = $config->{'site_root'}; |
|
37
|
3
|
|
|
|
|
11
|
$self->{'use_themes'} = $config->{'themes'}->{'use_themes'}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
3
|
50
|
|
|
|
12
|
if ($self->{'use_themes'}) { |
|
40
|
0
|
|
|
|
|
0
|
require Apache::Voodoo::View::HTML::Theme; |
|
41
|
0
|
|
|
|
|
0
|
$self->{'theme_handler'} = Apache::Voodoo::View::HTML::Theme->new($config->{'themes'}); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
20
|
$self->content_type('text/html'); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub begin { |
|
48
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
49
|
0
|
|
|
|
|
|
my $p = shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
0
|
|
|
|
$self->content_type($p->{"template_conf"}->{"content-type"} || 'text/html'); |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $skeleton; |
|
54
|
0
|
|
|
|
|
|
eval { |
|
55
|
0
|
|
|
|
|
|
my $return; |
|
56
|
0
|
0
|
|
|
|
|
if ($self->{'use_themes'}) { |
|
57
|
|
|
|
|
|
|
# time to do the theme processing stuff. |
|
58
|
0
|
|
|
|
|
|
$return = $self->{'theme_handler'}->handle( |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
|
|
|
|
|
|
"document_root" => $self->{'template_dir'}, |
|
61
|
|
|
|
|
|
|
"session" => $p->{'session'}, |
|
62
|
|
|
|
|
|
|
"uri" => $p->{'uri'}, |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$skeleton = $self->{'theme_handler'}->get_skeleton(); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else { |
|
69
|
0
|
|
0
|
|
|
|
$skeleton = $p->{'template_conf'}->{'skeleton'} || 'skeleton'; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->_load_skeleton($skeleton); |
|
73
|
0
|
|
|
|
|
|
$self->_load_template($p->{'uri'}); |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$self->params(SITE_ROOT => $self->{site_root}); |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
$self->params($return) if ($return); |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
0
|
0
|
|
|
|
|
if ($@) { |
|
80
|
0
|
|
|
|
|
|
$self->_internal_error($@); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _load_skeleton { |
|
85
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
86
|
0
|
|
|
|
|
|
my $s = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->{skeleton_template} = HTML::Template->new( |
|
89
|
|
|
|
|
|
|
'filename' => File::Spec->catfile($self->{'template_dir'},$s.".tmpl"), |
|
90
|
0
|
|
|
|
|
|
%{$self->{'template_opts'}} |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _load_template { |
|
95
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
96
|
0
|
|
|
|
|
|
my $u = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$self->{template} = HTML::Template->new( |
|
99
|
|
|
|
|
|
|
'filename' => File::Spec->catfile($self->{'template_dir'},$u.".tmpl"), |
|
100
|
0
|
|
|
|
|
|
%{$self->{'template_opts'}} |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _load_internal_template { |
|
105
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
106
|
0
|
|
|
|
|
|
my $u = shift; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $path = $INC{'Apache/Voodoo/View/HTML.pm'}; |
|
109
|
0
|
|
|
|
|
|
$path =~ s/\.pm/\//o; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
$self->{template} = HTML::Template->new( |
|
112
|
|
|
|
|
|
|
'filename' => $path.$u.'.tmpl', |
|
113
|
0
|
|
|
|
|
|
%{$self->{'template_opts'}} |
|
114
|
|
|
|
|
|
|
); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub params { |
|
118
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
return if ($self->{internal_error}); |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
eval { |
|
123
|
0
|
|
|
|
|
|
$self->{skeleton_template}->param(@_); |
|
124
|
0
|
|
|
|
|
|
$self->{template}->param(@_); |
|
125
|
|
|
|
|
|
|
}; |
|
126
|
0
|
0
|
|
|
|
|
if ($@) { |
|
127
|
0
|
|
|
|
|
|
$self->_internal_error($@); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub exception { |
|
132
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
133
|
0
|
|
|
|
|
|
my $e = shift; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
0
|
|
|
|
|
return if ($self->{internal_error}); |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
eval { |
|
138
|
0
|
0
|
|
|
|
|
if ($e->isa("Exception::Class::DBI")) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->_load_internal_template("db_error"); |
|
140
|
0
|
|
|
|
|
|
$self->params( |
|
141
|
|
|
|
|
|
|
"description" => "Database Error", |
|
142
|
|
|
|
|
|
|
"message" => $e->errstr, |
|
143
|
|
|
|
|
|
|
"package" => $e->package, |
|
144
|
|
|
|
|
|
|
"line" => $e->line, |
|
145
|
|
|
|
|
|
|
"query" => $self->_format_query($e->statement) |
|
146
|
|
|
|
|
|
|
); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
elsif ($e->isa("Apache::Voodoo::Exception::Application::DisplayError")) { |
|
149
|
0
|
0
|
|
|
|
|
if (-e File::Spec->catfile($self->{'template_dir'},"display_error.tmpl")) { |
|
150
|
0
|
|
|
|
|
|
$self->_load_template("display_error"); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
else { |
|
153
|
0
|
|
|
|
|
|
$self->_load_internal_template("display_error"); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
$self->params('error_url' => $e->target); |
|
157
|
0
|
0
|
|
|
|
|
if (ref($e->error) eq "HASH") { |
|
158
|
0
|
|
|
|
|
|
$self->params($e->error); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
else { |
|
161
|
0
|
|
|
|
|
|
$self->params('error_string' => $e->error); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
elsif ($e->isa("Apache::Voodoo::Exception")) { |
|
165
|
0
|
|
|
|
|
|
$self->_load_internal_template("exception"); |
|
166
|
0
|
|
|
|
|
|
$self->params( |
|
167
|
|
|
|
|
|
|
"description" => $e->description, |
|
168
|
|
|
|
|
|
|
"message" => $e->error |
|
169
|
|
|
|
|
|
|
); |
|
170
|
0
|
0
|
|
|
|
|
if ($e->isa("Apache::Voodoo::Exception::RunTime")) { |
|
171
|
0
|
|
|
|
|
|
$self->params("stack" => Apache::Voodoo::Exception::parse_stack_trace($e->trace())); |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
else { |
|
175
|
0
|
|
|
|
|
|
$self->_load_internal_template("exception"); |
|
176
|
0
|
|
|
|
|
|
$self->params("message" => "$e"); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
}; |
|
179
|
0
|
0
|
|
|
|
|
if ($@) { |
|
180
|
0
|
|
|
|
|
|
$self->_internal_error($@); |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub output { |
|
185
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
0
|
|
|
|
|
if ($self->{internal_error}) { |
|
188
|
|
|
|
|
|
|
return |
|
189
|
0
|
|
|
|
|
|
"". |
|
190
|
|
|
|
|
|
|
"The following error was encountered while processing this request:". |
|
191
|
|
|
|
|
|
|
"".$self->{error_msg}."". |
|
192
|
|
|
|
|
|
|
""; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
else { |
|
195
|
0
|
|
|
|
|
|
$self->{skeleton_template}->param('_MAIN_BODY_' => $self->{template}->output()); |
|
196
|
0
|
|
|
|
|
|
return $self->{skeleton_template}->output(); |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub finish { |
|
201
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
202
|
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
$self->{template} = undef; |
|
204
|
0
|
|
|
|
|
|
$self->{skeletong_template} = undef; |
|
205
|
0
|
|
|
|
|
|
$self->{internal_error} = 0; |
|
206
|
0
|
|
|
|
|
|
$self->{error_msg} = undef; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub _internal_error { |
|
210
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
$self->content_type("text/html"); |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
$self->{internal_error} = 1; |
|
215
|
0
|
|
|
|
|
|
$self->{error_msg} = shift; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub _format_query { |
|
219
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
220
|
0
|
|
|
|
|
|
my $query = shift; |
|
221
|
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
my $leading = undef; |
|
223
|
0
|
|
|
|
|
|
my @lines; |
|
224
|
0
|
|
|
|
|
|
foreach my $line (split(/\n/,$query)) { |
|
225
|
0
|
|
|
|
|
|
$line =~ s/[\r\n]//g; |
|
226
|
0
|
|
|
|
|
|
$line =~ s/(?
|
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
0
|
|
|
|
|
if (!defined($leading)) { |
|
229
|
0
|
0
|
|
|
|
|
next if $line =~ /^\s*$/; |
|
230
|
0
|
|
|
|
|
|
my $l = $line; |
|
231
|
0
|
|
|
|
|
|
$l =~ s/\S.*$//; |
|
232
|
0
|
0
|
|
|
|
|
if (length($l)) { |
|
233
|
0
|
|
|
|
|
|
$leading = length($l); |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
else { |
|
237
|
0
|
|
|
|
|
|
my $l = $line; |
|
238
|
0
|
|
|
|
|
|
$l =~ s/\S.*$//; |
|
239
|
0
|
0
|
0
|
|
|
|
if (length($l) and length($l) < $leading) { |
|
240
|
0
|
|
|
|
|
|
$leading = length($l); |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
} |
|
243
|
0
|
|
|
|
|
|
push (@lines,$line); |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
|
return join( |
|
247
|
|
|
|
|
|
|
"\n", |
|
248
|
|
|
|
|
|
|
map { |
|
249
|
0
|
|
|
|
|
|
$_ =~ s/^ {$leading}//; |
|
250
|
0
|
|
|
|
|
|
$_; |
|
251
|
|
|
|
|
|
|
} @lines |
|
252
|
|
|
|
|
|
|
); |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
1; |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
################################################################################ |
|
258
|
|
|
|
|
|
|
# Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org). |
|
259
|
|
|
|
|
|
|
# All rights reserved. |
|
260
|
|
|
|
|
|
|
# |
|
261
|
|
|
|
|
|
|
# You may use and distribute Apache::Voodoo under the terms described in the |
|
262
|
|
|
|
|
|
|
# LICENSE file include in this package. The summary is it's a legalese version |
|
263
|
|
|
|
|
|
|
# of the Artistic License :) |
|
264
|
|
|
|
|
|
|
# |
|
265
|
|
|
|
|
|
|
################################################################################ |