fixed a couple syntax errors
This commit is contained in:
parent
b58c87f1a9
commit
8cba918d7f
1 changed files with 68 additions and 10 deletions
|
|
@ -17,6 +17,7 @@ package WebGUI::FormProcessor;
|
|||
use strict;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -79,6 +80,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub checkbox {
|
||||
return selectList($_[0]);
|
||||
}
|
||||
|
|
@ -98,6 +101,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub checkboxList {
|
||||
return selectList($_[0]);
|
||||
}
|
||||
|
|
@ -117,6 +122,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub combo {
|
||||
if ($session{form}{$_[0]."_new"}) {
|
||||
return $session{form}{$_[0]."_new"};
|
||||
|
|
@ -139,6 +146,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub date {
|
||||
return WebGUI::DateTime::setToEpoch($session{form}{$_[0]});
|
||||
}
|
||||
|
|
@ -158,6 +167,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub dateTime {
|
||||
return (date($_[0]."_date")+time($_[0]."_time"));
|
||||
}
|
||||
|
|
@ -177,6 +188,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub email {
|
||||
if ($session{form}{$_[0]} =~ /^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/i) {
|
||||
return $session{form}{$_[0]};
|
||||
|
|
@ -199,6 +212,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub fieldType {
|
||||
return (selectList($_[0]) || "text");
|
||||
}
|
||||
|
|
@ -218,6 +233,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub filter {
|
||||
return ($session{form}{$_[0]} || "most");
|
||||
}
|
||||
|
|
@ -237,6 +254,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub float {
|
||||
if ($session{form}{$_[0]} =~ /^[\d\.\-]+$/) {
|
||||
return $session{form}{$_[0]};
|
||||
|
|
@ -259,6 +278,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub hidden {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
|
@ -278,6 +299,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub hiddenList {
|
||||
return selectList($_[0]);
|
||||
}
|
||||
|
|
@ -297,6 +320,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub HTMLArea {
|
||||
return WebGUI::HTML::cleanSegment($session{form}{$_[0]});
|
||||
}
|
||||
|
|
@ -316,6 +341,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub integer {
|
||||
if ($session{form}{$_[0]} =~ /^[\d\-]+$/) {
|
||||
return $session{form}{$_[0]};
|
||||
|
|
@ -338,6 +365,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub interval {
|
||||
return (WebGUI::DateTime::intervalToSeconds($session{form}{$_[0]."_interval"},$session{form}{$_[0]."_units"}) || 0);
|
||||
}
|
||||
|
|
@ -357,6 +386,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub password {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
|
@ -376,6 +407,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub phone {
|
||||
if ($session{form}{$_[0]} =~ /^[\d\s\-\+\(\)]+$/) {
|
||||
return $session{form}{$_[0]};
|
||||
|
|
@ -388,7 +421,7 @@ sub phone {
|
|||
|
||||
=head2 process ( name, type [ , default ] )
|
||||
|
||||
Returns whatever would be the expected result of the method type that was specified.
|
||||
Returns whatever would be the expected result of the method type that was specified. This method also checks to make sure that the field is not returning a string filled with nothing but whitespace.
|
||||
|
||||
=over
|
||||
|
||||
|
|
@ -406,12 +439,20 @@ The default value for this variable. If the variable is undefined then the defau
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($name, $type, $default) = @_;
|
||||
my $value;
|
||||
if (exists $session{form}{$name}) {
|
||||
return &$type($name);
|
||||
}
|
||||
return $default;
|
||||
$value = &$type($name);
|
||||
} else {
|
||||
$value = $default;
|
||||
}
|
||||
if ($value =~ /^[\s]+$/) {
|
||||
return undef;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -429,6 +470,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub radio {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
|
@ -448,6 +491,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub radioList {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
|
@ -457,7 +502,7 @@ sub radioList {
|
|||
|
||||
=head2 selectList ( name )
|
||||
|
||||
Returns either an array or a scalar depending upon what you request.
|
||||
Returns an array or a string depending upon which you request.
|
||||
|
||||
=over
|
||||
|
||||
|
|
@ -467,12 +512,10 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub selectList {
|
||||
my @array = $session{cgi}->param($_[0]);
|
||||
if ($#array) {
|
||||
return = \@array;
|
||||
}
|
||||
return $session{form}{$_[0]};
|
||||
return $session{cgi}->param($_[0]);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -490,6 +533,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub template {
|
||||
if ($session{form}{$_[0]} =~ /^\d+$/) {
|
||||
return $session{form}{$_[0]};
|
||||
|
|
@ -512,6 +557,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub text {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
|
@ -531,6 +578,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub textarea {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
|
@ -550,6 +599,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub time {
|
||||
return WebGUI::DateTime::timeToEpoch($session{form}{$_[0]});
|
||||
}
|
||||
|
|
@ -569,6 +620,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub url {
|
||||
if ($session{form}{$_[0]} =~ /^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/i) {
|
||||
if ($session{form}{$_[0]} =~ /mailto:/) {
|
||||
|
|
@ -596,6 +649,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub yesNo {
|
||||
if ($session{form}{$_[0]} > 0) {
|
||||
return 1;
|
||||
|
|
@ -618,6 +673,8 @@ The name of the form variable to retrieve.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub zipcode {
|
||||
if ($session{form}{$_[0]} =~ /^[A-Z\d\s\-]+$/) {
|
||||
return $session{form}{$_[0]};
|
||||
|
|
@ -626,5 +683,6 @@ sub zipcode {
|
|||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue