line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Menu::Select;
|
2
|
11
|
|
|
11
|
|
408413
|
use 5.004;
|
|
11
|
|
|
|
|
46
|
|
|
11
|
|
|
|
|
500
|
|
3
|
11
|
|
|
11
|
|
120
|
use strict;
|
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
567
|
|
4
|
11
|
|
|
11
|
|
65
|
use Carp 'carp';
|
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
24542
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.01';
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter;
|
9
|
|
|
|
|
|
|
our @ISA = qw( Exporter );
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(
|
12
|
|
|
|
|
|
|
options menu popup_menu
|
13
|
|
|
|
|
|
|
);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK );
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @KNOWN_KEYS = qw(
|
18
|
|
|
|
|
|
|
name value values default defaults labels attributes size multiple override );
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
8
|
|
|
8
|
1
|
15093
|
sub popup_menu { &menu };
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub menu {
|
24
|
15
|
100
|
|
15
|
1
|
85125
|
my %arg = (ref $_[0]) ? %{$_[0]} : @_;
|
|
4
|
|
|
|
|
95
|
|
25
|
15
|
|
|
|
|
34
|
my $html = '';
|
26
|
|
|
|
|
|
|
|
27
|
15
|
100
|
|
|
|
63
|
$arg{name} = '' if not exists $arg{name};
|
28
|
|
|
|
|
|
|
|
29
|
15
|
|
|
|
|
66
|
$html = sprintf ' |
30
|
|
|
|
|
|
|
|
31
|
15
|
|
|
|
|
11847
|
for my $key (keys %arg) {
|
32
|
39
|
100
|
|
|
|
116
|
if (! grep {$key eq $_} @KNOWN_KEYS) {
|
|
390
|
|
|
|
|
672
|
|
33
|
9
|
|
|
|
|
30
|
$html .= sprintf ' %s="%s"', $key, _escapeHTML( $arg{$key} );
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
|
37
|
15
|
|
|
|
|
37
|
$html .= ">\n";
|
38
|
15
|
|
|
|
|
53
|
$html .= options(%arg);
|
39
|
15
|
|
|
|
|
32
|
$html .= "\n";
|
40
|
|
|
|
|
|
|
|
41
|
15
|
|
|
|
|
64
|
return $html;
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub options {
|
46
|
39
|
50
|
|
39
|
1
|
18130
|
my %arg = (ref $_[0]) ? %{$_[0]} : @_;
|
|
0
|
|
|
|
|
0
|
|
47
|
39
|
|
|
|
|
67
|
my $html = '';
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# aliases
|
50
|
39
|
|
|
|
|
86
|
for (qw/ value default /) {
|
51
|
78
|
100
|
|
|
|
276
|
$arg{$_} = $arg{"${_}s"}
|
52
|
|
|
|
|
|
|
if exists $arg{"${_}s"};
|
53
|
|
|
|
|
|
|
|
54
|
78
|
100
|
100
|
|
|
473
|
$arg{$_} = [$arg{$_}]
|
55
|
|
|
|
|
|
|
if exists $arg{$_} && ! ref $arg{$_};
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# don't support CGI.pm's 'override' argument
|
59
|
39
|
50
|
|
|
|
117
|
if (exists $arg{override}) {
|
60
|
0
|
|
|
|
|
0
|
carp "CGI.pm's 'override' argument is not supported by HTML::Menu::Select";
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
|
63
|
39
|
|
|
|
|
57
|
for my $option (@{ $arg{value} }) {
|
|
39
|
|
|
|
|
104
|
|
64
|
61
|
|
|
|
|
97
|
$html .= ' |
65
|
|
|
|
|
|
|
|
66
|
61
|
|
|
|
|
76
|
for my $default (@{ $arg{default} }) {
|
|
61
|
|
|
|
|
162
|
|
67
|
47
|
100
|
|
|
|
142
|
if ($option eq $default) {
|
68
|
22
|
|
|
|
|
58
|
$html .= 'selected="selected" ';
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
61
|
|
|
|
|
94
|
for my $att (keys %{ $arg{attributes} }) {
|
|
61
|
|
|
|
|
290
|
|
73
|
9
|
100
|
|
|
|
33
|
if ($att eq $option) {
|
74
|
5
|
|
|
|
|
6
|
for (keys %{ $arg{attributes}{$att} }) {
|
|
5
|
|
|
|
|
16
|
|
75
|
5
|
|
|
|
|
20
|
$html .= sprintf '%s="%s" ',
|
76
|
|
|
|
|
|
|
$_,
|
77
|
|
|
|
|
|
|
_escapeHTML( $arg{attributes}{$att}{$_} );
|
78
|
|
|
|
|
|
|
}
|
79
|
|
|
|
|
|
|
}
|
80
|
|
|
|
|
|
|
}
|
81
|
|
|
|
|
|
|
|
82
|
61
|
|
|
|
|
170
|
$html .= sprintf 'value="%s">', _escapeHTML( $option );
|
83
|
|
|
|
|
|
|
|
84
|
61
|
100
|
100
|
|
|
343
|
if (exists $arg{labels} && exists $arg{labels}{$option}) {
|
85
|
12
|
|
|
|
|
31
|
$html .= _escapeHTML( $arg{labels}{$option} );
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
else {
|
88
|
49
|
|
|
|
|
98
|
$html .= _escapeHTML( $option );
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
61
|
|
|
|
|
171
|
$html .= '';
|
92
|
61
|
|
|
|
|
127
|
$html .= "\n";
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
|
95
|
39
|
|
|
|
|
186
|
return $html;
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _escapeHTML {
|
100
|
151
|
|
|
151
|
|
228
|
my ($escape) = (@_);
|
101
|
|
|
|
|
|
|
|
102
|
151
|
50
|
|
|
|
335
|
return unless defined $escape;
|
103
|
|
|
|
|
|
|
|
104
|
151
|
100
|
|
|
|
727
|
if (exists $::INC{'CGI.pm'}) {
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
105
|
3
|
|
|
|
|
149
|
return CGI::escapeHTML( $escape );
|
106
|
|
|
|
|
|
|
}
|
107
|
|
|
|
|
|
|
elsif (exists $::INC{'CGI/Simple/Util.pm'}) {
|
108
|
0
|
|
|
|
|
0
|
return CGI::Simple::Util::escapeHTML( $escape );
|
109
|
|
|
|
|
|
|
}
|
110
|
|
|
|
|
|
|
elsif (exists $::INC{'HTML/Entities.pm'}) {
|
111
|
3
|
|
|
|
|
9
|
return HTML::Entities::encode_entities( $escape );
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
elsif (exists $::INC{'Apache/Util.pm'}) {
|
114
|
0
|
|
|
|
|
0
|
return Apache::Util::escape_html( $escape );
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# looks like nothing's already loaded to do it for us
|
118
|
145
|
|
|
|
|
239
|
$escape =~ s/&/&/gs;
|
119
|
145
|
|
|
|
|
252
|
$escape =~ s/</gs;
|
120
|
145
|
|
|
|
|
207
|
$escape =~ s/>/>/gs;
|
121
|
145
|
|
|
|
|
163
|
$escape =~ s/"/"/gs;
|
122
|
|
|
|
|
|
|
|
123
|
145
|
|
|
|
|
491
|
return $escape;
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1;
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__
|