blib/lib/CGI/Application/Plus/Util.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 3 | 39 | 7.6 |
branch | 0 | 6 | 0.0 |
condition | 0 | 6 | 0.0 |
subroutine | 1 | 4 | 25.0 |
pod | 0 | 3 | 0.0 |
total | 4 | 58 | 6.9 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | 8 | 8 | 400316 | use strict ; | |||
8 | 21 | ||||||
8 | 5615 | ||||||
2 | |||||||
3 | # This file uses the "Perlish" coding style | ||||||
4 | # please read http://perl.4pro.net/perlish_coding_style.html | ||||||
5 | |||||||
6 | ; package CGI::Application::Plus::Util | ||||||
7 | |||||||
8 | # same as the original, here just for compatibility | ||||||
9 | ; sub load_tmpl | ||||||
10 | 0 | 0 | 0 | { my $s = shift | |||
11 | 0 | ; my ($tmpl_file, @extra_params) = @_ | |||||
12 | # add tmpl_path to path array of one is set, otherwise add a path arg | ||||||
13 | 0 | 0 | ; if (my $tmpl_path = $s->tmpl_path) | ||||
14 | 0 | { my $found = 0 | |||||
15 | 0 | ; for( my $x = 0 | |||||
16 | ; $x < @extra_params | ||||||
17 | ; $x += 2 | ||||||
18 | ) | ||||||
19 | 0 | 0 | 0 | { if ( $extra_params[$x] eq 'path' | |||
0 | |||||||
20 | and ref $extra_params[$x+1] | ||||||
21 | and ref $extra_params[$x+1] eq 'ARRAY' | ||||||
22 | ) | ||||||
23 | 0 | { unshift @{$extra_params[$x+1]}, $tmpl_path | |||||
0 | |||||||
24 | 0 | ; $found = 1 | |||||
25 | ; last | ||||||
26 | 0 | } | |||||
27 | } | ||||||
28 | 0 | 0 | ; push ( @extra_params | ||||
29 | , path => [ $tmpl_path ] | ||||||
30 | ) | ||||||
31 | unless $found | ||||||
32 | } | ||||||
33 | ; require HTML::Template | ||||||
34 | 0 | ; my $t = HTML::Template->new_file( $tmpl_file | |||||
0 | |||||||
35 | , @extra_params | ||||||
36 | ) | ||||||
37 | 0 | ; return $t | |||||
38 | } | ||||||
39 | |||||||
40 | |||||||
41 | # statements from now on are needed just when testing | ||||||
42 | # and they are never used in real job | ||||||
43 | |||||||
44 | ; sub dump | ||||||
45 | 0 | 0 | 0 | { my $s = shift | |||
46 | 0 | ; $s->page .= qq(Run-mode: "${\$s->runmode}"\n) | |||||
0 | |||||||
47 | 0 | ; $s->page .= "\nQuery Parameters:\n" | |||||
48 | 0 | ; foreach my $p ( sort $s->query->param() ) | |||||
49 | 0 | { my $data_str = "'" | |||||
50 | . join "', '" , $s->query->param($p) | ||||||
51 | ."'" | ||||||
52 | 0 | ; $s->page .= "\t$p => $data_str\n" | |||||
53 | } | ||||||
54 | 0 | ; $s->page .= "\nQuery Environment:\n" | |||||
55 | 0 | ; foreach my $k ( sort keys %ENV ) | |||||
56 | 0 | { $s->page .= "\t$k => '".$ENV{$k}."'\n" | |||||
57 | } | ||||||
58 | } | ||||||
59 | |||||||
60 | ; sub dump_html | ||||||
61 | 0 | 0 | 0 | { my $s = shift | |||
62 | 0 | ; $s->page .= qq( Run-mode: ${\$s->runmode} \n) |
|||||
0 | |||||||
63 | 0 | ; $s->page .= " \nQuery Parameters: |
|||||
64 | 0 | ; foreach my $p ( sort $s->query->param() ) | |||||
65 | 0 | { my $data_str = "'" | |||||
66 | . join "', '" , $s->query->param($p) | ||||||
67 | ."'" | ||||||
68 | 0 | ; $s->page .= " |
|||||
69 | } | ||||||
70 | 0 | ; $s->page .= "\n\n"; | |||||
71 | 0 | ; $s->page .= " \nQuery Environment:
|
|||||
72 | 0 | ; foreach my $ek ( sort keys %ENV ) | |||||
73 | 0 | { $s->page .= " |
|||||
74 | } | ||||||
75 | 0 | ; $s->page .= "\n\n"; | |||||
76 | } | ||||||
77 | |||||||
78 | |||||||
79 | |||||||
80 | ; 1 | ||||||
81 | |||||||
82 | __END__ |