line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tags::HTML::Table::View; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
110160
|
use base qw(Tags::HTML); |
|
7
|
|
|
|
|
50
|
|
|
7
|
|
|
|
|
3536
|
|
4
|
7
|
|
|
7
|
|
187457
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
148
|
|
5
|
7
|
|
|
7
|
|
42
|
use warnings; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
200
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
37
|
use Class::Utils qw(set_params split_params); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
331
|
|
8
|
7
|
|
|
7
|
|
48
|
use Error::Pure qw(err); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
300
|
|
9
|
7
|
|
|
7
|
|
42
|
use List::MoreUtils qw(none); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
33
|
|
10
|
7
|
|
|
7
|
|
4640
|
use Scalar::Util qw(blessed); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
6475
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.01; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constructor. |
15
|
|
|
|
|
|
|
sub new { |
16
|
6
|
|
|
6
|
1
|
5015
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create object. |
19
|
6
|
|
|
|
|
52
|
my ($object_params_ar, $other_params_ar) = split_params( |
20
|
|
|
|
|
|
|
['css_table', 'header'], @params); |
21
|
6
|
|
|
|
|
166
|
my $self = $class->SUPER::new(@{$other_params_ar}); |
|
6
|
|
|
|
|
49
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Main CSS class. |
24
|
6
|
|
|
|
|
249
|
$self->{'css_table'} = 'table'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Header is in first line. |
27
|
6
|
|
|
|
|
16
|
$self->{'header'} = 1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Process params. |
30
|
6
|
|
|
|
|
12
|
set_params($self, @{$object_params_ar}); |
|
6
|
|
|
|
|
22
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Object. |
33
|
6
|
|
|
|
|
55
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _cleanup { |
37
|
1
|
|
|
1
|
|
31
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
3
|
delete $self->{'_data'}; |
40
|
1
|
|
|
|
|
2
|
delete $self->{'_no_data'}; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
3
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _init { |
46
|
5
|
|
|
5
|
|
79
|
my ($self, $data_ar, $no_data_value) = @_; |
47
|
|
|
|
|
|
|
|
48
|
5
|
50
|
|
|
|
21
|
if (exists $self->{'_data'}) { |
49
|
0
|
|
|
|
|
0
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
|
|
12
|
$self->{'_data'} = $data_ar; |
53
|
5
|
|
|
|
|
12
|
$self->{'_no_data'} = $no_data_value; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
11
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Process 'Tags'. |
59
|
|
|
|
|
|
|
sub _process { |
60
|
4
|
|
|
4
|
|
680
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Main content. |
63
|
|
|
|
|
|
|
$self->{'tags'}->put( |
64
|
|
|
|
|
|
|
['b', 'table'], |
65
|
4
|
|
|
|
|
31
|
['a', 'class', $self->{'css_table'}], |
66
|
|
|
|
|
|
|
); |
67
|
4
|
|
|
|
|
317
|
my $columns_count = 0; |
68
|
4
|
50
|
|
|
|
12
|
if ($self->{'header'}) { |
69
|
4
|
|
|
|
|
16
|
$self->{'tags'}->put( |
70
|
|
|
|
|
|
|
['b', 'tr'], |
71
|
|
|
|
|
|
|
); |
72
|
4
|
|
|
|
|
139
|
my $header_ar = shift @{$self->{'_data'}}; |
|
4
|
|
|
|
|
12
|
|
73
|
4
|
|
|
|
|
7
|
foreach my $value (@{$header_ar}) { |
|
4
|
|
|
|
|
8
|
|
74
|
6
|
|
|
|
|
24
|
$self->{'tags'}->put( |
75
|
|
|
|
|
|
|
['b', 'th'], |
76
|
|
|
|
|
|
|
['d', $value], |
77
|
|
|
|
|
|
|
['e', 'th'], |
78
|
|
|
|
|
|
|
); |
79
|
6
|
|
|
|
|
503
|
$columns_count++; |
80
|
|
|
|
|
|
|
} |
81
|
4
|
|
|
|
|
12
|
$self->{'tags'}->put( |
82
|
|
|
|
|
|
|
['e', 'tr'], |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} else { |
85
|
0
|
|
|
|
|
0
|
$columns_count++; |
86
|
|
|
|
|
|
|
} |
87
|
4
|
|
|
|
|
145
|
foreach my $row_ar (@{$self->{'_data'}}) { |
|
4
|
|
|
|
|
10
|
|
88
|
2
|
|
|
|
|
10
|
$self->{'tags'}->put( |
89
|
|
|
|
|
|
|
['b', 'tr'], |
90
|
|
|
|
|
|
|
); |
91
|
2
|
|
|
|
|
68
|
foreach my $value (@{$row_ar}) { |
|
2
|
|
|
|
|
6
|
|
92
|
4
|
|
|
|
|
81
|
$self->{'tags'}->put( |
93
|
|
|
|
|
|
|
['b', 'td'], |
94
|
|
|
|
|
|
|
); |
95
|
4
|
|
|
|
|
136
|
$self->_value($value); |
96
|
4
|
|
|
|
|
16
|
$self->{'tags'}->put( |
97
|
|
|
|
|
|
|
['e', 'td'], |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
} |
100
|
2
|
|
|
|
|
73
|
$self->{'tags'}->put( |
101
|
|
|
|
|
|
|
['e', 'tr'], |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# No data row. |
106
|
4
|
100
|
100
|
|
|
75
|
if (! @{$self->{'_data'}} && defined $self->{'_no_data'}) { |
|
4
|
|
|
|
|
35
|
|
107
|
1
|
|
|
|
|
7
|
$self->{'tags'}->put( |
108
|
|
|
|
|
|
|
['b', 'tr'], |
109
|
|
|
|
|
|
|
['b', 'td'], |
110
|
|
|
|
|
|
|
['a', 'colspan', $columns_count], |
111
|
|
|
|
|
|
|
); |
112
|
1
|
|
|
|
|
87
|
$self->_value($self->{'_no_data'}); |
113
|
1
|
|
|
|
|
5
|
$self->{'tags'}->put( |
114
|
|
|
|
|
|
|
['e', 'td'], |
115
|
|
|
|
|
|
|
['e', 'tr'], |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
4
|
|
|
|
|
80
|
$self->{'tags'}->put( |
120
|
|
|
|
|
|
|
['e', 'table'], |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
4
|
|
|
|
|
161
|
return; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Process 'CSS::Struct'. |
127
|
|
|
|
|
|
|
sub _process_css { |
128
|
1
|
|
|
1
|
|
32
|
my $self = shift; |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
41
|
$self->{'css'}->put( |
131
|
|
|
|
|
|
|
['s', 'table'], |
132
|
|
|
|
|
|
|
['s', 'td'], |
133
|
|
|
|
|
|
|
['s', 'th'], |
134
|
|
|
|
|
|
|
['d', 'border', '1px solid #ddd'], |
135
|
|
|
|
|
|
|
['d', 'text-align', 'left'], |
136
|
|
|
|
|
|
|
['e'], |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
['s', 'table'], |
139
|
|
|
|
|
|
|
['d', 'border-collapse', 'collapse'], |
140
|
|
|
|
|
|
|
['d', 'width', '100%'], |
141
|
|
|
|
|
|
|
['e'], |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
['s', 'th'], |
144
|
|
|
|
|
|
|
['s', 'td'], |
145
|
|
|
|
|
|
|
['d', 'padding', '15px'], |
146
|
|
|
|
|
|
|
['e'], |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
382
|
return; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _tags_a { |
153
|
0
|
|
|
0
|
|
0
|
my ($self, $value) = @_; |
154
|
|
|
|
|
|
|
|
155
|
0
|
0
|
|
|
|
0
|
$self->{'tags'}->put( |
|
|
0
|
|
|
|
|
|
156
|
|
|
|
|
|
|
['b', 'a'], |
157
|
|
|
|
|
|
|
defined $value->css_class ? ( |
158
|
|
|
|
|
|
|
['a', 'class', $value->css_class], |
159
|
|
|
|
|
|
|
) : (), |
160
|
|
|
|
|
|
|
defined $value->url ? ( |
161
|
|
|
|
|
|
|
['a', 'href', $value->url], |
162
|
|
|
|
|
|
|
) : (), |
163
|
|
|
|
|
|
|
); |
164
|
0
|
0
|
|
|
|
0
|
if ($value->data_type eq 'plain') { |
|
|
0
|
|
|
|
|
|
165
|
0
|
|
|
|
|
0
|
$self->{'tags'}->put( |
166
|
|
|
|
|
|
|
['d', $value->data], |
167
|
|
|
|
|
|
|
); |
168
|
|
|
|
|
|
|
} elsif ($value->data_type eq 'tags') { |
169
|
0
|
|
|
|
|
0
|
$self->{'tags'}->put($value->data); |
170
|
|
|
|
|
|
|
} |
171
|
0
|
|
|
|
|
0
|
$self->{'tags'}->put( |
172
|
|
|
|
|
|
|
['e', 'a'], |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
0
|
return; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub _value { |
179
|
5
|
|
|
5
|
|
12
|
my ($self, $value) = @_; |
180
|
|
|
|
|
|
|
|
181
|
5
|
50
|
0
|
|
|
14
|
if (ref $value eq '') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
182
|
5
|
|
|
|
|
18
|
$self->{'tags'}->put( |
183
|
|
|
|
|
|
|
['d', $value], |
184
|
|
|
|
|
|
|
); |
185
|
|
|
|
|
|
|
} elsif (ref $value eq 'ARRAY') { |
186
|
0
|
|
|
|
|
0
|
$self->{'tags'}->put(@{$value}); |
|
0
|
|
|
|
|
0
|
|
187
|
|
|
|
|
|
|
} elsif (blessed($value) && $value->isa('Data::HTML::A')) { |
188
|
0
|
|
|
|
|
0
|
$self->_tags_a($value); |
189
|
|
|
|
|
|
|
} else { |
190
|
0
|
|
|
|
|
0
|
err 'Bad value object.'; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
5
|
|
|
|
|
124
|
return; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
__END__ |