| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CGI::Test::Form::Widget::Input::Text_Field; |
|
2
|
14
|
|
|
14
|
|
41
|
use strict; |
|
|
14
|
|
|
|
|
11
|
|
|
|
14
|
|
|
|
|
260
|
|
|
3
|
14
|
|
|
14
|
|
39
|
use warnings; |
|
|
14
|
|
|
|
|
24
|
|
|
|
14
|
|
|
|
|
241
|
|
|
4
|
|
|
|
|
|
|
################################################################## |
|
5
|
|
|
|
|
|
|
# $Id: Text_Field.pm 411 2011-09-26 11:19:30Z nohuhu@nohuhu.org $ |
|
6
|
|
|
|
|
|
|
# $Name: cgi-test_0-104_t1 $ |
|
7
|
|
|
|
|
|
|
################################################################## |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Copyright (c) 2001, Raphael Manfredi |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# You may redistribute only under the terms of the Artistic License, |
|
12
|
|
|
|
|
|
|
# as specified in the README file that comes with the distribution. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
|
|
15
|
14
|
|
|
14
|
|
30
|
use Carp; |
|
|
14
|
|
|
|
|
17
|
|
|
|
14
|
|
|
|
|
585
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# This class models a FORM text field. |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
|
|
21
|
14
|
|
|
14
|
|
42
|
use base qw(CGI::Test::Form::Widget::Input); |
|
|
14
|
|
|
|
|
14
|
|
|
|
14
|
|
|
|
|
4914
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# |
|
24
|
|
|
|
|
|
|
# %attr |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# Defines which HTML attributes we should look at within the node, and how |
|
27
|
|
|
|
|
|
|
# to translate that into class attributes. |
|
28
|
|
|
|
|
|
|
# |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %attr = ('name' => 'name', |
|
31
|
|
|
|
|
|
|
'value' => 'value', |
|
32
|
|
|
|
|
|
|
'size' => 'size', |
|
33
|
|
|
|
|
|
|
'maxlength' => 'max_length', |
|
34
|
|
|
|
|
|
|
'disabled' => 'is_disabled', |
|
35
|
|
|
|
|
|
|
'readonly' => 'is_read_only', |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
# ->_init |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
# Per-widget initialization routine. |
|
42
|
|
|
|
|
|
|
# Parse HTML node to determine our specific parameters. |
|
43
|
|
|
|
|
|
|
# |
|
44
|
|
|
|
|
|
|
sub _init |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
48
|
|
|
48
|
|
37
|
my $this = shift; |
|
47
|
48
|
|
|
|
|
60
|
my ($node) = shift; |
|
48
|
48
|
|
|
|
|
162
|
$this->_parse_attr($node, \%attr); |
|
49
|
48
|
|
|
|
|
48
|
return; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# |
|
53
|
|
|
|
|
|
|
# Attribute access |
|
54
|
|
|
|
|
|
|
# |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub size |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
0
|
|
|
0
|
1
|
0
|
$_[ 0 ]->{size}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub max_length |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
30
|
|
|
30
|
1
|
40
|
$_[ 0 ]->{max_length}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub gui_type |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
0
|
|
|
0
|
1
|
0
|
"text field" |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
# Redefined predicates |
|
73
|
|
|
|
|
|
|
# |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub is_field |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
0
|
|
|
0
|
1
|
0
|
1 |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# |
|
81
|
|
|
|
|
|
|
# Redefined routines |
|
82
|
|
|
|
|
|
|
# |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# |
|
85
|
|
|
|
|
|
|
# ->set_value -- redefined |
|
86
|
|
|
|
|
|
|
# |
|
87
|
|
|
|
|
|
|
# Ensure text is not larger than the maximum field length, by truncating |
|
88
|
|
|
|
|
|
|
# from the right. |
|
89
|
|
|
|
|
|
|
# |
|
90
|
|
|
|
|
|
|
sub set_value |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
30
|
|
|
30
|
1
|
28
|
my $this = shift; |
|
93
|
30
|
|
|
|
|
28
|
my ($value) = @_; |
|
94
|
|
|
|
|
|
|
|
|
95
|
30
|
|
|
|
|
66
|
my $maxlen = $this->max_length; |
|
96
|
30
|
50
|
33
|
|
|
130
|
$maxlen = 1 if defined $maxlen && $maxlen < 1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
30
|
50
|
33
|
|
|
100
|
if (defined $maxlen && length($value) > $maxlen) |
|
99
|
|
|
|
|
|
|
{ |
|
100
|
0
|
0
|
|
|
|
0
|
carp "truncating text to %d byte%s for %s '%s'", $maxlen, |
|
101
|
|
|
|
|
|
|
$maxlen == 1 ? "" : "s", $this->gui_type, $this->name; |
|
102
|
0
|
|
|
|
|
0
|
substr($value, $maxlen) = ''; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
30
|
|
|
|
|
92
|
$this->SUPER::set_value($value); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
CGI::Test::Form::Widget::Input::Text_Field - A text field |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# Inherits from CGI::Test::Form::Widget::Input |
|
117
|
|
|
|
|
|
|
# $form is a CGI::Test::Form |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $desc = $form->input_by_name("description"); |
|
120
|
|
|
|
|
|
|
$desc->replace("small and beautiful"); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This class models a single-line text field, where users can type text. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 INTERFACE |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The interface is the same as the one described in |
|
129
|
|
|
|
|
|
|
L, with the following additional attributes: |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item C |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The maximum allowed text length within the field. If not defined, it means |
|
136
|
|
|
|
|
|
|
the length is not limited. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item C |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The size of the displayed text field, in characters. The text held within |
|
141
|
|
|
|
|
|
|
the field can be much larger than that, however. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHORS |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The original author is Raphael Manfredi. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Steven Hilton was long time maintainer of this module. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Current maintainer is Alexander Tokarev Ftokarev@cpan.orgE>. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
CGI::Test::Form::Widget::Input(3). |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
|
158
|
|
|
|
|
|
|
|