line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::HTMLx::Form::Field::Autocomplete; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
37908
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
114
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use base qw( Rose::HTML::Form::Field::Text ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1244
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
277497
|
use Rose::Object::MakeMethods::Generic (scalar => [qw( autocomplete limit )]); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub url |
14
|
|
|
|
|
|
|
{ |
15
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
16
|
0
|
0
|
|
|
|
|
my $u = $self->autocomplete or croak "no autocomplete URL set"; |
17
|
0
|
|
0
|
|
|
|
my $n = $self->name || $self->local_name; |
18
|
0
|
|
0
|
|
|
|
my $l = $self->limit || 30; |
19
|
0
|
|
|
|
|
|
return [$u, {c => $n, l => $l}]; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# borrowed from TT::Plugin::URL |
23
|
|
|
|
|
|
|
sub url_as_string |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my $url = $self->url; |
27
|
0
|
|
|
|
|
|
my $args = $url->[1]; |
28
|
0
|
|
|
|
|
|
my $esc = join('&', |
29
|
0
|
0
|
|
|
|
|
map { _url_args($_, $args->{$_}) } |
30
|
0
|
|
|
|
|
|
grep { defined $args->{$_} && length $args->{$_} } |
31
|
|
|
|
|
|
|
sort keys %$args); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $url->[0] . '?' . $esc; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# borrowed from TT::Plugin::URL |
37
|
|
|
|
|
|
|
sub _url_args |
38
|
|
|
|
|
|
|
{ |
39
|
0
|
|
|
0
|
|
|
my ($key, $val) = @_; |
40
|
0
|
|
|
|
|
|
$key = _escape($key); |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
return map { "$key=" . _escape($_); } ref $val eq 'ARRAY' ? @$val : $val; |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# borrowed from TT::Plugin::URL, which borrowed froM CGI.pm |
46
|
|
|
|
|
|
|
sub _escape |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
|
|
my $toencode = shift; |
49
|
0
|
0
|
|
|
|
|
return undef unless defined($toencode); |
50
|
0
|
|
|
|
|
|
$toencode =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; |
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $toencode; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |