adding missing field types

This commit is contained in:
JT Smith 2005-07-28 15:17:48 +00:00
parent 5e7b7b8414
commit e184f2c185
14 changed files with 1775 additions and 0 deletions

View file

@ -0,0 +1,156 @@
package WebGUI::Form::fieldType;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::Form::selectList;
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::fieldType
=head1 DESCRIPTION
Creates a form control that will allow you to select a form control type.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 size
Defaults to 1. How many characters tall should this control be represented.
=head4 types
An array reference containing the form control types to be selectable. Defaults to all available types.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
size=>{
defaultValue=>1
},
types=>{
defaultValue=>$class->getTypes
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("744","WebGUI");
}
#-------------------------------------------------------------------
=head2 getTypes ( )
A class method that returns an array reference of all the form control types present in the system.
=cut
sub getTypes {
my $class = shift;
opendir(DIR,$session{config}{webguiRoot}."/lib/WebGUI/Form/");
my @rawTypes = readdir(DIR);
closedir(DIR);
my @types;
foreach my $type (@rawTypes) {
if ($type =~ /^(.*)\.pm$/) {
next if ($1 eq "Control");
push(@types,$1);
}
}
return \@types;
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
Returns either what's posted or if nothing comes back it returns "text".
=cut
sub getValueFromPost {
my $self = shift;
return $session{cgi}->param($self->{name}) || "text";
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a question selector asking the user where they want to go.
=cut
sub toHtml {
my $self = shift;
my %options;
foreach my $type (@{$self->{types}}) {
my $class = "WebGUI::Form::".$type;
my $cmd = "use ".$class;
eval ($cmd);
if ($@) {
WebGUI::ErrorHandler::error("Couldn't compile form control: ".$type.". Root cause: ".$@);
next;
}
$options{$type} = $class->getName;
}
return WebGUI::Form::selectList->new(
name=>$self->{name},
options=>\%options,
value=>[$self->{value}],
extras=>$self->{extras},
size=>$self->{size}
)->toHtml;
}
1;

139
lib/WebGUI/Form/file.pm Normal file
View file

@ -0,0 +1,139 @@
package WebGUI::Form::text;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::text
=head1 DESCRIPTION
Creates a text input box form field.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 maxlength
Defaults to 255. Determines the maximum number of characters allowed in this field.
=head4 size
Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big of a text box to display.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
maxlength=>{
defaultValue=> 255
},
size=>{
defaultValue=>$session{setting}{textBoxSize} || 30
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("475","WebGUI");
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders an input tag of type text.
=cut
sub toHtml {
my $self = shift;
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
return '<input type="text" name="'.$self->{name}.'" value="'.$value.'" size="'.$self->{size}.'" maxlength="'.$self->{maxlength}.'" '.$self->{extras}.' />';
}
#-------------------------------------------------------------------
=head2 files ( hashRef )
Returns a multiple file upload control.
=head3 name
The name field for this form element.
=cut
sub files {
WebGUI::Style::setScript($session{config}{extrasURL}.'/FileUploadControl.js',{type=>"text/javascript"});
my $uploadControl = '<div id="fileUploadControl"> </div>
<script>
var images = new Array();
';
opendir(DIR,$session{config}{extrasPath}.'/fileIcons');
my @files = readdir(DIR);
closedir(DIR);
foreach my $file (@files) {
unless ($file eq "." || $file eq "..") {
my $ext = $file;
$ext =~ s/(.*?)\.gif/$1/;
$uploadControl .= 'images["'.$ext.'"] = "'.$session{config}{extrasURL}.'/fileIcons/'.$file.'";'."\n";
}
}
$uploadControl .= 'var uploader = new FileUploadControl("fileUploadControl", images, "'.WebGUI::International::get('removeLabel','WebGUI').'");
uploader.addRow();
</script>';
return $uploadControl;
}
1;

View file

@ -0,0 +1,134 @@
package WebGUI::Form::filterContent;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use Tie::IxHash;
use WebGUI::Form::selectList;
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::filterContent
=head1 DESCRIPTION
Creates a select list containing the content filter options. This is for use with WebGUI::HTML::filter().
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 name
The name of this field to be passed through the URI. Defaults to "filterContent".
=head4 hoverHelp
A tooltip for what to do with this field. Defaults to a general explaination of content filters.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
name=>{
defaultValue=>"filterContent"
},
hoverHelp=>{
defaultValue=>WebGUI::International::get('418 description')
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("418","WebGUI");
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
Returns either what's posted or if nothing comes back it returns "most".
=cut
sub getValueFromPost {
my $self = shift;
return $session{cgi}->param($self->{name}) || "most";
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Returns a select list containing the content filter options. This is for use with WebGUI::HTML::filter().
=cut
sub toHtml {
my $self = shift;
my %filter;
tie %filter, 'Tie::IxHash';
%filter = (
'none'=>WebGUI::International::get(420),
'macros'=>WebGUI::International::get(891),
'javascript'=>WebGUI::International::get(526),
'most'=>WebGUI::International::get(421),
'all'=>WebGUI::International::get(419)
);
return WebGUI::Form::selectList->new(
options=>\%filter,
name=>$self->{name},
value=>[$self->{value}],
extras=>$self->{extras},
defaultValue=>[$self->{defaultValue}]
)->toHtml;
}
1;

187
lib/WebGUI/Form/ldapLink.pm Normal file
View file

@ -0,0 +1,187 @@
package WebGUI::Form::ldapLink;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::LDAPLink;
use WebGUI::Form::selectList;
use WebGUI::Grouping;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::URL;
=head1 NAME
Package WebGUI::Form::ldapLink
=head1 DESCRIPTION
Creates an LDAP connection chooser control.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 name
The identifier for this field. Defaults to "ldapLinkId".
=head4 defaultValue
An LDAP link id. Defaults to "0", which is nothing.
=head4 afterEdit
A URL that will be acted upon after editing an LDAP link.
=head4 size
The number of characters tall this list should be. Defaults to '1'.
=head4 multiple
Boolean indicating whether the user can select multiple items from this list like a checkList. Defaults to "0".
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
name=>{
defaultValue=>"ldapLinkId"
},
defaultValue=>{
defaultValue=>[0]
},
size=>{
defaultValue=>1
},
multiple=>{
defaultValue=>0
},
afterEdit=>{
defaultValue=>undef
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("LDAPLink_1075","AuthLDAP");
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar.
=cut
sub getValueFromPost {
my $self = shift;
my @data = $session{cgi}->param($self->{name});
return wantarray ? @data : join("\n",@data);
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a database connection picker control.
=cut
sub toHtml {
my $self = shift;
return WebGUI::Form::selectList->new(
name=>$self->{name},
options=>WebGUI::LDAPLink::getList(),
value=>$self->{value},
multiple=>$self->{multiple},
size=>$self->{size},
extras=>$self->{extras}
)->toHtml;
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
return WebGUI::Form::hiddenList->new(
value=>$self->{value},
name=>$self->{name},
options=>WebGUI::LDAPLink::getList()
)->toHtmlAsHidden;
}
#-------------------------------------------------------------------
=head2 toHtmlWithWrapper ( )
Renders the form field to HTML as a table row complete with labels, subtext, hoverhelp, etc. Also adds manage and edit icons next to the field if the current user is in the admins group.
=cut
sub toHtmlWithWrapper {
my $self = shift;
if (WebGUI::Grouping::isInGroup(3)) {
my $subtext;
if ($self->{afterEdit}) {
$subtext = editIcon("op=editLDAPLink&amp;llid=".$self->{value}."&amp;afterEdit=".WebGUI::URL::escape($self->{afterEdit}));
}
$subtext .= manageIcon("op=listLDAPLinks");
$self->{subtext} = $subtext . $self->{subtext};
}
return $self->SUPER::toHtmlWithWrapper;
}
1;

105
lib/WebGUI/Form/password.pm Normal file
View file

@ -0,0 +1,105 @@
package WebGUI::Form::password;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::password
=head1 DESCRIPTION
Creates a password input box form field.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 maxlength
Defaults to 35. Determines the maximum number of characters allowed in this field.
=head4 size
Defaults to 30. Specifies how big of a text box to display.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
maxlength=>{
defaultValue=>35
},
size=>{
defaultValue=>30
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("51","WebGUI");
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders an input tag of type password.
=cut
sub toHtml {
my $self = shift;
return '<input type="password" name="'.$self->{name}.'" value="'.$self->fixQuotes($self->{value}).'" size="'.
$self->{size}.'" maxlength="'.$self->{maxLength}.'" '.$self->{extras}.' />';
}
1;

87
lib/WebGUI/Form/phone.pm Normal file
View file

@ -0,0 +1,87 @@
package WebGUI::Form::phone;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::text';
use WebGUI::International;
use WebGUI::Session;
use WebGUI::Style;
=head1 NAME
Package WebGUI::Form::phone
=head1 DESCRIPTION
Creates a telephone number field.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::text.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("944","WebGUI");
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
Returns a string filtered to allow only digits, spaces, and these special characters: + - ( ) or it will return undef it the number doesn't validate to those.
=cut
sub getValueFromPost {
my $self = shift;
my $value = $session{cgi}->param($self->{name});
if ($value =~ /^[\d\s\-\+\(\)]+$/) {
return $value;
}
return undef;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a phone number field.
=cut
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ type=>'text/javascript' });
$self->{extras} .= ' onkeyup="doInputCheck(this.form.'.$self->{name}.',\'0123456789-()+ \')" ';
return $self->SUPER::toHtml;
}
1;

98
lib/WebGUI/Form/radio.pm Normal file
View file

@ -0,0 +1,98 @@
package WebGUI::Form::radio;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::radio
=head1 DESCRIPTION
Creates a radio button form field.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 checked
Defaults to "0". Set to "1" if this field should be checked.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
checked=>{
defaultValue=> 0
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("radio","WebGUI");
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders and input tag of type radio.
=cut
sub toHtml {
my $self = shift;
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
my $checkedText = ' checked="checked"' if ($self->{checked});
return '<input type="radio" name="'.$self->{name}.'" value="'.$value.'"'.$checkedText.' '.$self->{extras}.' />';
}
1;

View file

@ -0,0 +1,122 @@
package WebGUI::Form::radioList;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::Form::radio;
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::radioList
=head1 DESCRIPTION
Creates a series of radio button form fields.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control. Also take a look ath WebGUI::Form::checkbox as this class creates a list of checkboxes.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 options
A hash reference containing key values that will be returned with the form post and displayable text pairs. Defaults to an empty hash reference.
=head4 vertical
Boolean representing whether the checklist should be represented vertically or horizontally. If set to "1" will be displayed vertically. Defaults to "0".
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
options=>{
defaultValue=>{}
},
vertical=>{
defaultValue=>0
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("942","WebGUI");
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a series of radio buttons.
=cut
sub toHtml {
my $self = shift;
my $output;
foreach my $key (keys %{$self->{options}}) {
my $checked = 0;
if ($self->{value} eq $key) {
$checked = 1;
}
$output .= WebGUI::Form::radio->new({
name=>$self->{name},
value=>$key,
extras=>$self->{extras},
checked=>$checked
})->toHtml;
$output .= ${$self->{options}}{$key};
if ($self->{vertical}) {
$output .= "<br />\n";
} else {
$output .= " &nbsp; &nbsp;\n";
}
}
return $output;
}
1;

View file

@ -0,0 +1,95 @@
package WebGUI::Form::readOnly;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::readOnly
=head1 DESCRIPTION
Prints out the value directly with no form control.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("read only","WebGUI");
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
Returns undef.
=cut
sub getValueFromPost {
return undef;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders the value.
=cut
sub toHtml {
my $self = shift;
return $self->{value};
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Outputs nothing.
=cut
sub toHtmlAsHidden {
return undef;
}
1;

141
lib/WebGUI/Form/template.pm Normal file
View file

@ -0,0 +1,141 @@
package WebGUI::Form::template;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::Asset::Template;
use WebGUI::Form::selectList;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::URL;
=head1 NAME
Package WebGUI::Form::template
=head1 DESCRIPTION
Creates a template chooser control.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 name
The identifier for this field. Defaults to "templateId".
=head4 namespace
The namespace for the list of templates to return. If this is omitted, all templates will be displayed.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
name=>{
defaultValue=>"templateId"
},
namespace=>{
defaultValue=>undef
},
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("template","Asset_Template");
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a database connection picker control.
=cut
sub toHtml {
my $self = shift;
my $templateList = WebGUI::Asset::Template->getList($self->{namespace});
#Remove entries from template list that the user does not have permission to view.
for my $assetId ( keys %{$templateList} ) {
my $asset = WebGUI::Asset::Template->new($assetId);
if (!$asset->canView($session{user}{userId})) {
delete $templateList->{$assetId};
}
}
return WebGUI::Form::selectList->new(
name=>$self->{name},
options=>$templateList,
value=>[$self->{value}],
extras=>$self->{extras}
)->toHtml;
}
#-------------------------------------------------------------------
=head2 toHtmlWithWrapper ( )
Renders the form field to HTML as a table row complete with labels, subtext, hoverhelp, etc. Also adds manage and edit icons next to the field if the current user is in the admins group.
=cut
sub toHtmlWithWrapper {
my $self = shift;
my $template = WebGUI::Asset::Template->new($self->{value});
if (defined $template && $template->canEdit) {
my $returnUrl;
if (exists $session{asset}) {
$returnUrl = "&proceed=goBackToPage&returnUrl=".WebGUI::URL::escape($session{asset}->getUrl);
}
my $buttons = editIcon("func=edit".$returnUrl,$template->get("url"));
$buttons .= manageIcon("func=manageAssets",$template->getParent->get("url"));
$self->{subtext} = $buttons . $self->{subtext};
}
return $self->SUPER::toHtmlWithWrapper;
}
1;

View file

@ -0,0 +1,145 @@
package WebGUI::Form::timeField;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::text';
use WebGUI::DateTime;
use WebGUI::Form::button;
use WebGUI::Form::hidden;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::Style;
=head1 NAME
Package WebGUI::Form::timeField
=head1 DESCRIPTION
Creates a time form field.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::text.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the superclass for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 maxlength
Defaults to 8. Determines the maximum number of characters allowed in this field.
=head4 size
Default to 8. Determines how many characters wide the field wlll be.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
maxlength=>{
defaultValue=>8
},
size=>{
defaultValue=>8
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("971","WebGUI");
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
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.
=cut
sub getValueFromPost {
my $self = shift;
return WebGUI::DateTime::timeToSeconds($session{cgi}->param($self->{name}))-($session{user}{timeOffset}*3600);
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a time field.
=cut
sub toHtml {
my $self = shift;
my $value = WebGUI::DateTime::secondsToTime($self->{value});
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ type=>'text/javascript' });
$self->{extras} .= ' onkeyup="doInputCheck(this.form.'.$self->{name}.',\'0123456789:\')"';
return $self->SUPER::toHtml
.WebGUI::Form::button->new(
extras=>'style="font-size: 8pt;" onClick="window.timeField = this.form.'.$self->{name}.';clockSet = window.open(\''.$session{config}{extrasURL}. '/timeChooser.html\',\'timeChooser\',\'WIDTH=230,HEIGHT=100\');return false"',
value=>WebGUI::International::get(970)
)->toHtml;
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Renders the field as a hidden field.
=cut
sub toHtmlAsHidden {
my $self = shift;
return WebGUI::Form::hidden->new(
name=>$self->{name},
value=>secondsToTime($self->{value})
)->toHtmlAsHidden;
}
1;

119
lib/WebGUI/Form/url.pm Normal file
View file

@ -0,0 +1,119 @@
package WebGUI::Form::url;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::text';
use WebGUI::International;
use WebGUI::Session;
use WebGUI::Style;
=head1 NAME
Package WebGUI::Form::url
=head1 DESCRIPTION
Creates a URL form field.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::text.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the superclass for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 maxlength
Defaults to 2048. Determines the maximum number of characters allowed in this field.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
maxlength=>{
defaultValue=> 2048
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("478","WebGUI");
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
Parses the posted value and tries to make corrections if necessary.
=cut
sub getValueFromPost {
my $self = shift;
my $value = $session{cgi}->param($self->{name});
if ($value =~ /mailto:/) {
return $value;
} elsif ($value =~ /^([A-Z0-9]+[._+-]?){1,}([A-Z0-9]+[_+-]?)+\@(([A-Z0-9]+[._-]?){1,}[A-Z0-9]+\.){1,}[A-Z]{2,4}$/i) {
return "mailto:".$value;
} elsif ($value =~ /^\// || $value =~ /:\/\// || $value =~ /^\^/) {
return $value;
}
return "http://".$value;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a URL field.
=cut
sub toHtml {
my $self = shift;
WebGUI::Style::setScript($session{config}{extrasURL}.'/addHTTP.js',{ type=>'text/javascript' });
$self->{extras} .= ' onBlur="addHTTP(this.form.'.$self->{name}.')"';
return $self->SUPER::toHtml;
}
1;

113
lib/WebGUI/Form/whatNext.pm Normal file
View file

@ -0,0 +1,113 @@
package WebGUI::Form::whatNext;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::Form::selectList;
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::whatNext
=head1 DESCRIPTION
Creates a what next question field. This is used to allow users direct the flow of forms from one page to another.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 name
The identifier for this field. Defaults to "proceed".
=head4 defaultValue
A database link id. Defaults to "0", which is the WebGUI database.
=head4 afterEdit
A URL that will be acted upon after editing a database link.
=head4 hoverHelp
A tooltip to tell the user what to do with the field. Defaults a standard piece of help for Database Links.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
name=>{
defaultValue=>"proceed"
},
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("744","WebGUI");
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a question selector asking the user where they want to go.
=cut
sub toHtml {
my $self = shift;
return WebGUI::Form::selectList->new(
name=>$self->{name},
options=>$self->{options},
value=>[$self->{value}],
extras=>$self->{extras}
)->toHtml;
}
1;

134
lib/WebGUI/Form/yesNo.pm Normal file
View file

@ -0,0 +1,134 @@
package WebGUI::Form::yesNo;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::Form::radio;
use WebGUI::International;
use WebGUI::Session;
=head1 NAME
Package WebGUI::Form::yesNo
=head1 DESCRIPTION
Creates a yes/no question field.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 defaultValue
Can be a 1 or 0. Defaults to 0 if no value is specified.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
defaultValue=>{
defaultValue=>0
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("482","WebGUI");
}
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
Returns either a 1 or 0 representing yes, no.
=cut
sub yesNo {
my $self = shift;
if ($session{cgi}->param($self->{name}) > 0) {
return 1;
}
return 0;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a yes/no question field.
=cut
sub toHtml {
my $self = shift;
my ($checkYes, $checkNo);
if ($self->{value}) {
$checkYes = 1;
} else {
$checkNo = 1;
}
my $output = WebGUI::Form::radio->new(
checked=>$checkYes,
name=>$self->{name},
value=>1,
extras=>$self->{extras}
)->toHtml;
$output .= WebGUI::International::get(138);
$output .= '&nbsp;&nbsp;&nbsp;';
$output .= WebGUI::Form::radio->new(
checked=>$checkNo,
name=>$self->{name},
value=>0,
extras=>$self->{extras}
)->toHtml;
$output .= WebGUI::International::get(139);
return $output;
}
1;