line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Widget::Element::NullContainer; |
2
|
|
|
|
|
|
|
|
3
|
88
|
|
|
88
|
|
92445
|
use warnings; |
|
88
|
|
|
|
|
233
|
|
|
88
|
|
|
|
|
6924
|
|
4
|
88
|
|
|
88
|
|
535
|
use strict; |
|
88
|
|
|
|
|
364
|
|
|
88
|
|
|
|
|
4001
|
|
5
|
88
|
|
|
88
|
|
483
|
use base 'HTML::Widget::Element'; |
|
88
|
|
|
|
|
199
|
|
|
88
|
|
|
|
|
9233
|
|
6
|
88
|
|
|
88
|
|
525
|
use NEXT; |
|
88
|
|
|
|
|
211
|
|
|
88
|
|
|
|
|
688
|
|
7
|
88
|
|
|
88
|
|
2803
|
use Carp qw/croak/; |
|
88
|
|
|
|
|
198
|
|
|
88
|
|
|
|
|
116835
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/content/); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
*elem = \&element; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
HTML::Widget::Element::NullContainer - Null Container Element |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $e = $widget->element( 'NullContainer'); |
20
|
|
|
|
|
|
|
$e->element('Textfield', 'bar'); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
NullContainer Level Element. Base class for HTML::Widget::Element::Block |
25
|
|
|
|
|
|
|
May also be useful for canned subwidgets. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
See L for documentation of most methods. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Sets L to false, so that filters added |
34
|
|
|
|
|
|
|
by C<< $widget->filter_all >> won't be applied to Span elements. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Sets L to false, so that constraints |
37
|
|
|
|
|
|
|
added by C<< $widget->constraint_all >> won't be applied to Span elements. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
104
|
|
|
104
|
1
|
9224
|
my $self = shift->NEXT::new(@_); |
43
|
|
|
|
|
|
|
|
44
|
104
|
|
|
|
|
9441
|
$self->allow_filter(0)->allow_constraint(0)->content( [] ); |
45
|
|
|
|
|
|
|
|
46
|
104
|
|
|
|
|
3617
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 elem |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 element |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Arguments: $type, $name, \%attributes |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Return Value: $element |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
See L for details. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub element { |
62
|
22
|
|
|
22
|
1
|
242
|
my ( $self, $type, $name, $attrs ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
22
|
|
|
|
|
52
|
my $abs = $type =~ s/^\+//; |
65
|
22
|
50
|
|
|
|
75
|
$type = "HTML::Widget::Element::$type" unless $abs; |
66
|
|
|
|
|
|
|
|
67
|
22
|
|
|
|
|
147
|
my $element = HTML::Widget->_instantiate( $type, { name => $name } ); |
68
|
|
|
|
|
|
|
|
69
|
22
|
100
|
|
|
|
8255
|
$element->{_anonymous} = 1 if !defined $name; |
70
|
|
|
|
|
|
|
|
71
|
22
|
|
|
|
|
139
|
$self->push_content($element); |
72
|
|
|
|
|
|
|
|
73
|
22
|
100
|
|
|
|
204
|
if ( defined $attrs ) { |
74
|
1
|
|
|
|
|
3
|
eval { $element->attributes->{$_} = $attrs->{$_} for keys %$attrs; }; |
|
1
|
|
|
|
|
17
|
|
75
|
1
|
50
|
|
|
|
6
|
croak "attributes argument must be a hash-reference: $@" if $@; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
22
|
|
|
|
|
438
|
return $element; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 push_content |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub push_content { |
86
|
223
|
|
|
223
|
1
|
620
|
push @{ shift->content }, @_; |
|
223
|
|
|
|
|
1109
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 unshift_content |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub unshift_content { |
94
|
0
|
|
|
0
|
1
|
0
|
unshift @{ shift->content }, @_; |
|
0
|
|
|
|
|
0
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 containerize |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub containerize { |
102
|
3
|
|
|
3
|
1
|
7
|
my ( $self, $w, $value, $error, $args ) = @_; |
103
|
|
|
|
|
|
|
|
104
|
3
|
|
|
|
|
18
|
local $w->{attributes}->{id} = $self->id($w); |
105
|
|
|
|
|
|
|
|
106
|
3
|
|
|
|
|
15
|
my @content = $w->_containerize_elements( $self->content, $args ); |
107
|
|
|
|
|
|
|
|
108
|
3
|
|
|
|
|
18
|
return HTML::Widget::NullContainer->new( { |
109
|
|
|
|
|
|
|
passive => $self->passive, |
110
|
|
|
|
|
|
|
element => 1, |
111
|
|
|
|
|
|
|
content => \@content, |
112
|
|
|
|
|
|
|
name => $self->name, |
113
|
|
|
|
|
|
|
} ); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 id |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub id { |
121
|
144
|
|
|
144
|
1
|
360
|
my ( $self, $w ) = @_; |
122
|
144
|
100
|
|
|
|
716
|
return $w->name if $self->{_anonymous}; |
123
|
72
|
|
|
|
|
213
|
my $name = $self->name(); |
124
|
72
|
100
|
|
|
|
517
|
if ( $name =~ s/^_implicit_// ) { |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# $name is left set to the name of the |
127
|
|
|
|
|
|
|
# original parent widget of this element, as set by |
128
|
|
|
|
|
|
|
# H::W::_setup_implicit_subcontainer. |
129
|
|
|
|
|
|
|
} |
130
|
72
|
|
|
|
|
444
|
return $w->name . '_' . $name; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 get_elements |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub get_elements { |
138
|
7
|
|
|
7
|
1
|
9344
|
my ( $self, %opt ) = @_; |
139
|
|
|
|
|
|
|
|
140
|
7
|
|
|
|
|
31
|
return $self->_match_elements( $self->content, \%opt ); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 get_element |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub get_element { |
148
|
2
|
|
|
2
|
1
|
2697
|
my ( $self, %opt ) = @_; |
149
|
|
|
|
|
|
|
|
150
|
2
|
|
|
|
|
10
|
return ( $self->get_elements(%opt) )[0]; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 find_elements |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub find_elements { |
158
|
69
|
|
|
69
|
1
|
6006
|
my ( $self, %opt ) = @_; |
159
|
|
|
|
|
|
|
|
160
|
69
|
|
|
|
|
129
|
my @elements = ($self); |
161
|
69
|
|
|
|
|
86
|
push @elements, map { $_->find_elements(%opt) } @{ $self->content }; |
|
432
|
|
|
|
|
1566
|
|
|
69
|
|
|
|
|
201
|
|
162
|
|
|
|
|
|
|
|
163
|
69
|
|
|
|
|
289
|
return $self->_match_elements( \@elements, \%opt ); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub _match_elements { |
167
|
76
|
|
|
76
|
|
703
|
my ( $self, $elements, $opt ) = @_; |
168
|
|
|
|
|
|
|
|
169
|
76
|
100
|
|
|
|
323
|
if ( exists $opt->{type} ) { |
|
|
100
|
|
|
|
|
|
170
|
8
|
|
|
|
|
18
|
my $type = "HTML::Widget::Element::$opt->{type}"; |
171
|
|
|
|
|
|
|
|
172
|
8
|
|
|
|
|
15
|
return grep { $_->isa($type) } @$elements; |
|
27
|
|
|
|
|
176
|
|
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
elsif ( exists $opt->{name} ) { |
175
|
7
|
|
|
|
|
14
|
my $name = $opt->{name}; |
176
|
|
|
|
|
|
|
|
177
|
7
|
50
|
|
|
|
12
|
return grep { $_->name and $_->name eq $name } @$elements; |
|
19
|
|
|
|
|
186
|
|
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
61
|
|
|
|
|
398
|
return @$elements; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 prepare |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
See L |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub prepare { |
190
|
239
|
|
|
239
|
1
|
521
|
my ( $self, $w ) = @_; |
191
|
239
|
|
|
|
|
411
|
map { $_->prepare($w) } @{ $self->content }; |
|
490
|
|
|
|
|
3354
|
|
|
239
|
|
|
|
|
956
|
|
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 init |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
See L |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub init { |
201
|
97
|
|
|
97
|
1
|
271
|
my ( $self, $w ) = @_; |
202
|
97
|
|
|
|
|
216
|
for my $element ( @{ $self->content } ) { |
|
97
|
|
|
|
|
460
|
|
203
|
214
|
100
|
|
|
|
2197
|
$element->init($w) unless $element->{_initialized}; |
204
|
214
|
|
|
|
|
663
|
$element->{_initialized}++; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 process |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
See L |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub process { |
215
|
183
|
|
|
183
|
1
|
359
|
my ( $self, $params, $uploads ) = @_; |
216
|
183
|
|
|
|
|
296
|
my $errors; |
217
|
183
|
|
|
|
|
322
|
for my $element ( @{ $self->content } ) { |
|
183
|
|
|
|
|
669
|
|
218
|
344
|
|
|
|
|
2512
|
my $er = $element->process( $params, $uploads ); |
219
|
344
|
100
|
|
|
|
1188
|
push @$errors, @$er if $er; |
220
|
|
|
|
|
|
|
} |
221
|
183
|
|
|
|
|
636
|
return $errors; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 SEE ALSO |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
L |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 AUTHOR |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Michael Gray, C |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 LICENSE |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
235
|
|
|
|
|
|
|
the same terms as Perl itself. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=cut |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
package HTML::Widget::NullContainer; |
240
|
|
|
|
|
|
|
|
241
|
88
|
|
|
88
|
|
866
|
use warnings; |
|
88
|
|
|
|
|
190
|
|
|
88
|
|
|
|
|
2853
|
|
242
|
88
|
|
|
88
|
|
471
|
use strict; |
|
88
|
|
|
|
|
258
|
|
|
88
|
|
|
|
|
3029
|
|
243
|
88
|
|
|
88
|
|
510
|
use base 'HTML::Widget::Container'; |
|
88
|
|
|
|
|
198
|
|
|
88
|
|
|
|
|
14289
|
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/content/); |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub _build_element { |
248
|
3
|
|
|
3
|
|
20
|
my $self = shift; |
249
|
3
|
|
|
|
|
6
|
return ( map { $_->as_list } @{ $self->content } ); |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
15
|
|
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
1; |