line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tags::HTML::Table::View; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
119093
|
use base qw(Tags::HTML); |
|
7
|
|
|
|
|
52
|
|
|
7
|
|
|
|
|
3564
|
|
4
|
7
|
|
|
7
|
|
79224
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
3406
|
|
5
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
1693
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
38
|
use Class::Utils qw(set_params split_params); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
296
|
|
8
|
7
|
|
|
7
|
|
38
|
use Error::Pure qw(err); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
237
|
|
9
|
7
|
|
|
7
|
|
3472
|
use List::MoreUtils qw(none); |
|
7
|
|
|
|
|
82111
|
|
|
7
|
|
|
|
|
47
|
|
10
|
7
|
|
|
7
|
|
7141
|
use Scalar::Util qw(blessed); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
6422
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.03; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constructor. |
15
|
|
|
|
|
|
|
sub new { |
16
|
10
|
|
|
10
|
1
|
16941
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create object. |
19
|
10
|
|
|
|
|
105
|
my ($object_params_ar, $other_params_ar) = split_params( |
20
|
|
|
|
|
|
|
['css_table', 'header'], @params); |
21
|
10
|
|
|
|
|
329
|
my $self = $class->SUPER::new(@{$other_params_ar}); |
|
10
|
|
|
|
|
61
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Main CSS class. |
24
|
10
|
|
|
|
|
378
|
$self->{'css_table'} = 'table'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Header is in first line. |
27
|
10
|
|
|
|
|
32
|
$self->{'header'} = 1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Process params. |
30
|
10
|
|
|
|
|
19
|
set_params($self, @{$object_params_ar}); |
|
10
|
|
|
|
|
31
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Object. |
33
|
10
|
|
|
|
|
129
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _cleanup { |
37
|
1
|
|
|
1
|
|
38
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
3
|
delete $self->{'_data'}; |
40
|
1
|
|
|
|
|
3
|
delete $self->{'_no_data'}; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
2
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _init { |
46
|
9
|
|
|
9
|
|
144
|
my ($self, $data_ar, $no_data_value) = @_; |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
21
|
$self->{'_data'} = $data_ar; |
49
|
9
|
|
|
|
|
20
|
$self->{'_no_data'} = $no_data_value; |
50
|
|
|
|
|
|
|
|
51
|
9
|
|
|
|
|
20
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Process 'Tags'. |
55
|
|
|
|
|
|
|
sub _process { |
56
|
8
|
|
|
8
|
|
751
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
8
|
100
|
|
|
|
43
|
if (! exists $self->{'_data'}) { |
59
|
1
|
|
|
|
|
3
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Main content. |
63
|
|
|
|
|
|
|
$self->{'tags'}->put( |
64
|
|
|
|
|
|
|
['b', 'table'], |
65
|
7
|
|
|
|
|
47
|
['a', 'class', $self->{'css_table'}], |
66
|
|
|
|
|
|
|
); |
67
|
7
|
|
|
|
|
519
|
my $columns_count = 0; |
68
|
7
|
100
|
|
|
|
21
|
if ($self->{'header'}) { |
69
|
3
|
|
|
|
|
14
|
$self->{'tags'}->put( |
70
|
|
|
|
|
|
|
['b', 'tr'], |
71
|
|
|
|
|
|
|
); |
72
|
3
|
|
|
|
|
105
|
my $header_ar = shift @{$self->{'_data'}}; |
|
3
|
|
|
|
|
8
|
|
73
|
3
|
|
|
|
|
5
|
foreach my $value (@{$header_ar}) { |
|
3
|
|
|
|
|
7
|
|
74
|
6
|
|
|
|
|
26
|
$self->{'tags'}->put( |
75
|
|
|
|
|
|
|
['b', 'th'], |
76
|
|
|
|
|
|
|
['d', $value], |
77
|
|
|
|
|
|
|
['e', 'th'], |
78
|
|
|
|
|
|
|
); |
79
|
6
|
|
|
|
|
507
|
$columns_count++; |
80
|
|
|
|
|
|
|
} |
81
|
3
|
|
|
|
|
13
|
$self->{'tags'}->put( |
82
|
|
|
|
|
|
|
['e', 'tr'], |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} else { |
85
|
4
|
|
|
|
|
7
|
$columns_count++; |
86
|
|
|
|
|
|
|
} |
87
|
7
|
|
|
|
|
119
|
foreach my $row_ar (@{$self->{'_data'}}) { |
|
7
|
|
|
|
|
18
|
|
88
|
6
|
|
|
|
|
19
|
$self->{'tags'}->put( |
89
|
|
|
|
|
|
|
['b', 'tr'], |
90
|
|
|
|
|
|
|
); |
91
|
6
|
|
|
|
|
204
|
foreach my $value (@{$row_ar}) { |
|
6
|
|
|
|
|
12
|
|
92
|
12
|
|
|
|
|
257
|
$self->{'tags'}->put( |
93
|
|
|
|
|
|
|
['b', 'td'], |
94
|
|
|
|
|
|
|
); |
95
|
12
|
|
|
|
|
419
|
$self->_value($value); |
96
|
10
|
|
|
|
|
31
|
$self->{'tags'}->put( |
97
|
|
|
|
|
|
|
['e', 'td'], |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
} |
100
|
4
|
|
|
|
|
152
|
$self->{'tags'}->put( |
101
|
|
|
|
|
|
|
['e', 'tr'], |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# No data row. |
106
|
5
|
100
|
66
|
|
|
154
|
if (! @{$self->{'_data'}} && defined $self->{'_no_data'}) { |
|
5
|
|
|
|
|
30
|
|
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
|
5
|
|
|
|
|
80
|
$self->{'tags'}->put( |
120
|
|
|
|
|
|
|
['e', 'table'], |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
5
|
|
|
|
|
184
|
return; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Process 'CSS::Struct'. |
127
|
|
|
|
|
|
|
sub _process_css { |
128
|
1
|
|
|
1
|
|
18
|
my $self = shift; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$self->{'css'}->put( |
131
|
|
|
|
|
|
|
['s', '.'.$self->{'css_table'}], |
132
|
|
|
|
|
|
|
['s', '.'.$self->{'css_table'}.' td'], |
133
|
|
|
|
|
|
|
['s', '.'.$self->{'css_table'}.' th'], |
134
|
|
|
|
|
|
|
['d', 'border', '1px solid #ddd'], |
135
|
|
|
|
|
|
|
['d', 'text-align', 'left'], |
136
|
|
|
|
|
|
|
['e'], |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
['s', '.'.$self->{'css_table'}], |
139
|
|
|
|
|
|
|
['d', 'border-collapse', 'collapse'], |
140
|
|
|
|
|
|
|
['d', 'width', '100%'], |
141
|
|
|
|
|
|
|
['e'], |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
['s', '.'.$self->{'css_table'}.' th'], |
144
|
1
|
|
|
|
|
45
|
['s', '.'.$self->{'css_table'}.' td'], |
145
|
|
|
|
|
|
|
['d', 'padding', '15px'], |
146
|
|
|
|
|
|
|
['e'], |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
395
|
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
|
|
|
|
|
|
|
$self->{'tags'}->put( |
166
|
0
|
|
|
|
|
0
|
['d', @{$value->data}], |
|
0
|
|
|
|
|
0
|
|
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
|
13
|
|
|
13
|
|
26
|
my ($self, $value) = @_; |
180
|
|
|
|
|
|
|
|
181
|
13
|
100
|
66
|
|
|
54
|
if (ref $value eq '') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
182
|
10
|
|
|
|
|
54
|
$self->{'tags'}->put( |
183
|
|
|
|
|
|
|
['d', $value], |
184
|
|
|
|
|
|
|
); |
185
|
|
|
|
|
|
|
} elsif (ref $value eq 'ARRAY') { |
186
|
1
|
|
|
|
|
3
|
$self->{'tags'}->put(@{$value}); |
|
1
|
|
|
|
|
3
|
|
187
|
|
|
|
|
|
|
} elsif (blessed($value) && $value->isa('Data::HTML::A')) { |
188
|
0
|
|
|
|
|
0
|
$self->_tags_a($value); |
189
|
|
|
|
|
|
|
} else { |
190
|
2
|
|
|
|
|
47
|
err 'Bad value object.'; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
11
|
|
|
|
|
283
|
return; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
__END__ |