added most of the rest of the form controls
This commit is contained in:
parent
ce6ee697f9
commit
b86148acaa
12 changed files with 35 additions and 1870 deletions
|
|
@ -44,9 +44,6 @@ These functions are available from this package:
|
|||
|
||||
=cut
|
||||
|
||||
sub _checkEmailAddy {
|
||||
return ($_[0] =~ /^([A-Z0-9]+[._+-]?){1,}([A-Z0-9]+[_+-]?)+\@(([A-Z0-9]+[._-]?){1,}[A-Z0-9]+\.){1,}[A-Z]{2,4}$/i);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -70,76 +67,6 @@ sub AUTOLOAD {
|
|||
return $class->new({name=>$fieldName})->getValueFromPost;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 fieldType ( name )
|
||||
|
||||
Returns a field type. Defaults to "text".
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub fieldType {
|
||||
return ($session{form}{$_[0]} || "text");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 filterContent ( name )
|
||||
|
||||
Returns a scalar filter type. Defaults to "most".
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub filterContent {
|
||||
return ($session{form}{$_[0]} || "most");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 password ( name )
|
||||
|
||||
Returns a string.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub password {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 phone ( name )
|
||||
|
||||
Returns a string filtered to allow only digits, spaces, and these special characters: + - ( )
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub phone {
|
||||
if ($session{form}{$_[0]} =~ /^[\d\s\-\+\(\)]+$/) {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -180,128 +107,5 @@ sub process {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 radio ( name )
|
||||
|
||||
Returns a string.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub radio {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 radioList ( name )
|
||||
|
||||
Returns a string.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub radioList {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 template ( name )
|
||||
|
||||
Returns a template id. Defaults to "1".
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub template {
|
||||
if (exists $session{form}{$_[0]}) {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 timeField ( name )
|
||||
|
||||
Returns the number of seconds since 00:00:00 on a 24 hour clock. Note, this will adjust for the user's time offset in the reverse manner that the form field
|
||||
adjusts for it in order to make the times come out appropriately.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub timeField {
|
||||
return WebGUI::DateTime::timeToSeconds($session{form}{$_[0]})-($session{user}{timeOffset}*3600);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 url ( name )
|
||||
|
||||
Returns a URL.
|
||||
|
||||
=head3 name
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub url {
|
||||
if ($session{form}{$_[0]} =~ /mailto:/) {
|
||||
return $session{form}{$_[0]};
|
||||
} elsif (_checkEmailAddy($session{form}{$_[0]})) {
|
||||
return "mailto:".$session{form}{$_[0]};
|
||||
} elsif ($session{form}{$_[0]} =~ /^\// || $session{form}{$_[0]} =~ /:\/\// || $session{form}{$_[0]} =~ /^\^/) {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
return "http://".$session{form}{$_[0]};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 yesNo ( name )
|
||||
|
||||
Returns either a 1 or 0 or undef representing yes, no, and undefined. Defaults to "0".
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub yesNo {
|
||||
if ($session{form}{$_[0]} > 0) {
|
||||
return 1;
|
||||
}
|
||||
elsif ($session{form}{$_[0]} eq "") {
|
||||
return undef;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue