/usr/share/perl5/CGI/Test/Form/Widget/Input.pm is in libcgi-test-perl 1.111-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | package CGI::Test::Form::Widget::Input;
use strict;
use warnings;
##################################################################
# $Id: Input.pm 411 2011-09-26 11:19:30Z nohuhu@nohuhu.org $
# $Name: cgi-test_0-104_t1 $
##################################################################
#
# Copyright (c) 2001, Raphael Manfredi
#
# You may redistribute only under the terms of the Artistic License,
# as specified in the README file that comes with the distribution.
#
use Carp;
#
# This class models a FORM input field.
# It factorizes the interface of our heirs: Text_Area and Text_Field
#
use base qw(CGI::Test::Form::Widget);
#
# ->_is_successful -- defined
#
# Is the enabled widget "successful", according to W3C's specs?
# Any input is.
#
sub _is_successful
{
my $this = shift;
return 1;
}
#
# Editing shortcuts
#
# The set_value() routine from the Widget class is protected against
# disabled and read-only fields, so don't duplicate checks within these
# shortcut routines.
#
# All are obvious, excepted filter perhaps, which runs a filtering subroutine
# on the field's value, preset in $_:
#
# $i->filter(sub { s/this/that/ });
#
# In the traditional Perl way...
#
sub prepend
{
my $this = shift;
my $prepend = shift;
$this->set_value($prepend . $this->value());
}
sub append
{
my $this = shift;
my $append = shift;
$this->set_value($this->value() . $append);
}
sub replace
{
my $this = shift;
my $new_value = shift;
$this->set_value($new_value);
}
sub clear
{
my $this = shift;
$this->set_value('');
}
sub filter
{
my $this = shift;
my $filter = shift;
local $_ = $this->value();
&{$filter};
$this->set_value($_);
}
#
# Attribute access
#
sub is_read_only
{
my $this = shift;
return $this->{is_read_only};
}
#
# High-level classification predicates
#
sub is_input
{
return 1;
}
#
# Predicates for the Input hierarchy
#
sub is_field
{
return 0;
}
sub is_area
{
return 0;
}
sub is_password
{
return 0;
}
sub is_file
{
return 0;
}
1;
=head1 NAME
CGI::Test::Form::Widget::Input - Abstract representation of an input field
=head1 SYNOPSIS
# Inherits from CGI::Test::Form::Widget
=head1 DESCRIPTION
This class is the abstract representation of a text input field, i.e. a
text field, a password field, a file upload field or a text area.
To simulate user input in those fields, there are a set of routines to
C<prepend()>, C<append()>, C<replace()>, C<clear()> or even run existing text
through C<filter()>.
=head1 INTERFACE
The interface is the same as the one described in L<CGI::Test::Form::Widget>,
with the following additions:
=head2 Attribute Setting
There are a number of convenience routines that are wrappers on C<set_value()>:
=over 4
=item C<append> I<string>
Appends the I<string> text to the existing text.
=item C<clear>
Clears existing text.
=item C<filter> I<filter_routine>
Runs existing text through the given I<filter_routine>. The C<$_> variable
is set to the whole text value, and is made available to the filter.
Hence you may write:
$input->filter(sub { s/this/that/g });
to replace all instances of C<this> by C<that> within the input text.
=item C<prepend> I<string>
Prepends the I<string> text to the existing text.
=item C<replace> I<string>
Replaces the existing text with I<string>.
=back
=head2 Widget Classification Predicates
There are additional predicates to distinguish between the various
input fields:
=over 4
=item C<is_area>
Returns I<true> for a text area.
=item C<is_field>
Returns I<true> for a pure text field.
=item C<is_file>
Returns I<true> for a file upload field (text field with browser support for
file selection).
=item C<is_password>
Returns I<true> for a password field (text field with input masked by GUI).
=back
=head1 AUTHORS
The original author is Raphael Manfredi.
Steven Hilton was long time maintainer of this module.
Current maintainer is Alexander Tokarev F<E<lt>tokarev@cpan.orgE<gt>>.
=head1 SEE ALSO
CGI::Test::Form::Widget(3),
CGI::Test::Form::Widget::Input::File(3),
CGI::Test::Form::Widget::Input::Password(3),
CGI::Test::Form::Widget::Input::Text_Area(3),
CGI::Test::Form::Widget::Input::Text_Field(3).
=cut
|