first round of changes for the new session system
This commit is contained in:
parent
da95226072
commit
d4b7f2ce59
128 changed files with 2442 additions and 1478 deletions
|
|
@ -95,22 +95,22 @@ Renders an asset selector.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($self->{value}) || WebGUI::Asset->getRoot;
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($self->get("value")) || WebGUI::Asset->getRoot;
|
||||
return WebGUI::Form::Hidden->new(
|
||||
name=>$self->{name},
|
||||
extras=>$self->{extras},
|
||||
name=>$self->get("name"),
|
||||
extras=>$self->get("extras"),
|
||||
value=>$asset->getId,
|
||||
id=>$self->{id}
|
||||
)->toHtml
|
||||
.WebGUI::Form::Text->new(
|
||||
name=>$self->{name}."_display",
|
||||
name=>$self->get("name")."_display",
|
||||
extras=>' readonly="1" ',
|
||||
value=>$asset->get("title"),
|
||||
id=>$self->{id}."_display"
|
||||
)->toHtml
|
||||
.WebGUI::Form::Button->new(
|
||||
value=>"...",
|
||||
extras=>'onclick="window.open(\''.$asset->getUrl("op=formAssetTree;classLimiter=".$self->{class}.";formId=".$self->{id}).'\',\'assetPicker\',\'toolbar=no, location=no, status=no, directories=no, width=400, height=400\');"'
|
||||
extras=>'onclick="window.open(\''.$asset->getUrl("op=formAssetTree;classLimiter=".$self->get("class").";formId=".$self->{id}).'\',\'assetPicker\',\'toolbar=no, location=no, status=no, directories=no, width=400, height=400\');"'
|
||||
)->toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@ Renders a button.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixQuotes($self->{value});
|
||||
my $value = $self->fixQuotes($self->get("value"));
|
||||
my $html = '<input type="button" ';
|
||||
$html .= 'name="'.$self->{name}.'" ' if ($self->{name});
|
||||
$html .= 'name="'.$self->get("name").'" ' if ($self->get("name"));
|
||||
$html .= 'id="'.$self->{id}.'" ' unless ($self->{id} eq "_formId");
|
||||
$html .= 'value="'.$value.'" '.$self->{extras}.' />';
|
||||
$html .= 'value="'.$value.'" '.$self->get("extras").' />';
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,18 +92,18 @@ sub toHtml {
|
|||
%options = $self->orderedHash();
|
||||
foreach my $key (keys %options) {
|
||||
my $checked = 0;
|
||||
foreach my $item (@{$self->{value}}) {
|
||||
foreach my $item (@{$self->get("value}")) {
|
||||
if ($item eq $key) {
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$output .= WebGUI::Form::Checkbox->new({
|
||||
name=>$self->{name},
|
||||
name=>$self->get("name"),
|
||||
value=>$key,
|
||||
extras=>$self->{extras},
|
||||
extras=>$self->get("extras"),
|
||||
checked=>$checked
|
||||
})->toHtml;
|
||||
$output .= ${$self->{options}}{$key} . $alignment;
|
||||
$output .= ${$self->get("options}"){$key} . $alignment;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ Retrieves a value from a form GET or POST and returns it. If the value comes bac
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $formValue = $session{req}->param($self->{name});
|
||||
my $formValue = $self->session->request->param($self->get("name"));
|
||||
if (defined $formValue) {
|
||||
return $formValue;
|
||||
} else {
|
||||
|
|
@ -122,10 +122,10 @@ Renders and input tag of type checkbox.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
my $checkedText = ' checked="checked"' if ($self->{checked});
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
|
||||
my $checkedText = ' checked="checked"' if ($self->get("checked"));
|
||||
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
|
||||
return '<input type="checkbox" name="'.$self->{name}.'" value="'.$value.'"'.$idText.$checkedText.' '.$self->{extras}.' />';
|
||||
return '<input type="checkbox" name="'.$self->get("name").'" value="'.$value.'"'.$idText.$checkedText.' '.$self->get("extras").' />';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ Renders a code area field.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/TabFix.js',{type=>"text/javascript"});
|
||||
$self->{extras} .= ' style="width: 99%; min-width: 440px; height: 400px" onkeypress="return TabFix_keyPress(event)" onkeydown="return TabFix_keyDown(event)"';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/TabFix.js',{type=>"text/javascript"});
|
||||
$self->get("extras") .= ' style="width: 99%; min-width: 440px; height: 400px" onkeypress="return TabFix_keyPress(event)" onkeydown="return TabFix_keyDown(event)"';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ Returns a hex color like "#000000". Returns undef if the return value is not a v
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $color = $session{req}->param($self->{name});
|
||||
my $color = $self->session->request->param($self->get("name"));
|
||||
return undef unless $color =~ /\#\w{6}/;
|
||||
return $color;
|
||||
}
|
||||
|
|
@ -82,8 +82,8 @@ Renders a color picker control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/colorPicker.js',{ type=>'text/javascript' });
|
||||
return '<script type="text/javascript">initColorPicker("'.$self->{name}.'","'.($self->{value}).'");</script>';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/colorPicker.js',{ type=>'text/javascript' });
|
||||
return '<script type="text/javascript">initColorPicker("'.$self->get("name").'","'.($self->get("value")).'");</script>';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ Returns an array or a carriage return ("\n") separated scalar depending upon whe
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
if ($session{req}->param($self->{name}."_new")) {
|
||||
return $session{req}->param($self->{name}."_new");
|
||||
if ($self->session->request->param($self->get("name")."_new")) {
|
||||
return $self->session->request->param($self->get("name")."_new");
|
||||
}
|
||||
return $self->SUPER::getValueFromPost;
|
||||
}
|
||||
|
|
@ -95,12 +95,12 @@ Renders a combo box form control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->{options}->{''} = '['.WebGUI::International::get(582).']';
|
||||
$self->{options}->{_new_} = WebGUI::International::get(581).'->';
|
||||
$self->get("options")->{''} = '['.WebGUI::International::get(582).']';
|
||||
$self->get("options")->{_new_} = WebGUI::International::get(581).'->';
|
||||
return $self->SUPER::toHtml
|
||||
.WebGUI::Form::Text->new(
|
||||
size=>$session{setting}{textBoxSize}-5,
|
||||
name=>$self->{name}."_new",
|
||||
size=>$self->session->setting->get("textBoxSize")-5,
|
||||
name=>$self->get("name")."_new",
|
||||
id=>$self->{id}."_new"
|
||||
)->toHtml;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ Renders a select list form control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my %types;
|
||||
foreach my $type (@{$self->{types}}) {
|
||||
foreach my $type (@{$self->get("types}")) {
|
||||
if ($type eq "text") {
|
||||
$types{text} = WebGUI::International::get(1010);
|
||||
} elsif ($type eq "mixed") {
|
||||
|
|
@ -103,7 +103,7 @@ sub toHtml {
|
|||
$types{html} = WebGUI::International::get(1009);
|
||||
}
|
||||
}
|
||||
$self->{options} = \%types,
|
||||
$self->get("options") = \%types,
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ sub displayFormWithWrapper {
|
|||
if ($self->passUiLevelCheck) {
|
||||
my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext) = $self->prepareWrapper;
|
||||
return '<tr'.$rowClass.'>
|
||||
<td'.$labelClass.$hoverHelp.' valign="top" style="width: 25%;">'.$self->{label}.'</td>
|
||||
<td'.$labelClass.$hoverHelp.' valign="top" style="width: 25%;">'.$self->get("label").'</td>
|
||||
<td valign="top"'.$fieldClass.' style="width: 75%;">'.$self->displayForm().$subtext."</td>
|
||||
</tr>\n";
|
||||
} else {
|
||||
|
|
@ -250,7 +250,7 @@ form elements will just return their value.
|
|||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return $self->{value};
|
||||
return $self->get("value");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -271,6 +271,25 @@ sub generateIdParameter {
|
|||
return $name."_formId";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 get ( var )
|
||||
|
||||
Returns a property of this form object.
|
||||
|
||||
=head3 var
|
||||
|
||||
The variable name of the value to return.
|
||||
|
||||
=cut
|
||||
|
||||
sub get {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
return $self->{_params}{$var};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( )
|
||||
|
|
@ -373,20 +392,24 @@ Retrieves a value from a form GET or POST and returns it. If the value comes bac
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $formValue = $session{req}->param($self->{name});
|
||||
my $formValue = $self->session->request->param($self->get("name"));
|
||||
if (defined $formValue) {
|
||||
return $formValue;
|
||||
} else {
|
||||
return $self->{defaultValue};
|
||||
return $self->get("defaultValue");
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( parameters )
|
||||
=head2 new ( session, parameters )
|
||||
|
||||
Constructor. Creates a new form field object.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=head3 parameters
|
||||
|
||||
Accepts any parameters specified by the definition() method. This parameter set can be specified by either a hash or hash reference, and can be tagged or not. Here are examples:
|
||||
|
|
@ -402,6 +425,7 @@ Please note that an id attribute is automatically added to every form element wi
|
|||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my %raw;
|
||||
# deal with a hash reference full of properties
|
||||
if (ref $_[0] eq "HASH") {
|
||||
|
|
@ -440,8 +464,10 @@ sub new {
|
|||
}
|
||||
# preventing ID collisions
|
||||
$params{id} = $params{idPrefix}.$params{id};
|
||||
bless \%params, $class;
|
||||
bless {_session=>$session, _params=>\%params}, $class;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareWrapper ( )
|
||||
|
|
@ -452,13 +478,13 @@ Common code for preparing wrappers for *WithWrapper
|
|||
|
||||
sub prepareWrapper {
|
||||
my $self = shift;
|
||||
my $rowClass = $self->{rowClass};
|
||||
$rowClass = qq| class="$rowClass" | if($self->{rowClass});
|
||||
my $labelClass = $self->{labelClass};
|
||||
$labelClass = qq| class="$labelClass" | if($self->{labelClass});
|
||||
my $fieldClass = $self->{fieldClass};
|
||||
$fieldClass = qq| class="$fieldClass" | if($self->{fieldClass});
|
||||
my $hoverHelp = $self->{hoverHelp};
|
||||
my $rowClass = $self->get("rowClass");
|
||||
$rowClass = qq| class="$rowClass" | if($self->get("rowClass"));
|
||||
my $labelClass = $self->get("labelClass");
|
||||
$labelClass = qq| class="$labelClass" | if($self->get("labelClass"));
|
||||
my $fieldClass = $self->get("fieldClass");
|
||||
$fieldClass = qq| class="$fieldClass" | if($self->get("fieldClass"));
|
||||
my $hoverHelp = $self->get("hoverHelp");
|
||||
$hoverHelp =~ s/\r/ /g;
|
||||
$hoverHelp =~ s/\n/ /g;
|
||||
$hoverHelp =~ s/&/& amp;/g;
|
||||
|
|
@ -471,11 +497,26 @@ sub prepareWrapper {
|
|||
$hoverHelp =~ s/'/\\'/g;
|
||||
$hoverHelp =~ s/^\s+//;
|
||||
$hoverHelp = qq| onmouseover="return escape('$hoverHelp')"| if ($hoverHelp);
|
||||
my $subtext = $self->{subtext};
|
||||
my $subtext = $self->get("subtext");
|
||||
$subtext = qq| <span class="formSubtext">$subtext</span>| if ($subtext);
|
||||
return ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ( )
|
||||
|
||||
Returns a reference to the session.
|
||||
|
||||
=cut
|
||||
|
||||
sub session {
|
||||
my $self = shift;
|
||||
return $self->{_session};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
|
@ -486,7 +527,7 @@ Renders the form field to HTML. This method should be overridden by all subclass
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
return $self->{value};
|
||||
return $self->get("value");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -499,7 +540,7 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
return '<input type="hidden" name="'.$self->{name}.'" value="'.$self->fixQuotes($self->fixMacros($self->fixSpecialCharacters($self->{value}))).'" />'."\n";
|
||||
return '<input type="hidden" name="'.$self->get("name").'" value="'.$self->fixQuotes($self->fixMacros($self->fixSpecialCharacters($self->get("value")))).'" />'."\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -515,7 +556,7 @@ sub toHtmlWithWrapper {
|
|||
if ($self->passUiLevelCheck) {
|
||||
my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext) = $self->prepareWrapper;
|
||||
return '<tr'.$rowClass.'>
|
||||
<td'.$labelClass.$hoverHelp.' valign="top" style="width: 25%;">'.$self->{label}.'</td>
|
||||
<td'.$labelClass.$hoverHelp.' valign="top" style="width: 25%;">'.$self->get("label").'</td>
|
||||
<td valign="top"'.$fieldClass.' style="width: 75%;">'.$self->toHtml().$subtext."</td>
|
||||
</tr>\n";
|
||||
} else {
|
||||
|
|
@ -534,10 +575,11 @@ Renders the form field to HTML as a table row complete with labels, subtext, hov
|
|||
sub passUiLevelCheck {
|
||||
my $self = shift;
|
||||
my $passUiLevelCheck = 0;
|
||||
if ($session{config}{$self->{uiLevelOverride}."_uiLevel"}{$self->{name}}) { # use override if it exists
|
||||
$passUiLevelCheck = ($session{config}{$self->{uiLevelOverride}."_uiLevel"}{$self->{name}} <= $session{user}{uiLevel});
|
||||
my $override = $self->session->config->get($self->get("uiLevelOverride")."_uiLevel")
|
||||
if (defined $override && $override->{$self->get("name")}) { # use override if it exists
|
||||
$passUiLevelCheck = ($override->{$self->get("name")} <= $self->session->user->profileField("uiLevel"));
|
||||
} else { # use programmed default
|
||||
$passUiLevelCheck = ($self->{uiLevel} <= $session{user}{uiLevel});
|
||||
$passUiLevelCheck = ($self->get("uiLevel") <= $self->session->user->profileField("uiLevel"));
|
||||
}
|
||||
$passUiLevelCheck = WebGUI::Grouping::isInGroup(3) unless ($passUiLevelCheck); # override if in admins group
|
||||
return $passUiLevelCheck;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ Renders a database connection picker control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->{options} = WebGUI::DatabaseLink::getList();
|
||||
$self->get("options") = WebGUI::DatabaseLink::getList();
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
|
|
@ -125,11 +125,11 @@ sub toHtmlWithWrapper {
|
|||
my $self = shift;
|
||||
if (WebGUI::Grouping::isInGroup(3)) {
|
||||
my $subtext;
|
||||
if ($self->{afterEdit}) {
|
||||
$subtext = editIcon("op=editDatabaseLink;lid=".$self->{value}.";afterEdit=".WebGUI::URL::escape($self->{afterEdit}));
|
||||
if ($self->get("afterEdit")) {
|
||||
$subtext = editIcon("op=editDatabaseLink;lid=".$self->get("value").";afterEdit=".WebGUI::URL::escape($self->get("afterEdit")));
|
||||
}
|
||||
$subtext .= manageIcon("op=listDatabaseLinks");
|
||||
$self->{subtext} = $subtext . $self->{subtext};
|
||||
$self->get("subtext") = $subtext . $self->get("subtext");
|
||||
}
|
||||
return $self->SUPER::toHtmlWithWrapper;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ Return the date in a human readable format for the Profile system.
|
|||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return WebGUI::DateTime::epochToHuman($self->{value},"%z");
|
||||
return WebGUI::DateTime::epochToHuman($self->get("value"),"%z");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -122,7 +122,7 @@ Returns a validated form post result. If the result does not pass validation, it
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
return WebGUI::DateTime::setToEpoch($session{req}->param($self->{name}));
|
||||
return WebGUI::DateTime::setToEpoch($self->session->request->param($self->get("name")));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -135,20 +135,20 @@ Renders a date picker control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
if ($self->{_defaulted} && $self->{noDate} ) {
|
||||
$self->{value} = '';
|
||||
if ($self->get("_defaulted") && $self->get("noDate") ) {
|
||||
$self->get("value") = '';
|
||||
}
|
||||
else {
|
||||
$self->{value} = WebGUI::DateTime::epochToSet($self->{value});
|
||||
$self->get("value") = WebGUI::DateTime::epochToSet($self->get("value"));
|
||||
}
|
||||
my $language = WebGUI::International::getLanguage($session{user}{language},"languageAbbreviation");
|
||||
my $language = WebGUI::International::getLanguage($self->session->user->profileField("language"),"languageAbbreviation");
|
||||
unless ($language) {
|
||||
$language = WebGUI::International::getLanguage("English","languageAbbreviation");
|
||||
}
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-'.$language.'.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/calendar.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/lang/calendar-'.$language.'.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/calendar-setup.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setLink($self->session->config->get("extrasURL").'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
return $self->SUPER::toHtml. '<script type="text/javascript">
|
||||
Calendar.setup({
|
||||
inputField : "'.$self->{id}.'",
|
||||
|
|
@ -156,7 +156,7 @@ sub toHtml {
|
|||
showsTime : false,
|
||||
step : 1,
|
||||
timeFormat : "12",
|
||||
firstDay : '.$session{user}{firstDayOfWeek}.'
|
||||
firstDay : '.$self->session->user->profileField("firstDayOfWeek").'
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
|
@ -172,8 +172,8 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
return WebGUI::Form::Hidden->new(
|
||||
name=>$self->{name},
|
||||
value=>WebGUI::DateTime::epochToSet($self->{value})
|
||||
name=>$self->get("name"),
|
||||
value=>WebGUI::DateTime::epochToSet($self->get("value"))
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ Returns a validated form post result. If the result does not pass validation, it
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
return WebGUI::DateTime::setToEpoch($session{req}->param($self->{name}));
|
||||
return WebGUI::DateTime::setToEpoch($self->session->request->param($self->get("name")));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -114,23 +114,23 @@ Renders a date picker control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = WebGUI::DateTime::epochToSet($self->{value},1);
|
||||
my $language = WebGUI::International::getLanguage($session{user}{language},"languageAbbreviation");
|
||||
my $value = WebGUI::DateTime::epochToSet($self->get("value"),1);
|
||||
my $language = WebGUI::International::getLanguage($self->session->user->profileField("language"),"languageAbbreviation");
|
||||
unless ($language) {
|
||||
$language = WebGUI::International::getLanguage("English","languageAbbreviation");
|
||||
}
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-'.$language.'.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
my $mondayFirst = $session{user}{firstDayOfWeek} ? "true" : "false";
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/calendar.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/lang/calendar-'.$language.'.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/calendar/calendar-setup.js',{ type=>'text/javascript' });
|
||||
WebGUI::Style::setLink($self->session->config->get("extrasURL").'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
my $mondayFirst = $self->session->user->profileField("firstDayOfWeek") ? "true" : "false";
|
||||
return WebGUI::Form::Text->new(
|
||||
name=>$self->{name},
|
||||
name=>$self->get("name"),
|
||||
value=>$value,
|
||||
size=>$self->{size},
|
||||
extras=>$self->{extras},
|
||||
size=>$self->get("size"),
|
||||
extras=>$self->get("extras"),
|
||||
id=>$self->{id},
|
||||
maxlength=>$self->{maxlength}
|
||||
maxlength=>$self->get("maxlength")
|
||||
)->toHtml . '<script type="text/javascript">
|
||||
Calendar.setup({
|
||||
inputField : "'.$self->{id}.'",
|
||||
|
|
@ -138,7 +138,7 @@ sub toHtml {
|
|||
showsTime : true,
|
||||
step : 1,
|
||||
timeFormat : "12",
|
||||
firstDay : '.$session{user}{firstDayOfWeek}.'
|
||||
firstDay : '.$self->session->user->profileField("firstDayOfWeek").'
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
|
@ -154,8 +154,8 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
return WebGUI::Form::Hidden->new(
|
||||
name=>$self->{name},
|
||||
value=>WebGUI::DateTime::epochToSet($self->{value},1)
|
||||
name=>$self->get("name"),
|
||||
value=>WebGUI::DateTime::epochToSet($self->get("value"),1)
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ Returns a validated email address. If the result does not pass validation, it re
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $session{req}->param($self->{name});
|
||||
my $value = $self->session->request->param($self->get("name"));
|
||||
|
||||
if ($value =~ /^([A-Z0-9]+[._+-]?){1,}([A-Z0-9]+[_+-]?)+\@(([A-Z0-9]+[._-]?){1,}[A-Z0-9]+\.){1,}[A-Z]{2,4}$/i) {
|
||||
return $value;
|
||||
|
|
@ -96,8 +96,8 @@ Renders an email address field.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/emailCheck.js',{ type=>'text/javascript' });
|
||||
$self->{extras} .= ' onchange="emailCheck(this.value)" ';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/emailCheck.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onchange="emailCheck(this.value)" ';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ and DynamicField, the form class dispatcher.
|
|||
|
||||
sub getTypes {
|
||||
my $class = shift;
|
||||
opendir(DIR,$session{config}{webguiRoot}."/lib/WebGUI/Form/");
|
||||
opendir(DIR,$self->session->config->getWebguiRoot."/lib/WebGUI/Form/");
|
||||
my @rawTypes = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my @types;
|
||||
|
|
@ -112,7 +112,7 @@ Returns either what's posted or if nothing comes back it returns "text".
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
return $session{req}->param($self->{name}) || "text";
|
||||
return $self->session->request->param($self->get("name")) || "text";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -127,7 +127,7 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my %options;
|
||||
tie %options, "Tie::IxHash";
|
||||
foreach my $type (@{$self->{types}}) {
|
||||
foreach my $type (@{$self->get("types}")) {
|
||||
my $class = "WebGUI::Form::".ucfirst($type);
|
||||
my $cmd = "use ".$class;
|
||||
eval ($cmd);
|
||||
|
|
@ -137,7 +137,7 @@ sub toHtml {
|
|||
}
|
||||
$options{$type} = $class->getName;
|
||||
}
|
||||
$self->{options} = \%options;
|
||||
$self->get("options") = \%options;
|
||||
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,15 +94,15 @@ delete it. Otherwise, display a form element to upload a file.
|
|||
|
||||
sub displayForm {
|
||||
my ($self) = @_;
|
||||
return $self->toHtml unless $self->{value};
|
||||
return $self->toHtml unless $self->get("value");
|
||||
##There are files inside here, for each one, display the image
|
||||
##and another form control for deleting it.
|
||||
my $location = WebGUI::Storage->get($self->{value});
|
||||
my $location = WebGUI::Storage->get($self->get("value"));
|
||||
my $id = $location->getId;
|
||||
my $fileForm = '';
|
||||
foreach my $file ( @{ $location->getFiles } ) {
|
||||
$fileForm .= sprintf qq!<img src="%s" /><br />!, $location->getUrl($file);
|
||||
my $action = join '_', '_', $self->{name}, 'delete';
|
||||
my $action = join '_', '_', $self->get("name"), 'delete';
|
||||
$fileForm .= WebGUI::International::get(392)
|
||||
. " "x4
|
||||
. WebGUI::Form::YesNo->new({-name=>$action, -value=>0})->toHtml;
|
||||
|
|
@ -123,8 +123,8 @@ form elements will just return their value.
|
|||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return '' unless $self->{value};
|
||||
my $location = WebGUI::Storage->get($self->{value});
|
||||
return '' unless $self->get("value");
|
||||
my $location = WebGUI::Storage->get($self->get("value"));
|
||||
local $_;
|
||||
my @files = map { sprintf qq!<img src="%s" /> %s!, $location->getFileIconUrl($_), $_; } @{ $location->getFiles };
|
||||
my $fileValue = join "<br />\n", @files;
|
||||
|
|
@ -143,8 +143,8 @@ deleting the file if it was specified.
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $session{req}->param($self->{name});
|
||||
if ($session{req}->param(join '_', '_', $self->{name}, 'delete')) {
|
||||
my $value = $self->session->request->param($self->get("name"));
|
||||
if ($self->session->request->param(join '_', '_', $self->get("name"), 'delete')) {
|
||||
my $storage = WebGUI::Storage->get($value);
|
||||
$storage->delete;
|
||||
return '';
|
||||
|
|
@ -157,7 +157,7 @@ sub getValueFromPost {
|
|||
else {
|
||||
$storage = WebGUI::Storage::Image->create;
|
||||
}
|
||||
$storage->addFileFromFormPost($self->{name});
|
||||
$storage->addFileFromFormPost($self->get("name"));
|
||||
my @files = @{ $storage->getFiles };
|
||||
if (scalar(@files) < 1) {
|
||||
$storage->delete;
|
||||
|
|
@ -179,21 +179,21 @@ Renders a file upload control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/FileUploadControl.js',{type=>"text/javascript"});
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/FileUploadControl.js',{type=>"text/javascript"});
|
||||
my $uploadControl = '<script type="text/javascript">
|
||||
var fileIcons = new Array();
|
||||
';
|
||||
opendir(DIR,$session{config}{extrasPath}.'/fileIcons');
|
||||
opendir(DIR,$self->session->config->get("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 .= 'fileIcons["'.$ext.'"] = "'.$session{config}{extrasURL}.'/fileIcons/'.$file.'";'."\n";
|
||||
$uploadControl .= 'fileIcons["'.$ext.'"] = "'.$self->session->config->get("extrasURL").'/fileIcons/'.$file.'";'."\n";
|
||||
}
|
||||
}
|
||||
$uploadControl .= 'var uploader = new FileUploadControl("'.$self->{name}.'", fileIcons, "'.WebGUI::International::get('removeLabel','WebGUI').'","'.$self->{maxAttachments}.'");
|
||||
$uploadControl .= 'var uploader = new FileUploadControl("'.$self->get("name").'", fileIcons, "'.WebGUI::International::get('removeLabel','WebGUI').'","'.$self->get("maxAttachments").'");
|
||||
uploader.addRow();
|
||||
</script>';
|
||||
return $uploadControl;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ Returns either what's posted or if nothing comes back it returns "most".
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
return $session{req}->param($self->{name}) || "most";
|
||||
return $self->session->request->param($self->get("name")) || "most";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -114,7 +114,7 @@ sub toHtml {
|
|||
'most'=>WebGUI::International::get(421),
|
||||
'all'=>WebGUI::International::get(419)
|
||||
);
|
||||
$self->{options} = \%filter;
|
||||
$self->get("options") = \%filter;
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ Returns the integer from the form post, or returns 0.0 if the post result is inv
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $session{req}->param($self->{name});
|
||||
my $value = $self->session->request->param($self->get("name"));
|
||||
if ($value =~ /^[\d\-\.]+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -116,8 +116,8 @@ Renders a floating point field.
|
|||
|
||||
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-.\')"';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789-.\')"';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,10 +109,10 @@ Returns a group pull-down field. A group pull down provides a select list that p
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $where;
|
||||
if ($self->{excludeGroups}[0] ne "") {
|
||||
$where = "and groupId not in (".quoteAndJoin($self->{excludeGroups}).")";
|
||||
if ($self->get("excludeGroups")[0] ne "") {
|
||||
$where = "and groupId not in (".$self->session->db->quoteAndJoin($self->get("excludeGroups")).")";
|
||||
}
|
||||
$self->{options} = WebGUI::SQL->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName");
|
||||
$self->get("options") = $self->session->db->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName");
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ Creates a series of hidden fields representing the data in the list.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
$self->{options} = WebGUI::SQL->buildHashRef("select groupId,groupName from groups");
|
||||
$self->get("options") = $self->session->db->buildHashRef("select groupId,groupName from groups");
|
||||
return $self->SUPER::toHtmlAsHidden();
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ sub toHtmlWithWrapper {
|
|||
my $self = shift;
|
||||
if (WebGUI::Grouping::isInGroup(3)) {
|
||||
my $subtext = manageIcon("op=listGroups");
|
||||
$self->{subtext} = $subtext . $self->{subtext};
|
||||
$self->get("subtext") = $subtext . $self->get("subtext");
|
||||
}
|
||||
return $self->SUPER::toHtmlWithWrapper;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,13 +77,13 @@ sub definition {
|
|||
defaultValue=>WebGUI::International::get("477","WebGUI")
|
||||
},
|
||||
rows=>{
|
||||
defaultValue=> $session{setting}{textAreaRows}+20
|
||||
defaultValue=> $self->session->setting->get("textAreaRows")+20
|
||||
},
|
||||
columns=>{
|
||||
defaultValue=> $session{setting}{textAreaCols}+10
|
||||
defaultValue=> $self->session->setting->get("textAreaCols")+10
|
||||
},
|
||||
richEditId=>{
|
||||
defaultValue=>$session{setting}{richEditor} || "PBrichedit000000000001"
|
||||
defaultValue=>$self->session->setting->get("richEditor") || "PBrichedit000000000001"
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
|
|
@ -116,10 +116,10 @@ Renders an HTML area field.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/textFix.js',{ type=>'text/javascript' });
|
||||
$self->{extras} .= ' onblur="fixChars(this.form.'.$self->{name}.')" mce_editable="true" ';
|
||||
return $self->SUPER::toHtml.WebGUI::Asset::RichEdit->new($self->{richEditId})->getRichEditor($self->{id});
|
||||
my $richEdit = WebGUI::Asset::RichEdit->new($self->{richEditId});
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/textFix.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onblur="fixChars(this.form.'.$self->get("name").')" mce_editable="true" ';
|
||||
return $self->SUPER::toHtml.WebGUI::Asset::RichEdit->new($self->get("richEditId"))->getRichEditor($self->{id});
|
||||
my $richEdit = WebGUI::Asset::RichEdit->new($self->get("richEditId"));
|
||||
if (defined $richEdit) {
|
||||
return $self->SUPER::toHtml.$richEdit->getRichEditor($self->{id});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ Renders an input tag of type hidden.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
|
||||
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
|
||||
return '<input type="hidden" name="'.$self->{name}.'" value="'.$value.'" '.$self->{extras}.$idText.' />'."\n";
|
||||
return '<input type="hidden" name="'.$self->get("name").'" value="'.$value.'" '.$self->get("extras").$idText.' />'."\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -98,8 +98,8 @@ profile field.
|
|||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return '' unless $self->{value};
|
||||
my $location = WebGUI::Storage->get($self->{value});
|
||||
return '' unless $self->get("value");
|
||||
my $location = WebGUI::Storage->get($self->get("value"));
|
||||
local $_;
|
||||
my @files = map { sprintf qq!<img src="%s" />!, $location->getUrl($_) } @{ $location->getFiles };
|
||||
my $fileValue = join "<br />\n", @files;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ Returns the integer from the form post, or returns 0 if the post result is inval
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $session{req}->param($self->{name});
|
||||
my $value = $self->session->request->param($self->get("name"));
|
||||
if ($value =~ /^[\d\-]+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -116,8 +116,8 @@ Renders an integer field.
|
|||
|
||||
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-\')"';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789-\')"';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ Returns either the interval that was posted (in seconds) or if nothing comes bac
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
return WebGUI::DateTime::intervalToSeconds($session{req}->param($self->{name}."_interval"),$session{req}->param($self->{name}."_units")) || 0;
|
||||
return WebGUI::DateTime::intervalToSeconds($self->session->request->param($self->get("name")."_interval"),$self->session->request->param($self->get("name")."_units")) || 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -112,20 +112,20 @@ sub toHtml {
|
|||
'weeks'=>WebGUI::International::get(701),
|
||||
'months'=>WebGUI::International::get(702),
|
||||
'years'=>WebGUI::International::get(703));
|
||||
my ($interval, $units) = WebGUI::DateTime::secondsToInterval($self->{value});
|
||||
my ($interval, $units) = WebGUI::DateTime::secondsToInterval($self->get("value"));
|
||||
# not sure why, but these things need to be defined like this or
|
||||
# they fail under some circumstnaces
|
||||
my $cmd = "WebGUI::Form::Integer";
|
||||
my $out = $cmd->new(
|
||||
name=>$self->{name}."_interval",
|
||||
name=>$self->get("name")."_interval",
|
||||
value=>$interval,
|
||||
extras=>$self->{extras},
|
||||
extras=>$self->get("extras"),
|
||||
id=>$self->{id}."_interval",
|
||||
)->toHtml;
|
||||
$cmd = "WebGUI::Form::SelectBox";
|
||||
$out .= $cmd->new(
|
||||
options=>\%units,
|
||||
name=>$self->{name}."_units",
|
||||
name=>$self->get("name")."_units",
|
||||
id=>$self->{id}."_units",
|
||||
value=>[$units]
|
||||
)->toHtml;
|
||||
|
|
@ -143,13 +143,13 @@ Returns the field as hidden controls rather than displayable controls.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my ($interval, $units) = WebGUI::DateTime::secondsToInterval($self->{value});
|
||||
my ($interval, $units) = WebGUI::DateTime::secondsToInterval($self->get("value"));
|
||||
return WebGUI::Form::Hidden->new(
|
||||
name=>$self->{name}.'_interval',
|
||||
name=>$self->get("name").'_interval',
|
||||
value=>$interval
|
||||
)->toHtmlAsHidden
|
||||
.WebGUI::Form::Hidden->new(
|
||||
name=>$self->{name}.'_units',
|
||||
name=>$self->get("name").'_units',
|
||||
value=>$units
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ Renders a database connection picker control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->{options} = WebGUI::LDAPLink::getList();
|
||||
$self->get("options") = WebGUI::LDAPLink::getList();
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ Creates a series of hidden fields representing the data in the list.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
$self->{options} = WebGUI::LDAPLink::getList();
|
||||
$self->get("options") = WebGUI::LDAPLink::getList();
|
||||
return $self->SUPER::toHtmlAsHidden();
|
||||
}
|
||||
|
||||
|
|
@ -146,11 +146,11 @@ sub toHtmlWithWrapper {
|
|||
my $self = shift;
|
||||
if (WebGUI::Grouping::isInGroup(3)) {
|
||||
my $subtext;
|
||||
if ($self->{afterEdit}) {
|
||||
$subtext = editIcon("op=editLDAPLink;llid=".$self->{value}.";afterEdit=".WebGUI::URL::escape($self->{afterEdit}));
|
||||
if ($self->get("afterEdit")) {
|
||||
$subtext = editIcon("op=editLDAPLink;llid=".$self->get("value").";afterEdit=".WebGUI::URL::escape($self->get("afterEdit")));
|
||||
}
|
||||
$subtext .= manageIcon("op=listLDAPLinks");
|
||||
$self->{subtext} = $subtext . $self->{subtext};
|
||||
$self->get("subtext") = $subtext . $self->get("subtext");
|
||||
}
|
||||
return $self->SUPER::toHtmlWithWrapper;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ of radio/check boxes.
|
|||
|
||||
sub alignmentSeparator {
|
||||
my ($self) = @_;
|
||||
if ($self->{vertical}) {
|
||||
if ($self->get("vertical")) {
|
||||
return "<br />\n";
|
||||
}
|
||||
else {
|
||||
|
|
@ -72,10 +72,10 @@ sub correctOptions {
|
|||
s/\s+$//; # remove trailing spaces
|
||||
$options{$_} = $_;
|
||||
}
|
||||
if (exists $self->{options} && ref($self->{options}) eq "HASH") {
|
||||
%options = (%{$self->{options}} , %options);
|
||||
if (exists $self->get("options") && ref($self->get("options")) eq "HASH") {
|
||||
%options = (%{$self->get("options}") , %options);
|
||||
}
|
||||
$self->{options} = \%options;
|
||||
$self->get("options") = \%options;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ sub correctValues {
|
|||
s/\s+$//; # remove trailing spaces
|
||||
push(@defaultValues, $_);
|
||||
}
|
||||
$self->{value} = \@defaultValues;
|
||||
$self->get("value") = \@defaultValues;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ Returns an array or a carriage return ("\n") separated scalar depending upon whe
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my @data = $session{req}->param($self->{name});
|
||||
my @data = $self->session->request->param($self->get("name"));
|
||||
return wantarray ? @data : join("\n",@data);
|
||||
}
|
||||
|
||||
|
|
@ -207,11 +207,11 @@ ref.
|
|||
sub getValues {
|
||||
my $self = shift;
|
||||
my @values = ();
|
||||
if (ref $self->{value} eq 'ARRAY') {
|
||||
@values = @{ $self->{value} };
|
||||
if (ref $self->get("value") eq 'ARRAY') {
|
||||
@values = @{ $self->get("value") };
|
||||
}
|
||||
else {
|
||||
push @values, $self->{value};
|
||||
push @values, $self->get("value");
|
||||
}
|
||||
return @values;
|
||||
}
|
||||
|
|
@ -230,12 +230,12 @@ sub orderedHash {
|
|||
my ($self) = @_;
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
if ($self->{sortByValue}) {
|
||||
foreach my $optionKey (sort {"\L${$self->{options}}{$a}" cmp "\L${$self->{options}}{$b}" } keys %{$self->{options}}) {
|
||||
$options{$optionKey} = $self->{options}{$optionKey};
|
||||
if ($self->get("sortByValue")) {
|
||||
foreach my $optionKey (sort {"\L${$self->get("options}"){$a}" cmp "\L${$self->get("options}"){$b}" } keys %{$self->get("options}")) {
|
||||
$options{$optionKey} = $self->get("options"){$optionKey};
|
||||
}
|
||||
} else {
|
||||
%options = %{$self->{options}};
|
||||
%options = %{$self->get("options}");
|
||||
}
|
||||
return %options;
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ sub toHtmlAsHidden {
|
|||
foreach my $item (@values) {
|
||||
if ($item eq $key) {
|
||||
$output .= WebGUI::Form::Hidden->(
|
||||
name=>$self->{name},
|
||||
name=>$self->get("name"),
|
||||
value=>$key
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ Renders an input tag of type password.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $html = '<input type="password" name="'.$self->{name}.'" value="'.$self->fixQuotes($self->{value}).'" size="'.$self->{size}.'" id="'.$self->{id}.'" ';
|
||||
$html .= 'maxlength="'.$self->{maxLength}.'" ' if ($self->{maxLength});
|
||||
$html .= $self->{extras}.' />';
|
||||
my $html = '<input type="password" name="'.$self->get("name").'" value="'.$self->fixQuotes($self->get("value")).'" size="'.$self->get("size").'" id="'.$self->{id}.'" ';
|
||||
$html .= 'maxlength="'.$self->get("maxLength").'" ' if ($self->get("maxLength"));
|
||||
$html .= $self->get("extras").' />';
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ Returns a string filtered to allow only digits, spaces, and these special charac
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $session{req}->param($self->{name});
|
||||
my $value = $self->session->request->param($self->get("name"));
|
||||
if ($value =~ /^[\d\s\-\+\(\)]+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -95,8 +95,8 @@ Renders a phone number field.
|
|||
|
||||
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-()+ \')" ';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789-()+ \')" ';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,10 +97,10 @@ Renders and input tag of type radio.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
my $checkedText = ' checked="checked"' if ($self->{checked});
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
|
||||
my $checkedText = ' checked="checked"' if ($self->get("checked"));
|
||||
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
|
||||
return '<input type="radio" name="'.$self->{name}.'" value="'.$value.'"'.$idText.$checkedText.' '.$self->{extras}.' />';
|
||||
return '<input type="radio" name="'.$self->get("name").'" value="'.$value.'"'.$idText.$checkedText.' '.$self->get("extras").' />';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -104,16 +104,16 @@ sub toHtml {
|
|||
%options = $self->orderedHash;
|
||||
foreach my $key (keys %options) {
|
||||
my $checked = 0;
|
||||
if ($self->{value} eq $key) {
|
||||
if ($self->get("value") eq $key) {
|
||||
$checked = 1;
|
||||
}
|
||||
$output .= WebGUI::Form::Radio->new({
|
||||
name=>$self->{name},
|
||||
name=>$self->get("name"),
|
||||
value=>$key,
|
||||
extras=>$self->{extras},
|
||||
extras=>$self->get("extras"),
|
||||
checked=>$checked
|
||||
})->toHtml;
|
||||
$output .= ${$self->{options}}{$key} . $alignment;
|
||||
$output .= ${$self->get("options}"){$key} . $alignment;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ Renders the value.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
return $self->{value};
|
||||
return $self->get("value");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -94,11 +94,11 @@ Retrieves a value from a form GET or POST and returns it. If the value comes bac
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $formValue = $session{req}->param($self->{name});
|
||||
my $formValue = $self->session->request->param($self->get("name"));
|
||||
if (defined $formValue) {
|
||||
return $formValue;
|
||||
} else {
|
||||
return $self->{defaultValue};
|
||||
return $self->get("defaultValue");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ Renders a select list form control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $output = '<select name="'.$self->{name}.'" size="'.$self->{size}.'" id="'.$self->{id}.'" '.$self->{extras}.'>';
|
||||
my $output = '<select name="'.$self->get("name").'" size="'.$self->get("size").'" id="'.$self->{id}.'" '.$self->get("extras").'>';
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
%options = $self->orderedHash;
|
||||
|
|
@ -122,7 +122,7 @@ sub toHtml {
|
|||
if ($value eq $key) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
$output .= '>'.${$self->{options}}{$key}.'</option>';
|
||||
$output .= '>'.${$self->get("options}"){$key}.'</option>';
|
||||
}
|
||||
$output .= '</select>'."\n";
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ Renders a select list form control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $multiple = ' multiple="1"' if ($self->{multiple});
|
||||
my $output = '<select name="'.$self->{name}.'" size="'.$self->{size}.'" id="'.$self->{id}.'" '.$self->{extras}.$multiple.'>';
|
||||
my $multiple = ' multiple="1"' if ($self->get("multiple"));
|
||||
my $output = '<select name="'.$self->get("name").'" size="'.$self->get("size").'" id="'.$self->{id}.'" '.$self->get("extras").$multiple.'>';
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
%options = $self->orderedHash;
|
||||
|
|
@ -104,7 +104,7 @@ sub toHtml {
|
|||
$output .= ' selected="selected"';
|
||||
}
|
||||
}
|
||||
$output .= '>'.${$self->{options}}{$key}.'</option>';
|
||||
$output .= '>'.${$self->get("options}"){$key}.'</option>';
|
||||
}
|
||||
$output .= '</select>'."\n";
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@ Renders a button.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixQuotes($self->{value});
|
||||
$self->{extras} ||= 'onclick="this.value=\''.WebGUI::International::get(452).'\'"';
|
||||
my $value = $self->fixQuotes($self->get("value"));
|
||||
$self->get("extras") ||= 'onclick="this.value=\''.WebGUI::International::get(452).'\'"';
|
||||
my $html = '<input type="submit" ';
|
||||
$html .= 'name="'.$self->{name}.'" ' if ($self->{name});
|
||||
$html .= 'name="'.$self->get("name").'" ' if ($self->get("name"));
|
||||
$html .= 'id="'.$self->{id}.'" ' unless ($self->{id} eq "_formId");
|
||||
$html .= 'value="'.$value.'" '.$self->{extras}.' />';
|
||||
$html .= 'value="'.$value.'" '.$self->get("extras").' />';
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,15 +94,15 @@ Renders a template picker control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $templateList = WebGUI::Asset::Template->getList($self->{namespace});
|
||||
my $templateList = WebGUI::Asset::Template->getList($self->get("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})) {
|
||||
if (!$asset->canView($self->session->user->profileField("userId"))) {
|
||||
delete $templateList->{$assetId};
|
||||
}
|
||||
}
|
||||
$self->{options} = $templateList;
|
||||
$self->get("options") = $templateList;
|
||||
$self->setManageIcons();
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
|
@ -132,15 +132,15 @@ editing the template show up if the user is allowed to do that.
|
|||
|
||||
sub setManageIcons {
|
||||
my $self = shift;
|
||||
my $template = WebGUI::Asset::Template->new($self->{value});
|
||||
my $template = WebGUI::Asset::Template->new($self->get("value"));
|
||||
if (defined $template && $template->canEdit) {
|
||||
my $returnUrl;
|
||||
if (exists $session{asset}) {
|
||||
$returnUrl = ";proceed=goBackToPage;returnUrl=".WebGUI::URL::escape($session{asset}->getUrl);
|
||||
if (exists $self->session->asset) {
|
||||
$returnUrl = ";proceed=goBackToPage;returnUrl=".WebGUI::URL::escape($self->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};
|
||||
$self->get("subtext") = $buttons . $self->get("subtext");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ sub definition {
|
|||
defaultValue=> 255
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>$session{setting}{textBoxSize} || 30
|
||||
defaultValue=>$self->session->setting->get("textBoxSize") || 30
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
|
|
@ -91,8 +91,8 @@ Renders an input tag of type text.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
return '<input id="'.$self->{id}.'" type="text" name="'.$self->{name}.'" value="'.$value.'" size="'.$self->{size}.'" maxlength="'.$self->{maxlength}.'" '.$self->{extras}.' />';
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
|
||||
return '<input id="'.$self->{id}.'" type="text" name="'.$self->get("name").'" value="'.$value.'" size="'.$self->get("size").'" maxlength="'.$self->get("maxlength").'" '.$self->get("extras").' />';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -73,10 +73,10 @@ sub definition {
|
|||
defaultValue=>WebGUI::International::get("476","WebGUI")
|
||||
},
|
||||
rows=>{
|
||||
defaultValue=> $session{setting}{textAreaRows} || 5
|
||||
defaultValue=> $self->session->setting->get("textAreaRows") || 5
|
||||
},
|
||||
columns=>{
|
||||
defaultValue=> $session{setting}{textAreaCols} || 50
|
||||
defaultValue=> $self->session->setting->get("textAreaCols") || 50
|
||||
},
|
||||
wrap=>{
|
||||
defaultValue=>"virtual"
|
||||
|
|
@ -98,9 +98,9 @@ Renders an input tag of type text.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->{value})));
|
||||
return '<textarea id="'.$self->{id}.'" name="'.$self->{name}.'" cols="'.$self->{columns}.'" rows="'.$self->{rows}.'" wrap="'.
|
||||
$self->{wrap}.'" '.$self->{extras}.'>'.$value.'</textarea>';
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->get("value"))));
|
||||
return '<textarea id="'.$self->{id}.'" name="'.$self->get("name").'" cols="'.$self->get("columns").'" rows="'.$self->get("rows").'" wrap="'.
|
||||
$self->get("wrap").'" '.$self->get("extras").'>'.$value.'</textarea>';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ Returns the number of seconds since 00:00:00 on a 24 hour clock. Note, this will
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
return WebGUI::DateTime::timeToSeconds($session{req}->param($self->{name}))-($session{user}{timeOffset}*3600);
|
||||
return WebGUI::DateTime::timeToSeconds($self->session->request->param($self->get("name")))-($self->session->user->profileField("timeOffset")*3600);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -108,13 +108,13 @@ Renders a time field.
|
|||
|
||||
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:\')"';
|
||||
my $value = WebGUI::DateTime::secondsToTime($self->get("value"));
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789:\')"';
|
||||
return $self->SUPER::toHtml
|
||||
.WebGUI::Form::Button->new(
|
||||
id=>$self->{id},
|
||||
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"',
|
||||
extras=>'style="font-size: 8pt;" onclick="window.timeField = this.form.'.$self->get("name").';clockSet = window.open(\''.$self->session->config->get("extrasURL"). '/timeChooser.html\',\'timeChooser\',\'WIDTH=230,HEIGHT=100\');return false"',
|
||||
value=>WebGUI::International::get(970)
|
||||
)->toHtml;
|
||||
}
|
||||
|
|
@ -130,8 +130,8 @@ Renders the field as a hidden field.
|
|||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
return WebGUI::Form::Hidden->new(
|
||||
name=>$self->{name},
|
||||
value=>secondsToTime($self->{value})
|
||||
name=>$self->get("name"),
|
||||
value=>secondsToTime($self->get("value"))
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ Renders a database connection picker control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->{options} = WebGUI::DateTime::getTimeZones();
|
||||
$self->get("options") = WebGUI::DateTime::getTimeZones();
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Parses the posted value and tries to make corrections if necessary.
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $session{req}->param($self->{name});
|
||||
my $value = $self->session->request->param($self->get("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) {
|
||||
|
|
@ -106,8 +106,8 @@ Renders a URL field.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/addHTTP.js',{ type=>'text/javascript' });
|
||||
$self->{extras} .= ' onBlur="addHTTP(this.form.'.$self->{name}.')"';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/addHTTP.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onBlur="addHTTP(this.form.'.$self->get("name").')"';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Returns either a 1 or 0 representing yes, no.
|
|||
|
||||
sub yesNo {
|
||||
my $self = shift;
|
||||
if ($session{req}->param($self->{name}) > 0) {
|
||||
if ($self->session->request->param($self->get("name")) > 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -102,24 +102,24 @@ Renders a yes/no question field.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my ($checkYes, $checkNo);
|
||||
if ($self->{value}) {
|
||||
if ($self->get("value")) {
|
||||
$checkYes = 1;
|
||||
} else {
|
||||
$checkNo = 1;
|
||||
}
|
||||
my $output = WebGUI::Form::Radio->new(
|
||||
checked=>$checkYes,
|
||||
name=>$self->{name},
|
||||
name=>$self->get("name"),
|
||||
value=>1,
|
||||
extras=>$self->{extras}
|
||||
extras=>$self->get("extras")
|
||||
)->toHtml;
|
||||
$output .= WebGUI::International::get(138);
|
||||
$output .= ' ';
|
||||
$output .= WebGUI::Form::Radio->new(
|
||||
checked=>$checkNo,
|
||||
name=>$self->{name},
|
||||
name=>$self->get("name"),
|
||||
value=>0,
|
||||
extras=>$self->{extras}
|
||||
extras=>$self->get("extras")
|
||||
)->toHtml;
|
||||
$output .= WebGUI::International::get(139);
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Returns a validated form post result. If the result does not pass validation, it
|
|||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $session{req}->param($self->{name});
|
||||
my $value = $self->session->request->param($self->get("name"));
|
||||
if ($value =~ /^[A-Z\d\s\-]+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -102,8 +102,8 @@ Renders a zip code field.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ type=>'text/javascript' });
|
||||
$self->{extras} .= ' onkeyup="doInputCheck(this.form.'.$self->{name}.',\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')"';
|
||||
WebGUI::Style::setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
|
||||
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')"';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue