From b86148acaa7c5b1faaf7c2d5679166c8228ea9f3 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 27 Jul 2005 23:03:46 +0000 Subject: [PATCH] added most of the rest of the form controls --- lib/WebGUI/Asset/Wobject/DataForm.pm | 3 +- lib/WebGUI/Form.pm | 654 ---------------- lib/WebGUI/Form/Control.pm | 4 +- lib/WebGUI/Form/checkbox.pm | 2 +- lib/WebGUI/Form/databaseLink.pm | 16 +- lib/WebGUI/Form/group.pm | 5 +- lib/WebGUI/Form/interval.pm | 2 +- lib/WebGUI/Form/zipcode.pm | 2 +- lib/WebGUI/FormProcessor.pm | 196 ----- lib/WebGUI/HTMLForm.pm | 995 ------------------------ lib/WebGUI/Operation/ProfileSettings.pm | 3 +- lib/WebGUI/i18n/English/WebGUI.pm | 23 +- 12 files changed, 35 insertions(+), 1870 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/DataForm.pm b/lib/WebGUI/Asset/Wobject/DataForm.pm index b8436fca1..2ee36f84b 100644 --- a/lib/WebGUI/Asset/Wobject/DataForm.pm +++ b/lib/WebGUI/Asset/Wobject/DataForm.pm @@ -815,7 +815,8 @@ sub www_editField { -name=>"type", -label=>WebGUI::International::get(23,"Asset_DataForm"), -hoverHelp=>WebGUI::International::get('23 description',"Asset_DataForm"), - -value=>$field{type} || "text" + -value=>$field{type} || "text", + -types=>[qw(dateTime time float zipcode text textarea HTMLArea url date email phone integer yesNo selectList radioList checkList)] ); $f->integer( -name=>"width", diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index e6fb90b57..09d11e5ed 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -158,95 +158,6 @@ sub dynamicField { } -#------------------------------------------------------------------- - -=head2 fieldType ( hashRef ) - -Returns a field type select list field. This is primarily useful for building dynamic form builders. - -=head3 name - -The name field for this form element. - -=head3 types - -An array reference of field types to be displayed. The field names are the names of the methods from this forms package. Note that not all field types are supported. Defaults to all. - -=head3 value - -The default value for this form element. - -=head3 size - -The number of characters tall this form element should be. Defaults to "1". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub fieldType { - my $params = shift; - my (%hash, $output, $type); - tie %hash, 'Tie::IxHash'; - # NOTE: What you are about to see is bad code. Do not attempt this - # without adult supervision. =) - my @types = qw(dateTime time float zipcode text textarea HTMLArea url date email phone integer yesNo selectList radioList checkList); - $params->{types} = \@types unless ($params->{types}); - foreach $type (@{$params->{types}}) { - if ($type eq "text") { - $hash{text} = WebGUI::International::get(475); - } elsif ($type eq "timeField") { - $hash{timeField} = WebGUI::International::get(971); - } elsif ($type eq "dateTime") { - $hash{dateTime} = WebGUI::International::get(972); - } elsif ($type eq "textarea") { - $hash{textarea} = WebGUI::International::get(476); - } elsif ($type eq "HTMLArea") { - $hash{HTMLArea} = WebGUI::International::get(477); - } elsif ($type eq "url") { - $hash{url} = WebGUI::International::get(478); - } elsif ($type eq "date") { - $hash{date} = WebGUI::International::get(479); - } elsif ($type eq "float") { - $hash{float} = WebGUI::International::get("float"); - } elsif ($type eq "email") { - $hash{email} = WebGUI::International::get(480); - } elsif ($type eq "phone") { - $hash{phone} = WebGUI::International::get(481); - } elsif ($type eq "integer") { - $hash{integer} = WebGUI::International::get(482); - } elsif ($type eq "yesNo") { - $hash{yesNo} = WebGUI::International::get(483); - } elsif ($type eq "selectList") { - $hash{selectList} = WebGUI::International::get(484); - } elsif ($type eq "radioList") { - $hash{radioList} = WebGUI::International::get(942); - } elsif ($type eq "checkList") { - $hash{checkList} = WebGUI::International::get(941); - } elsif ($type eq "zipcode") { - $hash{zipcode} = WebGUI::International::get(944); - } elsif ($type eq "checkbox") { - $hash{checkbox} = WebGUI::International::get(943); - } - } - return selectList({ - options=>\%hash, - name=>$params->{name}, - value=>[$params->{value}], - extras=>$params->{extras}, - size=>$params->{size}, - defaultValue=>[$params->{defaultValue}] - }); -} - #------------------------------------------------------------------- =head2 file ( hashRef ) @@ -311,53 +222,6 @@ sub files { } -#------------------------------------------------------------------- - -=head2 filterContent ( hashRef ) - -Returns a select list containing the content filter options. This is for use with WebGUI::HTML::filter(). - -=head3 name - -The name field for this form element. This defaults to "filterContent". - -=head3 value - -The default value for this form element. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub filterContent { - my $params = 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) - ); - my $name = $params->{name} || "filterContent"; - return selectList({ - name=>$name, - options=>\%filter, - value=>[$params->{value}], - extras=>$params->{extras}, - defaultValue=>[$params->{defaultValue}] - }); -} - #------------------------------------------------------------------- =head2 formFooter ( ) @@ -415,524 +279,6 @@ sub formHeader { } -#------------------------------------------------------------------- - -=head2 ldapLink ( hashRef ) - -Returns a select list of ldap links. - -=head3 name - -The name field for this form element. Defaults to "ldapLinkId". - -=head3 value - -The default value(s) for this form element. This should be passed as an array reference. - -=head3 defaultValue - -This will be used if no value is specified. Defaults to 0 (the WebGUI database). - -=head3 size - -The number of characters tall this form element should be. Defaults to "1". - -=head3 multiple - -A boolean value for whether this select list should allow multiple selections. Defaults to "0". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=cut - -sub ldapLink { - my $params = shift; - my $value = $params->{value} || [$params->{defaultValue}] || [0]; - my $name = $params->{name} || "ldapLinkId"; - my $size = $params->{size} || 1; - my $multiple = $params->{multiple} || 0; - my $extras = $params->{extras} || ""; - return selectList({ - name=>$name, - options=>WebGUI::LDAPLink::getList(), - value=>$value, - size=>$size, - multiple=>$multiple, - extras=>$extras - }); -} - - -#------------------------------------------------------------------- - -=head2 password ( hashRef ) - -Returns a password field. - -=head3 name - -The name field for this form element. - -=head3 value - -The default value for this form element. - -=head3 maxlength - -The maximum number of characters to allow in this form element. Defaults to "35". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. Defaults to "30" unless overridden in the settings. - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub password { - my $params = shift; - my $value = _fixQuotes($params->{value}||$params->{defaultValue}); - my $maxLength = $params->{maxlength} || 35; - my $size = $params->{size} || $session{setting}{textBoxSize} || 30; - return '{extras}.' />'; -} - -#------------------------------------------------------------------- - -=head2 phone ( hashRef ) - -Returns a telephone number field. - -=head3 name - -The name field for this form element. - -=head3 value - -The default value for this form element. - -=head3 maxlength - -The maximum number of characters to allow in this form element. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub phone { - my $params = shift; - WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ type=>'text/javascript' }); - my $maxLength = $params->{maxlength} || 30; - return text({ - name=>$params->{name}, - maxlength=>$maxLength, - extras=>'onkeyup="doInputCheck(this.form.'.$params->{name}.',\'0123456789-()+ \')" '.$params->{extras}, - value=>$params->{value}, - size=>$params->{size}, - defaultValue=>$params->{defaultValue} - }); -} - -#------------------------------------------------------------------- - -=head2 radio ( hashRef ) - -Returns a radio button. - -=head3 name - -The name field for this form element. - -=head3 checked - -If you'd like this radio button to be defaultly checked, set this to "1". - -=head3 value - -The default value for this form element. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub radio { - my $params = shift; - my $checkedText = ' checked="1"' if ($params->{checked}); - my $value = defined($params->{value}) ? $params->{value} : $params->{defaultValue}; - return '{extras}.' />'; -} - -#------------------------------------------------------------------- - -=head2 radioList ( hashRef ) - -Returns a radio button list field. - -=head3 name - -The name field for this form element. - -=head3 options - -The list of options for this list. Should be passed as a hash reference. - -=head3 value - -The default value for this form element. This should be passed as a scalar. - -=head3 vertical - -If set to "1" the radio button elements will be laid out horizontally. Defaults to "0". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub radioList { - my $params = shift; - my ($output, $key, $checked); - my $value = defined($params->{value}) ? $params->{value} : $params->{defaultValue}; - foreach $key (keys %{$params->{options}}) { - $checked = 0; - $checked = 1 if ($key eq $value); - $output .= radio({ - name=>$params->{name}, - value=>$key, - checked=>$checked, - extras=>$params->{extras} - }); - $output .= ' '.$params->{options}->{$key}; - if ($params->{vertical}) { - $output .= "
\n"; - } else { - $output .= "    \n"; - } - } - return $output; -} - -#------------------------------------------------------------------- - -=head2 submit ( hashRef ) - -Returns a submit button. - -=head3 value - -The button text for this submit button. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. Defaults to "save". - -=cut - -sub submit { - my $params = shift; - my $value = $params->{value} || $params->{defaultValue} || WebGUI::International::get(62); - $value = _fixQuotes($value); - my $wait = WebGUI::International::get(452); - my $extras = $params->{extras} || 'onclick="this.value=\''.$wait.'\'"'; - return ''; - -} - -#------------------------------------------------------------------- - -=head2 template ( hashRef ) - -Returns a select list of templates. - -=head3 name - -The name field for this form element. Defaults to "templateId". - -=head3 value - -The unique identifier for the selected template. - -=head3 namespace - -The namespace for the list of templates to return. If this is omitted, all templates will be displayed. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub template { - my $params = shift; - my $templateId = $params->{value} || $params->{defaultValue}; - my $name = $params->{name} || "templateId"; - my $userId = $session{user}{userId}; - my $templateList = WebGUI::Asset::Template->getList($params->{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($userId)) { - delete $templateList->{$assetId}; - } - } - return selectList({ - name=>$name, - options=>$templateList, - value=>[$templateId], - extras=>$params->{extras} - }); -} - - -#------------------------------------------------------------------- - -=head2 timeField ( hashRef ) - -Returns a time field, 24 hour format. - -=head3 name - -The name field for this form element. - -=head3 value - -The default value for this form element. - -=head3 maxlength - -The maximum number of characters to allow in this form element. Defaults to 8. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. Defaults to 8. - -=head3 defaultValue - -This will be used if no value is specified. Defaults to now. - -=cut - -sub timeField { - my $params = shift; - my $value = WebGUI::DateTime::secondsToTime($params->{value}||$params->{defaultValue}); - WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ type=>'text/javascript' }); - my $output = text({ - name=>$params->{name}, - value=>$value, - size=>$params->{size} || 8, - extras=>'onKeyUp="doInputCheck(this.form.'.$params->{name}.',\'0123456789:\')" '.$params->{extras}, - maxlength=>$params->{maxlength} || 8 - }); - $output .= ''; - return $output; -} - -#------------------------------------------------------------------- - -=head2 url ( hashRef ) - -Returns a URL field. - -=head3 name - -The name field for this form element. - -=head3 value - -The default value for this form element. - -=head3 maxlength - -The maximum number of characters to allow in this form element. Defaults to 2048. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub url { - my $params = shift; - my $maxLength = $params->{maxlength} || 2048; - WebGUI::Style::setScript($session{config}{extrasURL}.'/addHTTP.js',{ type=>'text/javascript' }); - return text({ - name=>$params->{name}, - value=>$params->{value}, - extras=>$params->{extras}.' onBlur="addHTTP(this.form.'.$params->{name}.')"', - size=>$params->{size}, - maxlength=>$maxLength, - defaultValue=>$params->{defaultValue} - }); -} - -#------------------------------------------------------------------- - -=head2 whatNext ( hashRef ] ) - -Returns a "What next?" select list for use with chained action forms in WebGUI. - -=head3 options - -A hash reference of the possible actions that could happen next. - -=head3 value - -The selected element in this list. - -=head3 name - -The name field for this form element. Defaults to "proceed". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. - -=cut - -sub whatNext { - my $params = shift; - my $name = $params->{name} || "proceed"; - return selectList({ - options=>$params->{options}, - name=>$name, - value=>[$params->{value}], - extras=>$params->{extras}, - defaultValue=>[$params->{defaultValue}] - }); - -} - -#------------------------------------------------------------------- - -=head2 yesNo ( hashRef ) - -Returns a yes/no radio field. - -=head3 name - -The name field for this form element. - -=head3 value - -The default value(s) for this form element. Valid values are "1" and "0". Defaults to "1". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -This will be used if no value is specified. Defaults to 1. - -=cut - -sub yesNo { - my $params = shift; - my ($checkYes, $checkNo); - my $value = $params->{value}||$params->{defaultValue}; - if ($value) { - $checkYes = 1; - } else { - $checkNo = 1; - } - my $output = radio({ - checked=>$checkYes, - name=>$params->{name}, - value=>1, - extras=>$params->{extras} - }); - $output .= WebGUI::International::get(138); - $output .= '   '; - $output .= radio({ - checked=>$checkNo, - name=>$params->{name}, - value=>0, - extras=>$params->{extras} - }); - $output .= WebGUI::International::get(139); - return $output; -} diff --git a/lib/WebGUI/Form/Control.pm b/lib/WebGUI/Form/Control.pm index 429fe63c6..8070632ae 100644 --- a/lib/WebGUI/Form/Control.pm +++ b/lib/WebGUI/Form/Control.pm @@ -87,7 +87,7 @@ Add extra attributes to the form tag like =head4 label -A text label that will be displayed if toHtmlWithWrapper() is called. +A text label that will be displayed if toHtmlWithWrapper() is called. Defaults to the getName() method call. =head4 uiLevel @@ -138,7 +138,7 @@ sub definition { defaultValue=>undef }, label=>{ - defaultValue=>undef + defaultValue=>$class->getName }, uiLevel=>{ defaultValue=>1 diff --git a/lib/WebGUI/Form/checkbox.pm b/lib/WebGUI/Form/checkbox.pm index a7a8120f1..87b66c86e 100644 --- a/lib/WebGUI/Form/checkbox.pm +++ b/lib/WebGUI/Form/checkbox.pm @@ -95,7 +95,7 @@ Renders and input tag of type checkbox. sub toHtml { my $self = shift; - my $value = $self->fixQuotes($self->{value}); + my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value}))); my $checkedText = ' checked="checked"' if ($self->{checked}); return '{extras}.' />'; } diff --git a/lib/WebGUI/Form/databaseLink.pm b/lib/WebGUI/Form/databaseLink.pm index db8a9212f..6810743df 100644 --- a/lib/WebGUI/Form/databaseLink.pm +++ b/lib/WebGUI/Form/databaseLink.pm @@ -22,6 +22,7 @@ use WebGUI::Grouping; use WebGUI::Icon; use WebGUI::International; use WebGUI::Session; +use WebGUI::URL; =head1 NAME @@ -61,11 +62,7 @@ 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. Typically there is a link next to the select list that reads "Edit this database link" and this is the URL to go to after editing is complete. - -=head4 label - -A label displayed next to the field when toHtmlWithWrapper() is called. Defaults to "Database Link". +A URL that will be acted upon after editing a database link. =head4 hoverHelp @@ -86,9 +83,6 @@ sub definition { afterEdit=>{ defaultValue=>undef }, - label=>{ - defaultValue=>WebGUI::International::get(1075) - }, hoverHelp=>{ defaultValue=>WebGUI::International::get('1075 description') }, @@ -121,7 +115,8 @@ sub toHtml { return WebGUI::Form::selectList->new( name=>$self->{name}, options=>WebGUI::DatabaseLink::getList(), - value=>[$self->{value}] + value=>[$self->{value}], + extras=>$self->{extras} )->toHtml; } @@ -140,7 +135,7 @@ sub toHtmlWithWrapper { if ($self->{afterEdit}) { $subtext = editIcon("op=editDatabaseLink&lid=".$self->{value}."&afterEdit=".WebGUI::URL::escape($self->{afterEdit})); } - $subtext = .= manageIcon("op=listDatabaseLinks"); + $subtext .= manageIcon("op=listDatabaseLinks"); $self->{subtext} = $subtext . $self->{subtext}; } return $self->SUPER::toHtmlWithWrapper; @@ -148,5 +143,6 @@ sub toHtmlWithWrapper { + 1; diff --git a/lib/WebGUI/Form/group.pm b/lib/WebGUI/Form/group.pm index 340884329..9759d1c08 100644 --- a/lib/WebGUI/Form/group.pm +++ b/lib/WebGUI/Form/group.pm @@ -118,7 +118,7 @@ sub getValueFromPost { if (scalar(@data)) { return wantarray ? @data : join("\n",@data); } - return wantarray ? @[2] : 2; + return wantarray ? @{[2]} : 2; } #------------------------------------------------------------------- @@ -176,8 +176,7 @@ Renders the form field to HTML as a table row complete with labels, subtext, hov sub toHtmlWithWrapper { my $self = shift; if (WebGUI::Grouping::isInGroup(3)) { - my $subtext; - $subtext = .= manageIcon("op=listGroups"); + my $subtext = manageIcon("op=listGroups"); $self->{subtext} = $subtext . $self->{subtext}; } return $self->SUPER::toHtmlWithWrapper; diff --git a/lib/WebGUI/Form/interval.pm b/lib/WebGUI/Form/interval.pm index 3207910e8..2e1786141 100644 --- a/lib/WebGUI/Form/interval.pm +++ b/lib/WebGUI/Form/interval.pm @@ -122,7 +122,7 @@ sub toHtml { extras=>$self->{extras} )->toHtml .WebGUI::Form::selectList->new( - options=>\%units + options=>\%units, name=>$self->{name}."_units", value=>[$self->{value}] )->toHtml; diff --git a/lib/WebGUI/Form/zipcode.pm b/lib/WebGUI/Form/zipcode.pm index ab2bb2be1..fa527b291 100644 --- a/lib/WebGUI/Form/zipcode.pm +++ b/lib/WebGUI/Form/zipcode.pm @@ -100,7 +100,7 @@ sub getValueFromPost { =head2 toHtml ( ) -Renders an input tag of type text. +Renders a zip code field. =cut diff --git a/lib/WebGUI/FormProcessor.pm b/lib/WebGUI/FormProcessor.pm index e71ec0edc..875fd5d68 100644 --- a/lib/WebGUI/FormProcessor.pm +++ b/lib/WebGUI/FormProcessor.pm @@ -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; diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index f12b0dded..7f6c8bb6d 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -189,83 +189,6 @@ sub dynamicField { } -#------------------------------------------------------------------- - -=head2 fieldType ( name, types [, label, value, size, extras, subtext, uiLevel, defaultValue ] ) - -Adds a field type select list field to this form. This is primarily useful for building dynamic form builders. - -=head3 name - -The name field for this form element. - -=head3 types - -An array reference of field types to be displayed. The field names are the names of the methods from this forms package. Note that not all field types are supported. Defaults to all types. - -=head3 label - -The left column label for this form row. - -=head3 value - -The default value for this form element. - -=head3 size - -The number of characters tall this form element should be. Defaults to "1". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -When no other value is specified, this will be used. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub fieldType { - my ($output); - my ($self, @p) = @_; - my ($name, $types, $label, $value, $size, $multiple, $extras, $subtext, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name types label value size multiple extras subtext uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::fieldType({ - "name"=>$name, - "types"=>$types, - "value"=>$value, - "multiple"=>$multiple, - "size"=>$size, - "extras"=>$extras, - "defaultValue"=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - "defaultValue"=>$defaultValue - }); - } - $self->{_data} .= $output; -} - #------------------------------------------------------------------- =head2 file ( name [, label, subtext, extras, size, uiLevel ] ) @@ -321,162 +244,6 @@ sub file { $self->{_data} .= $output; } -#------------------------------------------------------------------- - -=head2 filterContent ( [ name, label, value, extras, subtext, uiLevel, defaultValue ] ) - -Adds a content filter select list to the form for use with the WebGUI::HTML::filter() function. - -=head3 name - -The name field for this form element. Defaults to "filterContent". - -=head3 label - -The left column label for this form row. Defaults to "Filter Content" (internationalized). - -=head3 value - -The default value for this form element. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here -as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -When no other value is present, this will be used. - -=head3 hoverHelp - -When no other value is present, this will be used. - -=cut - -sub filterContent { - my ($output); - my ($self, @p) = @_; - my ($name, $label, $value, $extras, $subtext, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name label value extras subtext uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $label = WebGUI::International::get(418) if ($label eq ""); - $hoverHelp = WebGUI::International::get('418 description') if ($hoverHelp eq ""); - $output = WebGUI::Form::filterContent({ - "name"=>$name, - "value"=>$value, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} - - - - -#------------------------------------------------------------------- - -=head2 ldapLink ( [name , value, label, afterEdit, extras, uiLevel, defaultValue ] ) - -Adds a ldap link select list to the form. - -=head3 name - -The name of this form element. - -=head3 value - -The default value(s) for this form element. This should be passed as an array reference. - -=head3 label - -The left column label for this form row. Defaults to "LDAP Link". - -=head3 size - -The number of characters tall this form element should be. Defaults to "1". - -=head3 multiple - -A boolean value for whether this select list should allow multiple selections. Defaults to "0". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 afterEdit - -A URL that will be acted upon after editing a database link. Typically there is a link next to the select list that reads "Edit this ldap link" and this is the URL to go to after editing is complete. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "5". - -=head3 defaultValue - -When no other value is passed, we'll use this. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub ldapLink { - my ($output, $subtext); - my ($self, @p) = @_; - my ($name, $value, $label, $size, $multiple, $afterEdit, $extras, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name value label size multiple afterEdit extras uiLevel defaultValue hoverHelp)], @p); - $size = 1 unless ($size); - $multiple = 0 unless ($multiple); - if (_uiLevelChecksOut($uiLevel)) { - $label = $label || WebGUI::International::get("LDAPLink_1075","AuthLDAP"); - if (WebGUI::Grouping::isInGroup(3)) { - if ($afterEdit) { - $subtext = editIcon("op=editLDAPLink&llid=".$value."&afterEdit=".WebGUI::URL::escape($afterEdit)); - } - $subtext .= manageIcon("op=listLDAPLinks"); - } - $output = WebGUI::Form::ldapLink({ - "name"=>$name, - "value"=>$value, - "extras"=>$extras, - "size"=>$size, - "multiple"=>$multiple, - "defaultValue"=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - "defaultValue"=>$defaultValue - }); - } - $self->{_data} .= $output; -} #------------------------------------------------------------------- @@ -534,158 +301,6 @@ sub new { #------------------------------------------------------------------- -=head2 password ( name [, label, value, subtext, maxlength, extras, size, uiLevel, defaultValue ] ) - -Adds a password row to this form. - -=head3 name - -The name field for this form element. - -=head3 label - -The left column label for this form row. - -=head3 value - -The default value for this form element. - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 maxlength - -The maximum number of characters to allow in this form element. Defaults to "35". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. Defaults to "30" unless overridden in the settings. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -When no value is specified, this will be used instead. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub password { - my ($output); - my ($self, @p) = @_; - my ($name, $label, $value, $subtext, $maxlength, $extras, $size, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name label value subtext maxlength extras size uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::password({ - "name"=>$name, - "value"=>$value, - "size"=>$size, - "maxlength"=>$maxlength, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} - -#------------------------------------------------------------------- - -=head2 phone ( name [, label, value, maxlength, extras, subtext, size, uiLevel, defaultValue ] ) - -Adds a text row to this form. - -=head3 name - -The name field for this form element. - -=head3 label - -The left column label for this form row. - -=head3 value - -The default value for this form element. - -=head3 maxlength - -The maximum number of characters to allow in this form element. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -If no value is specified, we'll use this instead. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub phone { - my ($output); - my ($self, @p) = @_; - my ($name, $label, $value, $maxlength, $extras, $subtext, $size, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name label value maxlength extras subtext size uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::phone({ - "name"=>$name, - "value"=>$value, - "size"=>$size, - "maxlength"=>$maxlength, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} - -#------------------------------------------------------------------- - =head2 print ( ) Returns the HTML for this form object. @@ -708,154 +323,6 @@ sub printRowsOnly { return $_[0]->{_data}; } -#------------------------------------------------------------------- - -=head2 radio ( name [, label, checked, value, subtext, extras, uiLevel, defaultValue ] ) - -Adds a radio button row to this form. - -=head3 name - -The name field for this form element. - -=head3 label - -The left column label for this form row. - -=head3 checked - -If you'd like this radio button to be defaultly checked, set this to "1". - -=head3 value - -The default value for this form element. - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -If no value is specified, we'll use this instead. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub radio { - my ($output); - my ($self, @p) = @_; - my ($name, $label, $checked, $value, $subtext, $extras, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name label checked value subtext extras uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::radio({ - "name"=>$name, - "value"=>$value, - "checked"=>$checked, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - if ($checked) { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - } - $self->{_data} .= $output; -} - -#------------------------------------------------------------------- - -=head2 radioList ( name, options [, label, value, vertical, extras, subtext, uiLevel, defaultValue ] ) - -Adds a radio button list row to this form. - -=head3 name - -The name field for this form element. - -=head3 options - -The list of options for this list. Should be passed as a hash reference. - -=head3 label - -The left column label for this form row. - -=head3 value - -The default value for this form element. Should be passed as a scalar. - -=head3 vertical - -If set to "1" the radio button elements will be laid out horizontally. Defaults to "0". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -If no other value is specified, we'll use this instead. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub radioList { - my ($output); - my ($self, @p) = @_; - my ($name, $options, $label, $value, $vertical, $extras, $subtext, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name options label value vertical extras subtext uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::radioList({ - "name"=>$name, - "options"=>$options, - "value"=>$value, - "vertical"=>$vertical, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} #------------------------------------------------------------------- @@ -879,252 +346,6 @@ sub raw { $self->{_data} .= $output; } -#------------------------------------------------------------------- - -=head2 readOnly ( value [, label, subtext, uiLevel, defaultValue ] ) - -Adds a read only row to this form. This is mainly used for displaying not editable properties, but it can also be used to quickly insert custom form elements. - -=head3 value - -The read only value. - -=head3 label - -The left column label for this form row. - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -If no value is specified, we'll use this. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub readOnly { - my ($output); - my ($self, @p) = @_; - my ($value, $label, $subtext, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(value label subtext uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = $value || $defaultValue; - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output, $hoverHelp); - } - $self->{_data} .= $output; -} - - -#------------------------------------------------------------------- - -=head2 submit ( value [ label, extras, subtext, defaultValue ] ) - -Adds a submit button row to this form. - -=head3 value - -The button text for this submit button. - -=head3 label - -The left column label for this form row. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 defaultValue - -If no value is specified, this will be used. Defaults to "save". - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub submit { - my ($output); - my ($self, @p) = @_; - my ($value, $label, $extras, $subtext, $defaultValue,$hoverHelp) = rearrange([qw(value label extras subtext defaultValue hoverHelp)], @p); - $output = WebGUI::Form::submit({ - "value"=>$value, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - $self->{_data} .= $output; -} - -#------------------------------------------------------------------- - -=head2 template ( name [, value, label, namespace, afterEdit, extras, uiLevel, defaultValue, subtext ] ) - -Adds a template select list to the form. - -=head3 name - -The name of this form element. - -=head3 value - -The default value for this form element. - -=head3 label - -The left column label for this form row. - -=head3 namespace - -The namespace (or type) of templates to show in this list. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -If no value is specified, this will be used. - -=head3 subtext - -Any extra information you want to include after the field. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub template { - my ($output, $buttons); - my ($self, @p) = @_; - my ($name, $value, $label, $namespace, $afterEdit, $extras, $uiLevel, $defaultValue, $subtext,$hoverHelp) = - rearrange([qw(name value label namespace afterEdit extras uiLevel defaultValue subtext hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $label = $label || WebGUI::International::get(356); - my $template = WebGUI::Asset->newByDynamicClass($value); - if (defined $template && $template->canEdit) { - my $returnUrl; - if (exists $session{asset}) { - $returnUrl = "&proceed=goBackToPage&returnUrl=".WebGUI::URL::escape($session{asset}->getUrl); - } - $buttons = editIcon("func=edit".$returnUrl,$template->get("url")); - $buttons .= manageIcon("func=manageAssets",$template->getParent->get("url")); - } - $output = WebGUI::Form::template({ - "name"=>$name, - "value"=>$value, - "namespace"=>$namespace, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($buttons.$subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} - -#------------------------------------------------------------------- - -=head2 timeField ( name [, label, value, extras, subtext, size, noDate, uiLevel, defaultValue ] ) - -Adds a date row to this form. - -=head3 name - -The name field for this form element. - -=head3 label - -The left column label for this form row. - -=head3 value - -The default time. Pass as a number of seconds. Defaults to 0. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -This will be used if no value is specified. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub timeField { - my ($output); - my ($self, @p) = @_; - my ($name, $label, $value, $extras, $subtext, $size, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name label value extras subtext size uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::time({ - "name"=>$name, - "value"=>$value, - "size"=>$size, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output, $hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>secondsToTime($value), - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} - #------------------------------------------------------------------- @@ -1140,222 +361,6 @@ sub trClass { $self->{_class} = $class; } -#------------------------------------------------------------------- - -=head2 url ( name [, label, value, maxlength, extras, subtext, size, uiLevel, defaultValue ] ) - -Adds a URL row to this form. - -=head3 name - -The name field for this form element. - -=head3 label - -The left column label for this form row. - -=head3 value - -The default value for this form element. - -=head3 maxlength - -The maximum number of characters to allow in this form element. Defaults to 2048. - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 size - -The number of characters wide this form element should be. There should be no reason for anyone to specify this. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -A value to be set if value is empty. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub url { - my ($output); - my ($self, @p) = @_; - my ($name, $label, $value, $maxlength, $extras, $subtext, $size, $uiLevel, $defaultValue, $hoverHelp) = - rearrange([qw(name label value maxlength extras subtext size uiLevel defaultValue hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::url({ - "name"=>$name, - "value"=>$value, - "size"=>$size, - "maxlength"=>$maxlength, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} - -#------------------------------------------------------------------- - -=head2 whatNext ( options [, value, name, label, subtext, uiLevel, extras, defaultValue ] ) - -Adds a "What next?" select list to this form for use with chained action forms in WebGUI. - -=head3 options - -A hash reference of the possible actions that could happen next. - -=head3 value - -The selected element in this list. - -=head3 name - -The name field for this form element. Defaults to "proceed". - -=head3 label - -The left column label for this form row. - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "1". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 defaultValue - -Used if value is not specified. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub whatNext { - my ($output); - my ($self, @p) = @_; - my ($options, $value, $name, $label, $subtext, $uiLevel, $extras, $defaultValue, $hoverHelp) = - rearrange([qw(options value name label subtext uiLevel extras defaultValue hoverHelp)], @p); - $uiLevel |= 1; - $label |= WebGUI::International::get(744); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::whatNext({ - "name"=>$name, - "options"=>$options, - "value"=>$value, - "extras"=>$extras, - defaultValue=>$defaultValue - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value, - defaultValue=>$defaultValue - }); - } - $self->{_data} .= $output; -} - -#------------------------------------------------------------------- - -=head2 yesNo ( name [, label, value, extras, subtext, uiLevel, defaultValue ] ) - -Adds a yes/no radio menu to this form. - -=head3 name - -The name field for this form element. - -=head3 label - -The left column label for this form row. - -=head3 value - -The default value(s) for this form element. Valid values are "1" and "0". - -=head3 extras - -If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: - - 'onChange="this.form.submit()"' - -=head3 subtext - -Extra text to describe this form element or to provide special instructions. - -=head3 uiLevel - -The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". - -=head3 defaultValue - -This will be used if value is not specified. Defaults to 1. - -=head3 hoverHelp - -A string of text or HTML to be displayed when a user's mouse hover's over a field label. It is meant to describe to the user what to use the field for. - -=cut - -sub yesNo { - my ($output); - my ($self, @p) = @_; - my ($name, $label, $value, $extras, $subtext, $uiLevel, $hoverHelp) = - rearrange([qw(name label value extras subtext uiLevel hoverHelp)], @p); - if (_uiLevelChecksOut($uiLevel)) { - $output = WebGUI::Form::yesNo({ - "name"=>$name, - "value"=>$value, - "extras"=>$extras - }); - $output .= _subtext($subtext); - $output = $self->_tableFormRow($label,$output,$hoverHelp); - } else { - $value = 0 unless ($value); - $output = WebGUI::Form::hidden({ - "name"=>$name, - "value"=>$value - }); - } - $self->{_data} .= $output; -} - - - 1; diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index 026b37acb..41c095402 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -215,7 +215,8 @@ sub www_editProfileField { -label=>WebGUI::International::get(486,"WebGUIProfile"), -hoverHelp=>WebGUI::International::get('486 description',"WebGUIProfile"), -value=>$data{dataType}, - -defaultValue=>"text" + -defaultValue=>"text", + -types=>[qw(dateTime time float zipcode text textarea HTMLArea url date email phone integer yesNo selectList radioList checkList)] ); $f->textarea( -name => "dataValues", diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 575829c79..052cfa933 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -3270,11 +3270,6 @@ Privileges and styles assigned to pages in the package will not be copied when t lastUpdated => 1031514049 }, - '356' => { - message => q|Template|, - lastUpdated => 1031514049 - }, - '38' => { message => q|You do not have sufficient privileges to perform this operation. Please ^a(log in with an account); that has sufficient privileges before attempting this operation.|, lastUpdated => 1031514049 @@ -3343,6 +3338,24 @@ Privileges and styles assigned to pages in the package will not be copied when t context => q|Field type name| }, + 'radio' => { + message => q|Radio Button|, + lastUpdated =>0, + context => q|Field type name| + }, + + 'read only' => { + message => q|Read Only|, + lastUpdated =>0, + context => q|Field type name| + }, + + 'submit' => { + message => q|Submit|, + lastUpdated =>0, + context => q|Field type name| + }, + 'button' => { message => q|Button|, lastUpdated =>0,