line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1963
|
use Storable 'dclone'; |
|
1
|
|
|
|
|
3629
|
|
|
1
|
|
|
|
|
79
|
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
555
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
HTML::Obj2HTML::register_extension("dbtable", { |
7
|
|
|
|
|
|
|
tag => "table", |
8
|
|
|
|
|
|
|
before => sub { |
9
|
|
|
|
|
|
|
my $obj = shift; |
10
|
|
|
|
|
|
|
# we should have: hdl, the db handle to use; |
11
|
|
|
|
|
|
|
if ($obj->{header}) { |
12
|
|
|
|
|
|
|
push(@{$obj->{_}}, thead => [ tr => HTML::Obj2HTML::iterate("th", $obj->{header}) ]); |
13
|
|
|
|
|
|
|
delete($obj->{header}); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
if ($obj->{hdl} && $obj->{map}) { |
16
|
|
|
|
|
|
|
my @rows = (); |
17
|
|
|
|
|
|
|
while (my $r = $obj->{hdl}->next) { |
18
|
|
|
|
|
|
|
my @cols = (); |
19
|
|
|
|
|
|
|
foreach my $c (@{$obj->{map}}) { |
20
|
|
|
|
|
|
|
if (!ref $c) { |
21
|
|
|
|
|
|
|
if (exists $r->{$c}) { |
22
|
|
|
|
|
|
|
push(@cols, td => $r->{$c}); |
23
|
|
|
|
|
|
|
} else { |
24
|
|
|
|
|
|
|
push(@cols, td => $c); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} else { |
27
|
|
|
|
|
|
|
if (ref $c eq "CODE") { |
28
|
|
|
|
|
|
|
my $coderet = &$c($r); |
29
|
|
|
|
|
|
|
push(@cols, td => $coderet ); |
30
|
|
|
|
|
|
|
} else { |
31
|
|
|
|
|
|
|
my $newc = dclone $c; |
32
|
|
|
|
|
|
|
push(@cols, td => deepreplace($newc, $r) ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
push(@rows, tr => \@cols); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
push(@{$obj->{_}}, tbody => \@rows); |
39
|
|
|
|
|
|
|
delete($obj->{hdl}); |
40
|
|
|
|
|
|
|
delete($obj->{map}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
return ""; |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
attr => { class => 'ui celled table' } |
45
|
|
|
|
|
|
|
}); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub deepreplace { |
48
|
0
|
|
|
0
|
0
|
|
my $target = shift; |
49
|
0
|
|
|
|
|
|
my $record = shift; |
50
|
0
|
0
|
|
|
|
|
if (ref $target eq "ARRAY") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for (my $i=0; $i<=$#{$target}; $i++) { |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$target->[$i] = deepreplace($target->[$i], $record); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} elsif (ref $target eq "HASH") { |
55
|
0
|
|
|
|
|
|
foreach my $k (keys %{$target}) { |
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$target->{$k} = deepreplace($target->{$k}, $record); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} elsif (!ref $target) { |
60
|
0
|
|
|
|
|
|
$target = shallowreplace($target, $record); |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
|
|
|
return $target; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
sub shallowreplace { |
65
|
0
|
|
|
0
|
0
|
|
my $str = shift; |
66
|
0
|
|
|
|
|
|
my $record = shift; |
67
|
0
|
|
|
|
|
|
$str =~ s/\$\$([a-zA-Z0-9]+)/$record->{$1}/g; |
68
|
0
|
|
|
|
|
|
return $str; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |