line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tags::HTML::Table::View; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
109813
|
use base qw(Tags::HTML); |
|
7
|
|
|
|
|
60
|
|
|
7
|
|
|
|
|
3669
|
|
4
|
7
|
|
|
7
|
|
90950
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
1632
|
|
5
|
7
|
|
|
7
|
|
1834
|
use warnings; |
|
7
|
|
|
|
|
1509
|
|
|
7
|
|
|
|
|
218
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
38
|
use Class::Utils qw(set_params split_params); |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
312
|
|
8
|
7
|
|
|
7
|
|
37
|
use Error::Pure qw(err); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
248
|
|
9
|
7
|
|
|
7
|
|
3707
|
use List::MoreUtils qw(none); |
|
7
|
|
|
|
|
83795
|
|
|
7
|
|
|
|
|
43
|
|
10
|
7
|
|
|
7
|
|
7070
|
use Scalar::Util qw(blessed); |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
7034
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.02; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constructor. |
15
|
|
|
|
|
|
|
sub new { |
16
|
6
|
|
|
6
|
1
|
5015
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create object. |
19
|
6
|
|
|
|
|
51
|
my ($object_params_ar, $other_params_ar) = split_params( |
20
|
|
|
|
|
|
|
['css_table', 'header'], @params); |
21
|
6
|
|
|
|
|
165
|
my $self = $class->SUPER::new(@{$other_params_ar}); |
|
6
|
|
|
|
|
46
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Main CSS class. |
24
|
6
|
|
|
|
|
301
|
$self->{'css_table'} = 'table'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Header is in first line. |
27
|
6
|
|
|
|
|
13
|
$self->{'header'} = 1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Process params. |
30
|
6
|
|
|
|
|
16
|
set_params($self, @{$object_params_ar}); |
|
6
|
|
|
|
|
20
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Object. |
33
|
6
|
|
|
|
|
60
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _cleanup { |
37
|
1
|
|
|
1
|
|
28
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
4
|
delete $self->{'_data'}; |
40
|
1
|
|
|
|
|
2
|
delete $self->{'_no_data'}; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
3
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _init { |
46
|
5
|
|
|
5
|
|
88
|
my ($self, $data_ar, $no_data_value) = @_; |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
13
|
$self->{'_data'} = $data_ar; |
49
|
5
|
|
|
|
|
12
|
$self->{'_no_data'} = $no_data_value; |
50
|
|
|
|
|
|
|
|
51
|
5
|
|
|
|
|
11
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Process 'Tags'. |
55
|
|
|
|
|
|
|
sub _process { |
56
|
4
|
|
|
4
|
|
665
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
4
|
100
|
|
|
|
36
|
if (! exists $self->{'_data'}) { |
59
|
1
|
|
|
|
|
3
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Main content. |
63
|
|
|
|
|
|
|
$self->{'tags'}->put( |
64
|
|
|
|
|
|
|
['b', 'table'], |
65
|
3
|
|
|
|
|
23
|
['a', 'class', $self->{'css_table'}], |
66
|
|
|
|
|
|
|
); |
67
|
3
|
|
|
|
|
258
|
my $columns_count = 0; |
68
|
3
|
50
|
|
|
|
10
|
if ($self->{'header'}) { |
69
|
3
|
|
|
|
|
43
|
$self->{'tags'}->put( |
70
|
|
|
|
|
|
|
['b', 'tr'], |
71
|
|
|
|
|
|
|
); |
72
|
3
|
|
|
|
|
109
|
my $header_ar = shift @{$self->{'_data'}}; |
|
3
|
|
|
|
|
17
|
|
73
|
3
|
|
|
|
|
6
|
foreach my $value (@{$header_ar}) { |
|
3
|
|
|
|
|
5
|
|
74
|
6
|
|
|
|
|
30
|
$self->{'tags'}->put( |
75
|
|
|
|
|
|
|
['b', 'th'], |
76
|
|
|
|
|
|
|
['d', $value], |
77
|
|
|
|
|
|
|
['e', 'th'], |
78
|
|
|
|
|
|
|
); |
79
|
6
|
|
|
|
|
549
|
$columns_count++; |
80
|
|
|
|
|
|
|
} |
81
|
3
|
|
|
|
|
11
|
$self->{'tags'}->put( |
82
|
|
|
|
|
|
|
['e', 'tr'], |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} else { |
85
|
0
|
|
|
|
|
0
|
$columns_count++; |
86
|
|
|
|
|
|
|
} |
87
|
3
|
|
|
|
|
107
|
foreach my $row_ar (@{$self->{'_data'}}) { |
|
3
|
|
|
|
|
9
|
|
88
|
2
|
|
|
|
|
8
|
$self->{'tags'}->put( |
89
|
|
|
|
|
|
|
['b', 'tr'], |
90
|
|
|
|
|
|
|
); |
91
|
2
|
|
|
|
|
68
|
foreach my $value (@{$row_ar}) { |
|
2
|
|
|
|
|
13
|
|
92
|
4
|
|
|
|
|
83
|
$self->{'tags'}->put( |
93
|
|
|
|
|
|
|
['b', 'td'], |
94
|
|
|
|
|
|
|
); |
95
|
4
|
|
|
|
|
152
|
$self->_value($value); |
96
|
4
|
|
|
|
|
16
|
$self->{'tags'}->put( |
97
|
|
|
|
|
|
|
['e', 'td'], |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
} |
100
|
2
|
|
|
|
|
75
|
$self->{'tags'}->put( |
101
|
|
|
|
|
|
|
['e', 'tr'], |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# No data row. |
106
|
3
|
100
|
66
|
|
|
73
|
if (! @{$self->{'_data'}} && defined $self->{'_no_data'}) { |
|
3
|
|
|
|
|
22
|
|
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
|
|
|
|
|
12
|
$self->{'tags'}->put( |
114
|
|
|
|
|
|
|
['e', 'td'], |
115
|
|
|
|
|
|
|
['e', 'tr'], |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
3
|
|
|
|
|
75
|
$self->{'tags'}->put( |
120
|
|
|
|
|
|
|
['e', 'table'], |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
3
|
|
|
|
|
106
|
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
|
|
|
|
|
37
|
['s', '.'.$self->{'css_table'}.' td'], |
145
|
|
|
|
|
|
|
['d', 'padding', '15px'], |
146
|
|
|
|
|
|
|
['e'], |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
393
|
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
|
|
28
|
my ($self, $value) = @_; |
180
|
|
|
|
|
|
|
|
181
|
5
|
50
|
0
|
|
|
25
|
if (ref $value eq '') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
182
|
5
|
|
|
|
|
20
|
$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
|
|
|
|
|
129
|
return; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
__END__ |