line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
19591
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
2
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
79
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package |
5
|
|
|
|
|
|
|
XHTML::Instrumented::Form::Checkbox; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
9
|
use base 'XHTML::Instrumented::Form::Select'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
198
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Params::Validate qw (validate); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2954
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
14
|
0
|
|
|
|
|
|
my %p = validate(@_, { |
15
|
|
|
|
|
|
|
name => 1, |
16
|
|
|
|
|
|
|
type => 1, |
17
|
|
|
|
|
|
|
value => 0, |
18
|
|
|
|
|
|
|
required => 0, |
19
|
|
|
|
|
|
|
default => 0, |
20
|
|
|
|
|
|
|
values => 0, |
21
|
|
|
|
|
|
|
data => 0, |
22
|
|
|
|
|
|
|
}); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $data = $p{data}; |
25
|
0
|
|
|
|
|
|
delete $p{data}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $self = bless({ %p }, $class); |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
$self->set_select_data(@{$data}) if $data; |
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub args |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
37
|
0
|
|
|
|
|
|
my %hash = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if ($self->{type} eq 'select') { |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
0
|
|
|
|
|
if (my $count = $self->{id_count}) { |
42
|
0
|
0
|
|
|
|
|
if (my $value = $self->{control}->{args}->{value}) { |
|
|
0
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$hash{value} = $value; |
45
|
|
|
|
|
|
|
} elsif ($self->{values}) { |
46
|
0
|
|
|
|
|
|
die 'bob'; |
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
|
|
|
|
$hash{value} = $count; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} else { |
51
|
0
|
0
|
|
|
|
|
if (my $value = $hash{value}) { |
52
|
0
|
0
|
|
|
|
|
if ($self->{values}) { |
53
|
0
|
0
|
|
|
|
|
if (grep /$value/, @{$self->{values}}) { |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$hash{checked} = 'checked'; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
0
|
0
|
|
|
|
|
if ($self->{default}) { |
58
|
0
|
0
|
|
|
|
|
if (grep /$value/, @{$self->{default}}) { |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$hash{checked} = 'checked'; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} else { |
63
|
0
|
0
|
|
|
|
|
if (grep /on/, @{$self->{default}}) { |
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$hash{checked} = 'checked'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
$self->SUPER::args(%hash); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub expand_content |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
0
|
|
|
|
my $value = $self->{value} || $self->{default}; |
77
|
0
|
|
|
|
|
|
require XHTML::Instrumented::Entry; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
for my $option (@{$self->{data}}) { |
|
0
|
|
|
|
|
|
|
80
|
0
|
0
|
0
|
|
|
|
if ($self->{value} && $option->{value} |
|
|
|
0
|
|
|
|
|
81
|
|
|
|
|
|
|
&& $self->{value} eq $option->{value}) { |
82
|
0
|
|
|
|
|
|
$option->{selected} = 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my %values = map({ ($_ => 1); } @{$value}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my @ret = (); |
89
|
0
|
0
|
|
|
|
|
if ($self->{tag} eq 'select') { |
90
|
0
|
0
|
|
|
|
|
if (@{$self->{data}||[]}) { |
|
0
|
0
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
@ret = map({ XHTML::Instrumented::Entry->new( |
|
0
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
tag => 'option', |
93
|
|
|
|
|
|
|
flags => {}, |
94
|
|
|
|
|
|
|
args => { $_->as_args }, |
95
|
|
|
|
|
|
|
data => [ $_->{text} ], |
96
|
|
|
|
|
|
|
), |
97
|
0
|
|
|
|
|
|
} @{$self->{data}} |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
} else { |
100
|
0
|
|
|
|
|
|
for my $entry (@_) { |
101
|
0
|
0
|
|
|
|
|
if (ref($entry)) { |
102
|
0
|
|
|
|
|
|
my $entry_value = $entry->{args}{value}; |
103
|
|
|
|
|
|
|
|
104
|
0
|
0
|
|
|
|
|
if ($values{$entry_value}) { |
105
|
0
|
|
|
|
|
|
$entry->{args}{selected} = 'selected'; |
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
|
push(@ret, $entry); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
@ret; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub is_multi |
117
|
|
|
|
|
|
|
{ |
118
|
0
|
|
|
0
|
1
|
|
1; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub checked |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
124
|
0
|
|
|
|
|
|
die qq(fixme check boxes don't work.); |
125
|
0
|
|
|
|
|
|
0; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub set_default |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
131
|
0
|
|
|
|
|
|
my $value = shift; |
132
|
0
|
0
|
|
|
|
|
die if @_; |
133
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
if (my $type = ref($value)) { |
135
|
0
|
0
|
|
|
|
|
die unless $type eq 'ARRAY'; |
136
|
0
|
|
|
|
|
|
$self->{default} = $value; |
137
|
|
|
|
|
|
|
} else { |
138
|
0
|
|
|
|
|
|
$self->{default} = [ $value ]; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my %values = map({ ($_ => 1); } @{$self->{default}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
|
for my $element (@{$self->{data} || []}) { |
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
delete $element->{selected}; |
145
|
0
|
0
|
|
|
|
|
if ($values{$element->value}) { |
146
|
0
|
|
|
|
|
|
$element->{selected} = 1; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub set_value |
152
|
|
|
|
|
|
|
{ |
153
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
154
|
0
|
|
|
|
|
|
my $value = shift; |
155
|
0
|
0
|
|
|
|
|
die if @_; |
156
|
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
|
if (my $type = ref($value)) { |
158
|
0
|
0
|
|
|
|
|
die unless $type eq 'ARRAY'; |
159
|
0
|
|
|
|
|
|
$self->{value} = $value; |
160
|
|
|
|
|
|
|
} else { |
161
|
0
|
|
|
|
|
|
$self->{value} = [ $value ]; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
my %values = map({ ($_ => 1); } @{$self->{value}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
0
|
0
|
|
|
|
|
for my $element (@{$self->{data} || []}) { |
|
0
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
delete $element->{selected}; |
168
|
0
|
0
|
|
|
|
|
if ($values{$element->value}) { |
169
|
0
|
|
|
|
|
|
$element->{selected} = 1; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
175
|
|
|
|
|
|
|
__END__ |