merging form pollution fix
This commit is contained in:
parent
c1cab2299c
commit
11e4f6ea7e
78 changed files with 2666 additions and 1463 deletions
|
|
@ -69,9 +69,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("asset"),
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("asset"),
|
||||
},
|
||||
|
|
@ -81,15 +78,67 @@ sub definition {
|
|||
class=>{
|
||||
defaultValue=> undef
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'Asset')->get('asset');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Formats as a link.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($self->session,$self->getValue);
|
||||
if (defined $asset) {
|
||||
return '<a href="'.$asset->getUrl.'">'.$asset->getTitle.'</a>';
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an asset selector.
|
||||
|
|
@ -98,7 +147,7 @@ Renders an asset selector.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $self->get("value")) || WebGUI::Asset->getRoot($self->session);
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $self->getDefaultValue) || WebGUI::Asset->getRoot($self->session);
|
||||
my $url = $asset->getUrl("op=formHelper;sub=assetTree;class=Asset;formId=".$self->get('id'));
|
||||
$url .= ";classLimiter=".$self->get("class") if ($self->get("class"));
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ conjunction with one or more Rich Editors (see WebGUI::Form::HTMLArea) and shoul
|
|||
list for ease of use.
|
||||
|
||||
B<WARNING:> This form control is not capable of handling all aspects of the files uploaded to it. So you as the
|
||||
developer need to complete the process after the form has been submitted. See the getValueFromPost() method for
|
||||
developer need to complete the process after the form has been submitted. See the getValue() method for
|
||||
details.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
|
@ -85,11 +85,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("file")
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>"attachments"
|
||||
},
|
||||
|
|
@ -98,26 +94,45 @@ sub definition {
|
|||
},
|
||||
maxImageSize=>{},
|
||||
thumbnailSize=>{},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('Attachments formName');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns an array reference of asset ids that have been uploaded. New assets are uploaded to a temporary location,
|
||||
and you must move them to the place in the asset tree you want them, or they will be automatically deleted.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my @values = $self->session->form->param($self->get("name"));
|
||||
return \@values;
|
||||
|
|
@ -133,7 +148,7 @@ Renders an attachments control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my @assetIds = @{$self->get("value")};
|
||||
my @assetIds = @{$self->getDefaultValue};
|
||||
my $thumbnail = $self->get("thumbnailSize") || $self->session->setting->get("thumbnailSize");
|
||||
my $image = $self->get("maxImageSize") || $self->session->setting->get("maxImageSize");
|
||||
my $attachmentsList = "attachments=".join(";attachments=", @assetIds) if (scalar(@assetIds));
|
||||
|
|
|
|||
|
|
@ -58,21 +58,28 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session,"WebGUI");
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get('button')
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>$i18n->get(62)
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(255)",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('button');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a button.
|
||||
|
|
@ -81,7 +88,7 @@ Renders a button.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixQuotes($self->get("value"));
|
||||
my $value = $self->fixQuotes($self->getDefaultValue);
|
||||
my $html = '<input type="button" ';
|
||||
$html .= 'name="'.$self->get("name").'" ' if ($self->get("name"));
|
||||
$html .= 'id="'.$self->get('id').'" ' unless ($self->get('id') eq "_formId");
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Defaults to "Verify Your Humanity"
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
|
|
@ -63,33 +59,49 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session,"Form_Captcha");
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("topicName")
|
||||
},
|
||||
label => {
|
||||
defaultValue=>$i18n->get("verify your humanity")
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(6)",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "BOOLEAN".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "BOOLEAN";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'Form_Captcha')->get('topicName');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns a boolean indicating whether the string typed matched the image.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
my $challenge = $self->session->scratch->get("captcha_".$self->get("name"));
|
||||
$self->session->scratch->delete("captcha_".$self->get("name"));
|
||||
return (lc($value) eq lc($challenge));
|
||||
|
|
@ -97,6 +109,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a captcha field.
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Boolean representing whether the checklist should be represented vertically or horizontally. If set to "1" will be displayed vertically. Defaults to "0".
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=head4 showSelectAllButton
|
||||
|
||||
Flag that toggles a "Select All" toggle button on or off.
|
||||
|
|
@ -66,17 +62,10 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push @{$definition}, {
|
||||
formName => {
|
||||
defaultValue => $i18n->get("941"),
|
||||
},
|
||||
vertical => {
|
||||
defaultValue => 0,
|
||||
},
|
||||
profileEnabled => {
|
||||
defaultValue => 1,
|
||||
},
|
||||
showSelectAll => {
|
||||
defaultValue => 0,
|
||||
},
|
||||
|
|
@ -86,6 +75,19 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('941');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSelectAllButton ( )
|
||||
|
||||
Returns the HTML / Script for the Select All button
|
||||
|
|
@ -115,6 +117,18 @@ sub getSelectAllButton {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a series of checkboxes.
|
||||
|
|
@ -131,23 +145,21 @@ sub toHtml {
|
|||
$output .= $self->getSelectAllButton;
|
||||
}
|
||||
my $i=0;
|
||||
tie my %options, 'Tie::IxHash', $self->orderedHash();
|
||||
foreach my $key (keys %options) {
|
||||
$i++;
|
||||
my $options = $self->getOptions;
|
||||
foreach my $key (keys %{$options}) {
|
||||
$i++;
|
||||
my $checked = (grep { $_ eq $key } @{ $self->correctValues($self->get('value')) })
|
||||
? 1
|
||||
: 0
|
||||
;
|
||||
|
||||
$output
|
||||
.= WebGUI::Form::Checkbox->new($self->session, {
|
||||
$output .= WebGUI::Form::Checkbox->new($self->session, {
|
||||
name => $self->get('name'),
|
||||
value => $key,
|
||||
extras => $self->get('extras'),
|
||||
checked => $checked,
|
||||
id => $self->get('name').$i,
|
||||
})->toHtml
|
||||
. '<label for="'.$self->get('name').$i.'">'.$self->get('options')->{$key}."</label>"
|
||||
. '<label for="'.$self->get('name').$i.'">'.$options->{$key}."</label>"
|
||||
. $alignment
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,30 +53,19 @@ Defaults to "0". Set to "1" if this field should be checked.
|
|||
|
||||
The value returned by this field if it is checked and no value is specified. Defaults to "1".
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("943"),
|
||||
},
|
||||
checked=>{
|
||||
defaultValue=> 0
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -96,24 +85,27 @@ sub generateIdParameter {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return undef.
|
||||
|
||||
=head3 value
|
||||
|
||||
An optional value to process, instead of POST input.
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $formValue = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
if (defined $formValue) {
|
||||
return $formValue;
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('943');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -126,7 +118,7 @@ Renders and input tag of type checkbox.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value")))) || '';
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getDefaultValue))) || '';
|
||||
my $checkedText = $self->get("checked") ? ' checked="checked"' : '';
|
||||
my $idText = $self->get('id') ? ' id="'.$self->get('id').'" ' : '';
|
||||
return '<input type="checkbox" name="'.($self->get("name")||'').'" value="'.$value.'"'.$idText.$checkedText.' '.($self->get("extras")||'').' />';
|
||||
|
|
|
|||
|
|
@ -36,47 +36,49 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
See the super class for additional details.
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>"Class Name"
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('class name');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns a class name which has been taint checked.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ s/[^\w:]//g;
|
||||
return $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a class name field.
|
||||
|
|
|
|||
|
|
@ -59,21 +59,13 @@ Style attributes besides width and height which should be specified using the ab
|
|||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("codearea")
|
||||
},
|
||||
height=>{
|
||||
defaultValue=> 450
|
||||
},
|
||||
|
|
@ -83,18 +75,49 @@ sub definition {
|
|||
style=>{
|
||||
defaultValue => undef,
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "TEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "MEDIUMTEXT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "MEDIUMTEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('codearea');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a code area field.
|
||||
|
|
|
|||
|
|
@ -38,31 +38,32 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
See the super class for additional details.
|
||||
Returns "VARCHAR(7)".
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("color")
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(7)",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(7)";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('color');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a hex color like "#000000". Returns undef if the return value is not a valid color.
|
||||
|
||||
|
|
@ -72,15 +73,27 @@ An optional value to use instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $color = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
my $color = $self->SUPER::getValue(@_);
|
||||
return undef unless $color =~ /\#\w{6}/;
|
||||
return $color;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a color picker control.
|
||||
|
|
@ -102,7 +115,7 @@ sub toHtml {
|
|||
$style->setScript($url->extras('/yui/build/slider/slider-min.js'),{ type=>'text/javascript' });
|
||||
$style->setScript($url->extras('/colorpicker/colorpicker.js'),{ type=>'text/javascript' });
|
||||
my $id = $self->get("id");
|
||||
my $value = $self->get("value");
|
||||
my $value = $self->getDefaultValue;
|
||||
return q| <a href="javascript:WebguiColorPicker.display('|. $id. q|');" id="|. $id.q|_swatch"
|
||||
class="colorPickerFormSwatch" style="background-color: |.$value.q|;"></a>
|
||||
<input onchange="document.getElementById('|.$id.q|_swatch').style.backgroundColor=this.value;"
|
||||
|
|
|
|||
|
|
@ -41,44 +41,35 @@ The following methods are specifically available from this class. Check the supe
|
|||
=cut
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
See the super class for additional details.
|
||||
Returns "TEXT".
|
||||
|
||||
=head3 additionalTerms
|
||||
=cut
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("combobox")
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "TEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getDatabaseFieldType {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('combobox');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns an array or a carriage return ("\n") separated scalar depending
|
||||
upon whether you're returning the values into an array or a scalar. If
|
||||
|
|
@ -91,18 +82,30 @@ Optional values to process, instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
|
||||
if (@_) {
|
||||
return $self->SUPER::getValueFromPost(@_);
|
||||
return $self->SUPER::getValue(@_);
|
||||
}
|
||||
elsif ($self->session->form->param($self->get("name")."_new")) {
|
||||
my $formValue = $self->session->form->param($self->get("name")."_new");
|
||||
$formValue =~ tr/\r\n//d;
|
||||
return $formValue;
|
||||
}
|
||||
return $self->SUPER::getValueFromPost;
|
||||
return $self->SUPER::getValue(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -116,8 +119,9 @@ Renders a combo box form control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
$self->get("options")->{''} = '['.$i18n->get(582).']';
|
||||
$self->get("options")->{_new_} = $i18n->get(581).'->';
|
||||
my $options = $self->getOptions;
|
||||
$options->{''} = '['.$i18n->get(582).']';
|
||||
$options->{_new_} = $i18n->get(581).'->';
|
||||
return $self->SUPER::toHtml
|
||||
.WebGUI::Form::Text->new($self->session,
|
||||
size=>$self->session->setting->get("textBoxSize")-5,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -66,9 +78,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("1007")
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("1007")
|
||||
},
|
||||
|
|
@ -77,13 +86,38 @@ sub definition {
|
|||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>"mixed",
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('1007');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a select list form control.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ package WebGUI::Form::Control;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -41,6 +40,11 @@ Subclasses will look like this:
|
|||
my $html = $obj->toHtmlAsHidden;
|
||||
my $tableRows = $obj->toHtmlWithWrapper;
|
||||
|
||||
my $value = $obj->getValue;
|
||||
my $value = $obj->getDefaultValue;
|
||||
my $html = $obj->getValueAsHtml;
|
||||
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are available via this package.
|
||||
|
|
@ -50,23 +54,21 @@ The following methods are available via this package.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 privateName ( )
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Creates a safe, private name for additional use in multi-part forms
|
||||
like File and Image.
|
||||
Returns a boolean indicating whether the options of the list are settable. Some have a predefined set of options. This is useful in generating dynamic forms. Really only used by form controls with an "options" field, which are mostly subclasses if WebGUI::Form::List. Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub privateName {
|
||||
my ($self, $action) = @_;
|
||||
return join '_', '_', $self->get('name'), $action;
|
||||
sub areOptionsSettable {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, [ additionalTerms ] )
|
||||
|
||||
Defines the schema or parameters for a form field.
|
||||
Defines passible parameters for a form field.
|
||||
|
||||
=head3 session
|
||||
|
||||
|
|
@ -109,10 +111,6 @@ Add extra attributes to the form tag like
|
|||
|
||||
onmouseover='doSomething()'
|
||||
|
||||
=head4 formName
|
||||
|
||||
The key to look up for the form name.
|
||||
|
||||
=head4 label
|
||||
|
||||
A text label that will be displayed if toHtmlWithWrapper() is called.
|
||||
|
|
@ -155,16 +153,6 @@ A stylesheet class assigned to each label/field pair.
|
|||
|
||||
A text string that will pop up when the user hovers over the label when toHtmlWithWrapper() is called. This string should indicate how to use the field and is usually tied into the help system.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=head4 dbDataType
|
||||
|
||||
The SQL data type for this form element. Fields created using this form control
|
||||
will create a column with this data type. If undef, will not create a database
|
||||
column. Defaults to "VARCHAR(255)".
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
|
|
@ -172,9 +160,6 @@ sub definition {
|
|||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>'A name for this form was not supplied'
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
|
|
@ -220,12 +205,6 @@ sub definition {
|
|||
idPrefix=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(255)",
|
||||
},
|
||||
});
|
||||
return $definition;
|
||||
}
|
||||
|
|
@ -234,51 +213,39 @@ sub definition {
|
|||
|
||||
=head2 displayForm ( )
|
||||
|
||||
This utility method is used to format values for the Profile system but can
|
||||
be used in other areas as well. Most form elements will just return toHtml.
|
||||
Depricated, see toHtml().
|
||||
|
||||
=cut
|
||||
|
||||
sub displayForm {
|
||||
my ($self) = @_;
|
||||
$self->toHtml;
|
||||
my $self = shift;
|
||||
return $self->toHtml(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayFormWithWrapper ( )
|
||||
|
||||
This utility method is used to format values for the Profile system but can
|
||||
be used in other areas as well. Most form elements will just return displayForm.
|
||||
Depricated, see toHtmlWithWrapper().
|
||||
|
||||
=cut
|
||||
|
||||
sub displayFormWithWrapper {
|
||||
my $self = shift;
|
||||
if ($self->passUiLevelCheck) {
|
||||
my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext) = $self->prepareWrapper;
|
||||
$hoverHelp &&= '<div class="wg-hoverhelp">' . $hoverHelp . '</div>';
|
||||
return '<tr'.$rowClass.'>
|
||||
<td'.$labelClass.' valign="top" style="width: 25%;">'.$self->get("label") . $hoverHelp . '</td>
|
||||
<td valign="top"'.$fieldClass.' style="width: 75%;">'.$self->displayForm().$subtext."</td>
|
||||
</tr>\n";
|
||||
} else {
|
||||
return $self->toHtmlAsHidden;
|
||||
}
|
||||
return $self->toHtmlWithWrapper(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayValue ( )
|
||||
|
||||
This utility method is used to format values for the Profile system. Most
|
||||
form elements will just return their value.
|
||||
Depricated, see getValueAsHtml().
|
||||
|
||||
=cut
|
||||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return $self->get("value");
|
||||
return $self->getValueAsHtml;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -300,39 +267,6 @@ sub generateIdParameter {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=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 ( )
|
||||
|
||||
Returns a human readable name for this form control type. You MUST override this method with your own when creating new form controls.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
my $definition = $self->definition($session);
|
||||
return $definition->[0]->{formName}->{defaultValue};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -348,9 +282,9 @@ The string to search for macros in.
|
|||
|
||||
sub fixMacros {
|
||||
my $self = shift;
|
||||
my $value = shift;
|
||||
$value =~ s/\^/\&\#94\;/g;
|
||||
return $value;
|
||||
my $value = shift;
|
||||
$value =~ s/\^/\&\#94\;/g;
|
||||
return $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -413,9 +347,52 @@ sub fixTags {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 get ( var )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead.
|
||||
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 getDatabaseFieldType ( )
|
||||
|
||||
A class method that tells you what database field type this form field should be stored in. Defaults to "VARCHAR(255)".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(255)";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns a human readable name for this form control type. You MUST override this method with your own when creating new form controls.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
return "Override Me";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Gets the value of this form field from the following sources in order: passed in value, form post/get value, definition value, definition default value.
|
||||
|
||||
=head3 value
|
||||
|
||||
|
|
@ -423,30 +400,75 @@ An optional value to process, instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my ($self, $value) = @_;
|
||||
return $value if (defined $value);
|
||||
if ($self->session->request) {
|
||||
$value = $self->session->form->param($self->get("name"));
|
||||
return $value if (defined $value);
|
||||
}
|
||||
return $self->getDefaultValue;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefaultValue ( )
|
||||
|
||||
Returns the either the "value" ore "defaultValue" passed in to the object in that order, and doesn't take into account form processing.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDefaultValue {
|
||||
my $self = shift;
|
||||
my $value = $self->get("value");
|
||||
return $value if (defined $value);
|
||||
return $self->get("defaultValue");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Returns the value rendered suitably in HTML. This is useful for forms that are rendered dynamically like user profiling and Thingy.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
return $self->getValue(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost
|
||||
|
||||
Depricated. See getValue().
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $formValue;
|
||||
my $self = shift;
|
||||
return $self->getValue(@_);
|
||||
}
|
||||
|
||||
if (@_) {
|
||||
$formValue = shift;
|
||||
}
|
||||
elsif ($self->session->request) {
|
||||
$formValue = $self->session->form->param($self->get("name"));
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
if (defined $formValue) {
|
||||
return $formValue;
|
||||
} else {
|
||||
return $self->get("defaultValue");
|
||||
}
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control. Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isProfileEnabled ( session )
|
||||
|
||||
A class method. Returns a 1 if this control can be used by the profiling system. In general that means that the
|
||||
field is safe for dynamic generation.
|
||||
Depricated. See isDynamicCompatible().
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -454,7 +476,7 @@ field is safe for dynamic generation.
|
|||
sub isProfileEnabled {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
return $class->definition($session)->[0]{profileEnabled};
|
||||
return $class->isDynamicCompatible();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -526,6 +548,29 @@ sub new {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 passUiLevelCheck ( )
|
||||
|
||||
Renders the form field to HTML as a table row complete with labels, subtext, hoverhelp, etc.
|
||||
|
||||
=cut
|
||||
|
||||
sub passUiLevelCheck {
|
||||
my $self = shift;
|
||||
my $passUiLevelCheck = 0;
|
||||
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->get("uiLevel") <= $self->session->user->profileField("uiLevel"));
|
||||
}
|
||||
$passUiLevelCheck = $self->session->user->isInGroup(3) unless ($passUiLevelCheck); # override if in admins group
|
||||
return $passUiLevelCheck;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareWrapper ( )
|
||||
|
|
@ -550,6 +595,19 @@ sub prepareWrapper {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 privateName ( )
|
||||
|
||||
Creates a safe, private name for additional use in multi-part forms like File and Image.
|
||||
|
||||
=cut
|
||||
|
||||
sub privateName {
|
||||
my ($self, $action) = @_;
|
||||
return join '_', '_', $self->get('name'), $action;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ( )
|
||||
|
|
@ -636,27 +694,6 @@ sub toHtmlWithWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 passUiLevelCheck ( )
|
||||
|
||||
Renders the form field to HTML as a table row complete with labels, subtext, hoverhelp, etc.
|
||||
|
||||
=cut
|
||||
|
||||
sub passUiLevelCheck {
|
||||
my $self = shift;
|
||||
my $passUiLevelCheck = 0;
|
||||
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->get("uiLevel") <= $self->session->user->profileField("uiLevel"));
|
||||
}
|
||||
$passUiLevelCheck = $self->session->user->isInGroup(3) unless ($passUiLevelCheck); # override if in admins group
|
||||
return $passUiLevelCheck;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -59,9 +71,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get('country')
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get('country')
|
||||
},
|
||||
|
|
@ -71,18 +80,45 @@ sub definition {
|
|||
defaultValue=>{
|
||||
defaultValue=>"United States"
|
||||
},
|
||||
});
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('country');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a country picker control.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my %countries;
|
||||
tie %countries, 'Tie::IxHash';
|
||||
%countries = (
|
||||
|
|
@ -329,8 +365,6 @@ tie %countries, 'Tie::IxHash';
|
|||
'Zimbabwe' => 'Zimbabwe'
|
||||
);
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->set("options", \%countries);
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -75,9 +87,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("1075")
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("1075")
|
||||
},
|
||||
|
|
@ -93,15 +102,49 @@ sub definition {
|
|||
hoverHelp=>{
|
||||
defaultValue=>$i18n->get('1075 description')
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('1075');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a database connection picker control.
|
||||
|
|
@ -127,11 +170,10 @@ sub toHtmlWithWrapper {
|
|||
if ($self->session->user->isInGroup(3)) {
|
||||
my $subtext;
|
||||
if ($self->get("afterEdit")) {
|
||||
$subtext = $self->session->icon->edit("op=editDatabaseLink;lid=".$self->get("value").";afterEdit=".$self->session->url->escape($self->get("afterEdit")));
|
||||
$subtext = $self->session->icon->edit("op=editDatabaseLink;lid=".$self->getDefaultValue.";afterEdit=".$self->session->url->escape($self->get("afterEdit")));
|
||||
}
|
||||
$subtext .= $self->session->icon->manage("op=listDatabaseLinks");
|
||||
$self->set("subtext", $subtext . $self->get("subtext"));
|
||||
# $self->get("subtext") = $subtext . $self->get("subtext");
|
||||
}
|
||||
return $self->SUPER::toHtmlWithWrapper;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,21 +71,13 @@ If no value is specified, this will be used. Defaults to today and now.
|
|||
If the defaultValue is a MySQL date string, this form control will return MySQL
|
||||
date strings instead of epoch times.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("352")
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>$session->datetime->time()
|
||||
},
|
||||
|
|
@ -98,42 +90,38 @@ sub definition {
|
|||
noDate=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "BIGINT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayValue ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Return the date in a human readable format for the Profile system.
|
||||
Returns "BIGINT".
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
return $self->session->datetime->epochToHuman($self->get("value"),"%z");
|
||||
} else {
|
||||
# MySQL format
|
||||
my $value = $self->get("value");
|
||||
return $value;
|
||||
}
|
||||
sub getDatabaseFieldType {
|
||||
return "BIGINT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('352');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a validated form post result. If the result does not pass validation,
|
||||
it returns undef instead.
|
||||
|
|
@ -144,18 +132,16 @@ An optional value to process, instead of POST input. This should be in the 'YY(Y
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
return $self->session->datetime->setToEpoch(@_ ? shift : $self->session->form->param($self->get("name")));
|
||||
} else {
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ m/^\d+$/) {
|
||||
return $self->session->datetime->setToEpoch($value);
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
# YY(YY)?-MM-DD
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
|
||||
|
|
@ -166,6 +152,42 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Return the date in a human readable format.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
return $self->session->datetime->epochToHuman($self->getValue,"%z");
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
my $value = $self->getValue;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a date picker control.
|
||||
|
|
@ -185,11 +207,11 @@ sub toHtml {
|
|||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $self->set("value",$self->session->datetime->epochToSet($self->get("value")));
|
||||
$value = $self->set("value",$self->session->datetime->epochToSet($self->getDefaultValue));
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
$value = $self->get("value");
|
||||
$value = $self->getDefaultValue;
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
}
|
||||
|
||||
|
|
@ -238,10 +260,10 @@ sub toHtmlAsHidden {
|
|||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
$value = $self->session->datetime->epochToSet($self->get("value"),"%z");
|
||||
$value = $self->session->datetime->epochToSet($self->getDefaultValue,"%z");
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->get("value");
|
||||
$value = $self->getDefaultValue;
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,10 +62,6 @@ Defaults to 19. Determines the maximum number of characters allowed in this fiel
|
|||
|
||||
Defaults to 19. The displayed size of the box for the date to be typed in.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=head4 defaultValue
|
||||
|
||||
If no value is specified, this will be used. Defaults to today and now.
|
||||
|
|
@ -79,11 +75,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("972")
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>$session->datetime->time()
|
||||
},
|
||||
|
|
@ -93,19 +85,38 @@ sub definition {
|
|||
size=>{
|
||||
defaultValue=> 19
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "BIGINT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "BIGINT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "BIGINT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('972');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a validated form post result. If the result does not pass validation, it returns undef instead.
|
||||
|
||||
|
|
@ -115,23 +126,20 @@ An optional value to process, instead of POST input. This should be in the 'YY(Y
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if (!$self->get("defaultValue") || $self->get("defaultValue") =~ m/^\d+$/ || !$self->get("value") || $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
return $self->session->datetime->setToEpoch(@_ ? shift : $self->session->form->param($self->get("name")));
|
||||
} else {
|
||||
return $self->session->datetime->setToEpoch($value);
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
# YY(YY)?-MM-DD HH:MM:SS
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
$self->session->errorHandler->warn("Date value: $value");
|
||||
|
||||
# Verify format
|
||||
return
|
||||
return undef
|
||||
unless ($value =~ m/(?:\d{2}|\d{4})\D\d{2}\D\d{2}\D\d{2}\D\d{2}\D\d{2}/);
|
||||
|
||||
# Fix time zone
|
||||
|
|
@ -144,6 +152,42 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Return the date in a human readable format.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
return $self->session->datetime->epochToHuman($self->getDefaultValue,"%z %Z");
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
my $value = $self->getDefaultValue;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a date picker control.
|
||||
|
|
@ -159,10 +203,10 @@ sub toHtml {
|
|||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $self->session->datetime->epochToSet($self->get("value"),1);
|
||||
$value = $self->session->datetime->epochToSet($self->getDefaultValue,1);
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->get("value");
|
||||
$value = $self->getDefaultValue;
|
||||
# Fix time zone
|
||||
$value = WebGUI::DateTime->new($value)
|
||||
->set_time_zone($self->session->user->profileField("timeZone"))
|
||||
|
|
@ -214,10 +258,10 @@ sub toHtmlAsHidden {
|
|||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
$value = $self->session->datetime->epochToSet($self->get("value"),1);
|
||||
$value = $self->session->datetime->epochToSet($self->getDefaultValue,1);
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->get("value");
|
||||
$value = $self->getDefaultValue;
|
||||
# Fix Time zone
|
||||
$value = WebGUI::DateTime->new($value)
|
||||
->set_time_zone($self->session->user->profileField("timeZone"))
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::Form::DynamicField;
|
|||
use strict;
|
||||
use base 'WebGUI::Form::Control';
|
||||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -57,11 +58,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("475"),
|
||||
},
|
||||
fieldType=>{
|
||||
defaultValue=> "Text"
|
||||
},
|
||||
|
|
@ -71,6 +68,19 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('475');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( params)
|
||||
|
||||
Creates the object for the appropriate field type.
|
||||
|
|
@ -99,12 +109,11 @@ sub new {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my %raw = @_;
|
||||
my $param = \%raw;
|
||||
my $fieldType = ucfirst($param->{fieldType});
|
||||
delete $param->{fieldType};
|
||||
my $fieldType = ucfirst($raw{fieldType});
|
||||
delete $raw{fieldType};
|
||||
# Return the appropriate field object.
|
||||
if ($fieldType eq "") {
|
||||
$session->errorHandler->warn("Something is trying to create a dynamic field called ".$param->{name}.", but didn't pass in a field type.");
|
||||
$session->errorHandler->warn("Something is trying to create a dynamic field called ".$raw{name}.", but didn't pass in a field type.");
|
||||
$fieldType = "Text";
|
||||
}
|
||||
##No infinite loops, please
|
||||
|
|
@ -112,23 +121,7 @@ sub new {
|
|||
$session->errorHandler->warn("Something is trying to create a DynamicField via DynamicField.");
|
||||
$fieldType = "Text";
|
||||
}
|
||||
no strict 'refs';
|
||||
my $cmd = "WebGUI::Form::".$fieldType;
|
||||
my $load = "use ".$cmd;
|
||||
eval ($load);
|
||||
if ($@) {
|
||||
$session->errorHandler->error("Couldn't compile form control: ".$fieldType.". Root cause: ".$@);
|
||||
return undef;
|
||||
}
|
||||
my $formObj = $cmd->new($session, $param);
|
||||
if ($formObj->isa('WebGUI::Form::List')) {
|
||||
$formObj->correctValues($param->{value});
|
||||
$formObj->correctOptions($param->{possibleValues});
|
||||
}
|
||||
if ($param->{size}) {
|
||||
$formObj->set('size',$param->{size});
|
||||
}
|
||||
return $formObj;
|
||||
return WebGUI::Pluggable::instanciate("WebGUI::Form::".$fieldType, "new", [$session, \%raw]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,41 +36,23 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("480")
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('480');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a validated email address. If the result does not pass validation, it returns undef instead.
|
||||
|
||||
|
|
@ -80,7 +62,7 @@ An optional value to process instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
if ($value =~ /^([0-9a-zA-Z]([-.+\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/i) {
|
||||
|
|
@ -91,6 +73,33 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Formats as an email link.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $email = $self->getValue;
|
||||
return '<a href="mailto:'.$email.'">'.$email.'</a>';
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an email address field.
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ package WebGUI::Form::FieldType;
|
|||
|
||||
use strict;
|
||||
use base 'WebGUI::Form::SelectBox';
|
||||
use WebGUI::International;
|
||||
use WebGUI::Utility;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ Package WebGUI::Form::FieldType
|
|||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a form control that will allow you to select a form control type.
|
||||
Creates a form control that will allow you to select a form control type. It's meant to be used in conjunction with the DynamicField form control.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
|
|
@ -40,6 +41,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -50,7 +63,7 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
=head4 types
|
||||
|
||||
An array reference containing the form control types to be selectable. Defaults to all available types.
|
||||
An array reference containing the form control types to be selectable. Defaults to all available dynamic types.
|
||||
|
||||
=head4 label
|
||||
|
||||
|
|
@ -64,63 +77,87 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("fieldtype","WebGUI")
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("fieldtype","WebGUI")
|
||||
},
|
||||
types=>{
|
||||
defaultValue=>$class->getTypes($session)
|
||||
}
|
||||
});
|
||||
defaultValue=>[],
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getTypes ( )
|
||||
=head2 getName ( session )
|
||||
|
||||
A class method that returns an array reference of all the valid form
|
||||
control types present in the system. Invalid form types include
|
||||
Control.pm, the form master class and List, the list form master class
|
||||
and DynamicField, the form class dispatcher.
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTypes {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
opendir(DIR,$session->config->getWebguiRoot."/lib/WebGUI/Form/");
|
||||
my @rawTypes = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my @types;
|
||||
foreach my $type (@rawTypes) {
|
||||
if ($type =~ /^(.*)\.pm$/) {
|
||||
next if (isIn($1, qw/Control List DynamicField/));
|
||||
push(@types,$1);
|
||||
}
|
||||
}
|
||||
return \@types;
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('fieldType');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getTypes ( )
|
||||
|
||||
Returns a hash reference of field types and human readable names. Defaultly returns all that have isDynamicCompatible() set to 1, but if types is specified in the constructor, will return the ones from that list.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTypes {
|
||||
my $self = shift;
|
||||
my @types = @{$self->get('types')};
|
||||
unless (scalar(@types)) {
|
||||
opendir(DIR,$self->session->config->getWebguiRoot."/lib/WebGUI/Form/");
|
||||
foreach my $type (readdir(DIR)) {
|
||||
if ($type =~ s/^(.*)\.pm$/$1/) {
|
||||
if (WebGUI::Pluggable::instanciate('WebGUI::Form::'.ucfirst($type),'isDynamicCompatible')) {
|
||||
push @types, $type;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
}
|
||||
my %fields = ();
|
||||
foreach my $type (@types) {
|
||||
$fields{$type} = WebGUI::Pluggable::instanciate('WebGUI::Form::'.ucfirst($type), 'getName', [$self->session]);
|
||||
}
|
||||
return \%fields;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns either what's posted or if nothing comes back it returns "text".
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $fieldType = $self->session->form->param($self->get("name"));
|
||||
my $fieldType = $self->SUPER::getValue(@_);
|
||||
$fieldType =~ s/[^\w]//g;
|
||||
return $fieldType || "text";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a fieldType selector.
|
||||
|
|
@ -131,19 +168,7 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my %options;
|
||||
tie %options, "Tie::IxHash";
|
||||
foreach my $type (@{ $self->get('types') }) {
|
||||
my $class = "WebGUI::Form::".ucfirst($type);
|
||||
my $cmd = "use ".$class;
|
||||
eval ($cmd);
|
||||
if ($@) {
|
||||
$self->session->errorHandler->error("Couldn't compile form control: ".$type.". Root cause: ".$@);
|
||||
next;
|
||||
}
|
||||
next unless $class->isProfileEnabled($self->session);
|
||||
$options{$type} = $class->getName($self->session);
|
||||
}
|
||||
$self->set('options',\%options);
|
||||
|
||||
$self->set('options', $self->getTypes);
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,10 +57,6 @@ If no name is specified a default name of "file" will be used.
|
|||
How many attachments will be allowed to be uploaded. However, the file form
|
||||
only supports displaying/deleting 1 attachment.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=head4 deleteFileUrl
|
||||
|
||||
A url that will get a filename appended to it and then links to delete the files will be generated automatically.
|
||||
|
|
@ -75,76 +71,46 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("file")
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>"file"
|
||||
},
|
||||
maxAttachments=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
deleteFileUrl=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>40
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayForm ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
If an file is uploaded, then return an icon for that file's type and a control to
|
||||
delete it. Otherwise, display a form element to upload a file.
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
||||
sub displayForm {
|
||||
my ($self) = @_;
|
||||
return $self->toHtml unless $self->get("value");
|
||||
##There are files inside here, for each one, display the file icon
|
||||
##and another form control for deleting it.
|
||||
my $location = WebGUI::Storage->get($self->session,$self->get("value"));
|
||||
my $fileForm = '';
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $file = shift @{ $location->getFiles };
|
||||
$fileForm .= sprintf qq!<img src="%s" /><br />!, $location->getFileIconUrl($file);
|
||||
$fileForm .= $i18n->get(392)
|
||||
. " "x4
|
||||
. WebGUI::Form::YesNo->new($self->session,{-name=>$self->privateName('delete'), -value=>0})->toHtml;
|
||||
$fileForm .= $self->toHtmlAsHidden();
|
||||
$fileForm .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'keep'})->toHtml();
|
||||
return $fileForm;
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayValue ( )
|
||||
=head2 getName ( session )
|
||||
|
||||
This utility method is used to format values for the Profile system. Most
|
||||
form elements will just return their value.
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return '' unless $self->get("value");
|
||||
my $location = WebGUI::Storage->get($self->session,$self->get("value"));
|
||||
my $file = shift @{ $location->getFiles };
|
||||
my $fileValue = sprintf qq|<img src="%s" /> <a href="%s">%s</a>|, $location->getFileIconUrl($file), $location->getUrl($file), $file;
|
||||
return $fileValue;
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('file');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -162,6 +128,7 @@ A WebGUI::Storage object.
|
|||
sub getFilePreview {
|
||||
my $self = shift;
|
||||
my $storage = shift;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $preview = "";
|
||||
foreach my $file (@{$storage->getFiles}) {
|
||||
if ($self->get("deleteFileUrl")) {
|
||||
|
|
@ -171,10 +138,12 @@ sub getFilePreview {
|
|||
$preview .= '<p style="display:inline;vertical-align:middle;"><a href="'.$storage->getUrl($file).'">'
|
||||
.'<img src="'.$storage->getFileIconUrl($file).'" style="vertical-align:middle;border: 0px;" alt="'
|
||||
.$file.'" /> '.$file.'</a></p><br />';
|
||||
$preview .= $i18n->get(392) . (" "x4) . WebGUI::Form::YesNo->new($self->session,{name=>$self->privateName('delete'), value=>0})->toHtml;
|
||||
}
|
||||
return $preview;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageLocation ( )
|
||||
|
|
@ -185,14 +154,15 @@ Returns the WebGUI::Storage object for this control.
|
|||
|
||||
sub getStorageLocation {
|
||||
my $self = shift;
|
||||
my $storage = WebGUI::Storage->get($self->session, $self->get("value")) if ($self->get("value"));
|
||||
my $value = $self->getDefaultValue;
|
||||
my $storage = WebGUI::Storage->get($self->session, $value) if ( defined $value );
|
||||
return $storage;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns the storageId for the storage location that the file(s) got
|
||||
uploaded to. Returns undef if no files were uploaded. Also handles
|
||||
|
|
@ -200,7 +170,7 @@ deleting the file if it was specified.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = $self->get("value");
|
||||
if ($self->session->form->param($self->privateName('delete'))) {
|
||||
|
|
@ -232,6 +202,36 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Displays the file as a link.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
my $value = $self->getValue;
|
||||
return '' unless $value;
|
||||
my $location = WebGUI::Storage->get($self->session,$value);
|
||||
my $file = shift @{ $location->getFiles };
|
||||
my $fileValue = sprintf qq|<img src="%s" /> <a href="%s">%s</a>|, $location->getFileIconUrl($file), $location->getUrl($file), $file;
|
||||
return $fileValue;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a file upload control.
|
||||
|
|
@ -274,7 +274,7 @@ sub toHtml {
|
|||
else {
|
||||
$uploadControl .= WebGUI::Form::Hidden->new($self->session, {
|
||||
name => $self->get("name"),
|
||||
value => $self->get("value"),
|
||||
value => $self->getDefaultValue,
|
||||
id => $self->get("id")
|
||||
})->toHtml()."<br />";
|
||||
$uploadControl .= WebGUI::Form::Hidden->new($self->session, {
|
||||
|
|
@ -284,6 +284,9 @@ sub toHtml {
|
|||
})->toHtml()."<br />";
|
||||
}
|
||||
if (scalar(@files)) {
|
||||
if ($self->get('maxAttachments') == 1) {
|
||||
$self->set("");
|
||||
}
|
||||
$uploadControl .= $self->getFilePreview($storage);
|
||||
}
|
||||
return $uploadControl;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -67,9 +79,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("418")
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>"filterContent"
|
||||
},
|
||||
|
|
@ -79,24 +88,58 @@ sub definition {
|
|||
defaultValue=>{
|
||||
defaultValue=>"most",
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(16)",
|
||||
},
|
||||
});
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(16)".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(16)";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('418');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns either what's posted or if nothing comes back it returns "most".
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
return $self->session->form->param($self->get("name")) || "most";
|
||||
return $self->SUPER::getValue(@_) || "most";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -58,21 +58,13 @@ Defaults to 0. Used if no value is specified.
|
|||
|
||||
Defaults to 11. The number of characters that will be displayed at once in this field. Usually no need to override the default.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("float")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 14
|
||||
},
|
||||
|
|
@ -82,19 +74,38 @@ sub definition {
|
|||
size=>{
|
||||
defaultValue=>11
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "DOUBLE",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "DOUBLE".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "DOUBLE";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('float');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns the integer from the form post, or returns 0.0 if the post result is invalid.
|
||||
|
||||
|
|
@ -104,9 +115,9 @@ An optional value to process, instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if ($value =~ /^-?[\d\.]+$/ and $value =~ /\d/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -115,6 +126,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a floating point field.
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -63,21 +75,13 @@ An array reference containing a list of groups to exclude from the list. Default
|
|||
|
||||
This will be used if no value is specified. Should be passed as an array reference. Defaults to 7 (Everyone).
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("group")
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
|
|
@ -90,18 +94,67 @@ sub definition {
|
|||
excludeGroups=>{
|
||||
defaultValue=>[]
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('group');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Formats as a name.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $group = WebGUI::Group->new($self->session, $self->getValue);
|
||||
if (defined $group) {
|
||||
return $group->name;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Returns a group pull-down field. A group pull down provides a select list that provides name value pairs for all the groups in the WebGUI system.
|
||||
|
|
|
|||
|
|
@ -67,21 +67,13 @@ Style attributes besides width and height which should be specified using the ab
|
|||
|
||||
The ID of the WebGUI::Asset::RichEdit object to load. Defaults to the richEditor setting or "PBrichedit000000000001" if that's not set.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("477")
|
||||
},
|
||||
height=>{
|
||||
defaultValue=> 400
|
||||
},
|
||||
|
|
@ -94,19 +86,38 @@ sub definition {
|
|||
richEditId=>{
|
||||
defaultValue=>$session->setting->get("richEditor") || "PBrichedit000000000001"
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "LONGTEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "LONGTEXT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "LONGTEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('477');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns the value of this form field after stipping unwanted tags like <body>.
|
||||
|
||||
|
|
@ -116,12 +127,24 @@ An optional value to process, instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
return WebGUI::HTML::cleanSegment($self->SUPER::getValueFromPost(@_));
|
||||
return WebGUI::HTML::cleanSegment($self->SUPER::getValue(@_));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
|
@ -521,7 +544,7 @@ sub www_addImageSave {
|
|||
return $session->privilege->insufficient('bare') unless $base->canEdit;
|
||||
|
||||
#my $imageId = WebGUI::Form::Image->create($session);
|
||||
my $imageId = WebGUI::Form::Image->new($session,{name => 'filename'})->getValueFromPost;
|
||||
my $imageId = WebGUI::Form::Image->new($session,{name => 'filename'})->getDefaultValue;
|
||||
my $imageObj = WebGUI::Storage::Image->get($session, $imageId);
|
||||
##This is a hack. It should use the WebGUI::Form::File API to insulate
|
||||
##us from future form name changes.
|
||||
|
|
|
|||
|
|
@ -62,21 +62,13 @@ The length of the input box.
|
|||
|
||||
Pad the value to padLength characters by adding zeros in front if necesarry.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=> $i18n->get("hex slider")
|
||||
},
|
||||
maximum=>{
|
||||
defaultValue=> "ff",
|
||||
},
|
||||
|
|
@ -89,9 +81,6 @@ sub definition {
|
|||
padLength=>{
|
||||
defaultValue=>"2",
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -160,17 +149,16 @@ sub getOnChangeSlider {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
#=head2 getSliderMaximum ( )
|
||||
#
|
||||
#Returns the maximum value the slider can be set to in slider units.
|
||||
#
|
||||
#=cut
|
||||
#
|
||||
#sub getSliderMaximum {
|
||||
# my $self = shift;
|
||||
#
|
||||
# return scalar(keys %{$self->get('options')}) - 1;
|
||||
#}
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('hex slider');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -216,13 +204,13 @@ sub getSliderValue {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getValue ( )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
|
||||
my $properties = {
|
||||
|
|
@ -232,7 +220,19 @@ sub getValueFromPost {
|
|||
id => 'view-'.$self->get('id'),
|
||||
};
|
||||
|
||||
return WebGUI::Form::Hexadecimal->new($self->session, $properties)->getValueFromPost;
|
||||
return WebGUI::Form::Hexadecimal->new($self->session, $properties)->getValue;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -58,21 +58,13 @@ Defaults to 0. Used if no value is specified.
|
|||
|
||||
Defaults to 11. The number of characters that will be displayed at once in this field. Usually no need to override the default.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("hexadecimal")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 11
|
||||
},
|
||||
|
|
@ -82,24 +74,34 @@ sub definition {
|
|||
size=>{
|
||||
defaultValue=>11
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('hexadecimal');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns the integer from the form post, or returns 0 if the post result is invalid.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if ($value =~ /^[0-9a-f]+$/i) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -108,6 +110,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an integer field.
|
||||
|
|
|
|||
|
|
@ -36,37 +36,6 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("hidden")
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -82,6 +51,31 @@ sub generateIdParameter {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('hidden');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
A synonym for toHtmlAsHidden.
|
||||
|
|
@ -103,7 +97,7 @@ Renders an input tag of type hidden.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value")))) || '';
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getDefaultValue))) || '';
|
||||
my $idText = $self->get('id') ? ' id="'.$self->get('id').'" ' : '';
|
||||
return '<input type="hidden" name="'.($self->get("name")||'').'" value="'.$value.'" '.($self->get("extras")||'').$idText.' />'."\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,47 +36,42 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
See the super class for additional details.
|
||||
Returns "TEXT".
|
||||
|
||||
=head3 additionalTerms
|
||||
=cut
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
sub getDatabaseFieldType {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
=head4 options
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
A hash reference containing name value pairs. The name of each pair will be used to fill the value attribute of the hidden field. Defaults to an empty hash reference.
|
||||
=head2 getName ( session )
|
||||
|
||||
=head4 defaultValue
|
||||
|
||||
value and defaultValue are array referneces containing the names from the options list that should be stored.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("hidden list"),
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "TEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('hidden list');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -53,10 +53,6 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
If no name is specified a default name of "file" will be used.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=head4 forceImageOnly
|
||||
|
||||
When set, form control will not allow file uploads unless the file has recognized image file extension
|
||||
|
|
@ -67,74 +63,18 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("image")
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>"image"
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
forceImageOnly=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayForm ( )
|
||||
|
||||
If an image is uploaded, then return the image and a control to
|
||||
delete it. Otherwise, display a form element to upload a file.
|
||||
|
||||
=cut
|
||||
|
||||
sub displayForm {
|
||||
my ($self) = @_;
|
||||
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::Image->get($self->session, $self->get('value'));
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $fileForm = '';
|
||||
my $file = shift @{ $location->getFiles };
|
||||
$fileForm .= sprintf qq!<img src="%s" /><br />!, $location->getUrl($file);
|
||||
$fileForm .= $i18n->get(392)
|
||||
. " "x4
|
||||
. WebGUI::Form::YesNo->new($self->session, {-name=>$self->privateName('delete'), -value=>0})->toHtml;
|
||||
$fileForm .= $self->toHtmlAsHidden();
|
||||
$fileForm .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'keep'})->toHtml();
|
||||
return $fileForm;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayValue ( )
|
||||
|
||||
This utility method is used to format values for the Profile system. It
|
||||
displays each image in the storage location that is the value of the
|
||||
profile field.
|
||||
|
||||
=cut
|
||||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return '' unless $self->get("value");
|
||||
my $location = WebGUI::Storage::Image->get($self->session,$self->get("value"));
|
||||
my $file = shift @{ $location->getFiles };
|
||||
my $fileValue = sprintf qq|<img src="%s" /> %s|, $location->getUrl($file), $file;
|
||||
return $fileValue;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFilePreview ( storage )
|
||||
|
|
@ -151,6 +91,7 @@ sub getFilePreview {
|
|||
my $self = shift;
|
||||
my $storage = shift;
|
||||
my $preview = "";
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
foreach my $file (@{$storage->getFiles}) {
|
||||
if ($self->get("deleteFileUrl")) {
|
||||
$preview .= '<p style="display:inline;vertical-align:middle;"><a href="'.$self->get("deleteFileUrl").$file.'">'
|
||||
|
|
@ -160,12 +101,26 @@ sub getFilePreview {
|
|||
$preview .= '<p style="display:inline;vertical-align:middle;"><a href="'.$storage->getUrl($file).'">'
|
||||
.'<img src="'.$image.'" style="vertical-align:middle;border: 0px;" alt="'
|
||||
.$file.'" /> '.$file.'</a></p><br />';
|
||||
$preview .= $i18n->get(392) . " "x4 . WebGUI::Form::YesNo->new($self->session, {-name=>$self->privateName('delete'), -value=>0})->toHtml;
|
||||
}
|
||||
return $preview;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('image');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageLocation ( )
|
||||
|
||||
Returns the WebGUI::Storage object for this control.
|
||||
|
|
@ -174,22 +129,23 @@ Returns the WebGUI::Storage object for this control.
|
|||
|
||||
sub getStorageLocation {
|
||||
my $self = shift;
|
||||
my $storage = WebGUI::Storage::Image->get($self->session, $self->get("value")) if ($self->get("value"));
|
||||
my $value = $self->getDefaultValue;
|
||||
my $storage = WebGUI::Storage::Image->get($self->session, $value) if ($value);
|
||||
return $storage;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getValue ( )
|
||||
|
||||
See WebGUI::Form::File::getValueFromPost() for details. Generates a thumbnail.
|
||||
See WebGUI::Form::File::getValue() for details. Generates a thumbnail.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $id = $self->SUPER::getValueFromPost(@_);
|
||||
my $id = $self->SUPER::getValue(@_);
|
||||
if (defined $id) {
|
||||
my $storage = WebGUI::Storage::Image->get($self->session, $id);
|
||||
if (defined $storage) {
|
||||
|
|
@ -207,5 +163,35 @@ sub getValueFromPost {
|
|||
return $id;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Displays the image using an img tag.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
my $value = $self->getValue;
|
||||
return '' unless $value;
|
||||
my $location = WebGUI::Storage::Image->get($self->session, $value);
|
||||
my $file = shift @{ $location->getFiles };
|
||||
my $fileValue = sprintf qq|<img src="%s" /> %s|, $location->getUrl($file), $file;
|
||||
return $fileValue;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -50,36 +50,34 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
The length of the input box.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=> $i18n->get("int slider")
|
||||
},
|
||||
size=>{
|
||||
defaultValue=> "3",
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "BIGINT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "BIGINT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "BIGINT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInputElement ( )
|
||||
|
||||
Returns the form element used for manual input.
|
||||
|
|
@ -99,6 +97,19 @@ sub getInputElement {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('int slider');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOnChangeInputElement ( )
|
||||
|
||||
Returns the javascript code to update the slider and other form elements on a
|
||||
|
|
@ -130,7 +141,7 @@ sub getOnChangeSlider {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value.
|
||||
|
||||
|
|
@ -140,7 +151,7 @@ A value to process instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my @args = @_;
|
||||
|
||||
|
|
@ -151,7 +162,19 @@ sub getValueFromPost {
|
|||
id => 'view-'.$self->get('id'),
|
||||
};
|
||||
|
||||
return WebGUI::Form::Integer->new($self->session, $properties)->getValueFromPost(@args);
|
||||
return WebGUI::Form::Integer->new($self->session, $properties)->getValue(@args);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -58,21 +58,13 @@ Defaults to 0. Used if no value is specified.
|
|||
|
||||
Defaults to 11. The number of characters that will be displayed at once in this field. Usually no need to override the default.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("482")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 11
|
||||
},
|
||||
|
|
@ -82,19 +74,38 @@ sub definition {
|
|||
size=>{
|
||||
defaultValue=>11
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "BIGINT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "BIGINT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "BIGINT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('482');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns the integer from the form post, or returns 0 if the post result is invalid.
|
||||
|
||||
|
|
@ -104,9 +115,9 @@ An optional value to process, instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if ($value =~ /^-?\d+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -115,6 +126,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an integer field.
|
||||
|
|
|
|||
|
|
@ -55,37 +55,48 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
A time interval in seconds that is used if value is not specified. Defaults to 1.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("interval"),
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>1,
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "BIGINT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ num_and_units ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "BIGINT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "BIGINT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('interval');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ num_and_units ] )
|
||||
|
||||
Returns either the interval that was posted (in seconds) or if nothing comes back it returns 0.
|
||||
|
||||
|
|
@ -95,7 +106,7 @@ The number and units for this interval, to use instead of POST input, which is t
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
|
||||
if (@_) {
|
||||
|
|
@ -108,6 +119,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an interval control.
|
||||
|
|
@ -126,7 +149,7 @@ sub toHtml {
|
|||
'weeks'=>$i18n->get(701),
|
||||
'months'=>$i18n->get(702),
|
||||
'years'=>$i18n->get(703));
|
||||
my ($interval, $units) = $self->session->datetime->secondsToInterval($self->get("value"));
|
||||
my ($interval, $units) = $self->session->datetime->secondsToInterval($self->getDefaultValue);
|
||||
# not sure why, but these things need to be defined like this or
|
||||
# they fail under some circumstnaces
|
||||
my $cmd = "WebGUI::Form::Integer";
|
||||
|
|
@ -141,7 +164,7 @@ sub toHtml {
|
|||
options=>\%units,
|
||||
name=>$self->get("name")."_units",
|
||||
id=>$self->get('id')."_units",
|
||||
value=>[$units]
|
||||
value=>$units
|
||||
)->toHtml;
|
||||
return $out;
|
||||
}
|
||||
|
|
@ -157,7 +180,7 @@ Returns the field as hidden controls rather than displayable controls.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my ($interval, $units) = $self->session->datetime->secondsToInterval($self->get("value"));
|
||||
my ($interval, $units) = $self->session->datetime->secondsToInterval($self->getDefaultValue);
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name").'_interval',
|
||||
value=>$interval
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -79,9 +91,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("LDAPLink_1075","AuthLDAP")
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("LDAPLink_1075","AuthLDAP")
|
||||
},
|
||||
|
|
@ -100,15 +109,49 @@ sub definition {
|
|||
afterEdit=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "TEXT",
|
||||
},
|
||||
});
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "TEXT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'AuthLDAP')->get('LDAPLink_1075');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a database connection picker control.
|
||||
|
|
@ -148,7 +191,7 @@ sub toHtmlWithWrapper {
|
|||
if ($self->session->user->isInGroup(3)) {
|
||||
my $subtext;
|
||||
if ($self->get("afterEdit")) {
|
||||
$subtext = $self->session->icon->edit("op=editLDAPLink;llid=".$self->get("value").";afterEdit=".$self->session->url->escape($self->get("afterEdit")));
|
||||
$subtext = $self->session->icon->edit("op=editLDAPLink;llid=".$self->getDefaultValue.";afterEdit=".$self->session->url->escape($self->get("afterEdit")));
|
||||
}
|
||||
$subtext .= $self->session->icon->manage("op=listLDAPLinks");
|
||||
$self->set("subtext", $subtext . $self->get("subtext"));
|
||||
|
|
|
|||
|
|
@ -58,56 +58,16 @@ sub alignmentSeparator {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 correctOptions ( )
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Parse a string for a list of options to present to the user. This method
|
||||
will mainly be called from WebGUI::Form::DynamicField.
|
||||
Returns a boolean indicating whether the options of the list are settable. Some have a predefined set of options. This is useful in generating dynamic forms. Returns 1.
|
||||
|
||||
=cut
|
||||
|
||||
sub correctOptions {
|
||||
my ($self, $possibleValues) = @_;
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
foreach (split(/\n/, $possibleValues)) {
|
||||
s/\s+$//; # remove trailing spaces
|
||||
$options{$_} = $_;
|
||||
}
|
||||
if ($self->get('options') && ref($self->get('options')) eq "HASH") {
|
||||
%options = (%{$self->get('options')} , %options);
|
||||
}
|
||||
$self->set('options', \%options);
|
||||
sub areOptionsSettable {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
##-------------------------------------------------------------------
|
||||
|
||||
=head2 correctValues ( )
|
||||
|
||||
Parse a string for a list of values that should be selected. This method
|
||||
will mainly be called from WebGUI::Form::DynamicField. Form types that
|
||||
don't have multiple select, like RadioLists, need to override this
|
||||
method.
|
||||
|
||||
=cut
|
||||
|
||||
sub correctValues {
|
||||
my ($self, $value) = @_;
|
||||
return undef unless defined $value;
|
||||
my @defaultValues;
|
||||
if (ref $value eq "ARRAY") {
|
||||
@defaultValues = @{ $value };
|
||||
}
|
||||
else {
|
||||
foreach (split(/\n/, $value)) {
|
||||
s/\s+$//; # remove trailing spaces
|
||||
push(@defaultValues, $_);
|
||||
}
|
||||
}
|
||||
$self->set("value", \@defaultValues);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
|
@ -138,25 +98,17 @@ A boolean indicating whether the user can select multiple items from this list l
|
|||
|
||||
A boolean value for whether or not the values in the options hash should be sorted. Defaults to "0".
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("486"),
|
||||
},
|
||||
options=>{
|
||||
defaultValue=>{}
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>{
|
||||
defaultValue=>[],
|
||||
},
|
||||
multiple=>{
|
||||
|
|
@ -168,12 +120,6 @@ sub definition {
|
|||
size=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "TEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -181,22 +127,72 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayValue ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Return all the options
|
||||
Returns "LONGTEXT".
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
||||
sub displayValue {
|
||||
my ($self) = @_;
|
||||
return join ", ", $self->getValues();
|
||||
sub getDatabaseFieldType {
|
||||
return "LONGTEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar.
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('486');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOptions ( )
|
||||
|
||||
Options are passed in for many list types. Those options can come in as a hash ref, or a \n separated string, or a key|value\n separated string. This method returns a hash ref regardless of what's passed in.
|
||||
|
||||
=cut
|
||||
|
||||
sub getOptions {
|
||||
my ($self) = @_;
|
||||
my $possibleValues = $self->get('options');
|
||||
my %options = ();
|
||||
tie %options, 'Tie::IxHash';
|
||||
if (ref $possibleValues eq "HASH") {
|
||||
%options = %{$possibleValues};
|
||||
}
|
||||
else {
|
||||
foreach my $line (split "\n", $possibleValues) {
|
||||
if ($line =~ m/(.*)|(.*)/) {
|
||||
$options{$1} = $2;
|
||||
}
|
||||
else {
|
||||
$options{$line} = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($self->get('sortByValue')) {
|
||||
my %ordered = ();
|
||||
tie %ordered, 'Tie::IxHash';
|
||||
foreach my $optionKey (sort {"\L$options{$a}" cmp "\L$options{$b}" } keys %options) {
|
||||
$ordered{$optionKey} = $options{$optionKey};
|
||||
}
|
||||
return \%ordered;
|
||||
}
|
||||
return \%options;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar. Also parses the input values (wherever they come from) to see if it's a scalar then it splits on \n.
|
||||
|
||||
=head3 value
|
||||
|
||||
|
|
@ -204,56 +200,78 @@ Optional values to process, instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my @data = @_ ? @_ : $self->session->form->param($self->get("name"));
|
||||
return wantarray ? @data : join("\n",@data);
|
||||
sub getValue {
|
||||
my ($self, $value) = @_;
|
||||
my @values = ();
|
||||
if (defined $value) {
|
||||
if (ref $value eq "ARRAY") {
|
||||
@values = @{$value};
|
||||
}
|
||||
else {
|
||||
@values = split "\n", $value;
|
||||
}
|
||||
}
|
||||
if (scalar @values < 1 && $self->session->request) {
|
||||
my $value = $self->session->form->param($self->get("name"));
|
||||
if (defined $value) {
|
||||
@values = $self->session->form->param($self->get("name"));
|
||||
}
|
||||
}
|
||||
if (scalar @values < 1) {
|
||||
@values = $self->getDefaultValue;
|
||||
}
|
||||
return wantarray ? @values : join("\n",@values);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefaultValue ( )
|
||||
|
||||
Returns the either the "value" ore "defaultValue" passed in to the object in that order, and doesn't take into account form processing.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDefaultValue {
|
||||
my $self = shift;
|
||||
my @values = ();
|
||||
foreach my $value ($self->get("value"), $self->get("defaultValue")) {
|
||||
if (scalar @values < 1 && defined $value) {
|
||||
if (ref $value eq "ARRAY") {
|
||||
@values = @{$value};
|
||||
}
|
||||
else {
|
||||
@values = split "\n", $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return wantarray ? @values : join("\n",@values);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Return all the options
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
my $options = $self->getOptions;
|
||||
return join ", ", map { $options->{$_} } $self->getValue();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValues ( )
|
||||
|
||||
Safely handle returning values whether the stored data is scalar or an array
|
||||
ref.
|
||||
Depricated. See getValue().
|
||||
|
||||
=cut
|
||||
|
||||
sub getValues {
|
||||
my $self = shift;
|
||||
my @values = ();
|
||||
if (ref $self->get("value") eq 'ARRAY') {
|
||||
@values = @{ $self->get("value") };
|
||||
}
|
||||
else {
|
||||
push @values, $self->get("value");
|
||||
}
|
||||
return @values;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 orderedHash ( )
|
||||
|
||||
Based on whether the sortByValue flag is set, return the options hash
|
||||
for List type Forms sorted by values. The sort is done without regard
|
||||
to the case of the values.
|
||||
|
||||
=cut
|
||||
|
||||
sub orderedHash {
|
||||
my ($self) = @_;
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
my $original = $self->get("options");
|
||||
if ($self->get('sortByValue')) {
|
||||
foreach my $optionKey (sort {"\L$original->{$a}" cmp "\L$original->{$b}" } keys %{$original}) {
|
||||
$options{$optionKey} = $original->{$optionKey};
|
||||
}
|
||||
} else {
|
||||
%options = %{$original};
|
||||
}
|
||||
return %options;
|
||||
return $self->getValue(@_);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -267,21 +285,19 @@ Creates a series of hidden fields representing the data in the list.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
%options = $self->orderedHash();
|
||||
my $options = $self->getOptions();
|
||||
my $output;
|
||||
my @values = $self->getValues();
|
||||
foreach my $key (keys %options) {
|
||||
foreach my $item (@values) {
|
||||
if ($item eq $key) {
|
||||
$output .= WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name"),
|
||||
value=>$key
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
my @values = $self->getDefaultValue();
|
||||
foreach my $key (keys %{$options}) {
|
||||
foreach my $item (@values) {
|
||||
if ($item eq $key) {
|
||||
$output .= WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name"),
|
||||
value=>$key
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,21 +58,40 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, 'Form_MimeType');
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get('mimeType'),
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get('mimeType'),
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'Form_MimeType')->get('mimeType');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a database connection picker control.
|
||||
|
|
|
|||
|
|
@ -54,36 +54,63 @@ Defaults to 35. Determines the maximum number of characters allowed in this fiel
|
|||
|
||||
Defaults to 30. Specifies how big of a text box to display.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("51")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=>35
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>30
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('51');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Formats as ******.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
return '******';
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an input tag of type password.
|
||||
|
|
@ -92,7 +119,7 @@ Renders an input tag of type password.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $html = '<input type="password" name="'.$self->get("name").'" value="'.$self->fixQuotes($self->get("value")).'" size="'.$self->get("size").'" id="'.$self->get('id').'" ';
|
||||
my $html = '<input type="password" name="'.$self->get("name").'" value="'.$self->fixQuotes($self->getDefaultValue).'" size="'.$self->get("size").'" id="'.$self->get('id').'" ';
|
||||
$html .= 'maxlength="'.$self->get("maxlength").'" ' if ($self->get("maxlength"));
|
||||
$html .= $self->get("extras").' />';
|
||||
return $html;
|
||||
|
|
|
|||
|
|
@ -38,39 +38,20 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("481")
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('481');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a string filtered to allow only digits, spaces, and these special characters: + - ( ) or it will return undef it the number doesn't validate to those.
|
||||
|
||||
|
|
@ -80,9 +61,9 @@ An input value to use instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if ($value =~ /^[x\d \.\-\+\(\)]+$/ and $value =~ /\d/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -91,6 +72,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a phone number field.
|
||||
|
|
|
|||
|
|
@ -50,27 +50,16 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Defaults to "0". Set to "1" if this field should be checked.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("radio")
|
||||
},
|
||||
checked=>{
|
||||
defaultValue=> 0
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -90,6 +79,19 @@ sub generateIdParameter {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('radio');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders and input tag of type radio.
|
||||
|
|
|
|||
|
|
@ -37,17 +37,6 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
##-------------------------------------------------------------------
|
||||
|
||||
=head2 correctValues ( )
|
||||
|
||||
Override method from master class since RadioList only supports a single value
|
||||
|
||||
=cut
|
||||
|
||||
sub correctValues { }
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
|
@ -62,27 +51,16 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Boolean representing whether the checklist should be represented vertically or horizontally. If set to "1" will be displayed vertically. Defaults to "0".
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("942")
|
||||
},
|
||||
vertical=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>''
|
||||
}
|
||||
|
|
@ -91,6 +69,57 @@ sub definition {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('942');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
See WebGUI::Form::Control::getValue()
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
return $self->WebGUI::Form::Control::getValue(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefaultValue ( [ value ] )
|
||||
|
||||
See WebGUI::Form::Control::getDefaultValue()
|
||||
|
||||
=cut
|
||||
|
||||
sub getDefaultValue {
|
||||
my $self = shift;
|
||||
return $self->WebGUI::Form::Control::getDefaultValue(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
|
@ -103,26 +132,24 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my $output;
|
||||
my $alignment = $self->alignmentSeparator;
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
%options = $self->orderedHash;
|
||||
my $i=0;
|
||||
foreach my $key (keys %options) {
|
||||
my $options = $self->getOptions;
|
||||
foreach my $key (keys %{$options}) {
|
||||
$i++;
|
||||
my $checked = 0;
|
||||
if ($self->get('value') eq $key) {
|
||||
$checked = 1;
|
||||
}
|
||||
$output .= WebGUI::Form::Radio->new($self->session, {
|
||||
name=>$self->get('name'),
|
||||
value=>$key,
|
||||
extras=>$self->get('extras'),
|
||||
checked=>$checked,
|
||||
id=>$self->get('name').$i
|
||||
})->toHtml;
|
||||
$output .= '<label for="'.$self->get('name').$i.'">'.$self->get('options')->{$key}."</label>" . $alignment;
|
||||
my $checked = 0;
|
||||
if ($self->get('value') eq $key) {
|
||||
$checked = 1;
|
||||
}
|
||||
return $output;
|
||||
$output .= WebGUI::Form::Radio->new($self->session, {
|
||||
name=>$self->get('name'),
|
||||
value=>$key,
|
||||
extras=>$self->get('extras'),
|
||||
checked=>$checked,
|
||||
id=>$self->get('name').$i
|
||||
})->toHtml;
|
||||
$output .= '<label for="'.$self->get('name').$i.'">'.$options->{$key}."</label>" . $alignment;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -39,50 +39,43 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("read only")
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('read only');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getValue ( )
|
||||
|
||||
Returns undef.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders the value.
|
||||
|
|
@ -91,7 +84,7 @@ Renders the value.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
return $self->get("value");
|
||||
return $self->getDefaultValue;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -36,16 +36,6 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
##-------------------------------------------------------------------
|
||||
|
||||
=head2 correctValues ( )
|
||||
|
||||
Override method from master class since SelectBox only support a single value
|
||||
|
||||
=cut
|
||||
|
||||
sub correctValues { }
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
|
@ -60,58 +50,92 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
The number of characters tall this list should be. Defaults to '1'.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("487"),
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>'', # gotta be a scalar, not an arrayref.
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>1,
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1,
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(255)",
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Note, this is exactly the same method as used by Control since SelectBoxes only support a single value.
|
||||
Returns "VARCHAR(255)".
|
||||
|
||||
=head3 value
|
||||
=cut
|
||||
|
||||
Optional values to process (read "return"), instead of POST input.
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(255)";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('487');
|
||||
}
|
||||
|
||||
my $formValue = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
if (defined $formValue) {
|
||||
return $formValue;
|
||||
} else {
|
||||
return $self->get("defaultValue");
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
See WebGUI::Form::Control::getValue()
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
return $self->WebGUI::Form::Control::getValue(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefaultValue ( )
|
||||
|
||||
Returns the either the "value" ore "defaultValue" passed in to the object in that order, and doesn't take into account form processing.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDefaultValue {
|
||||
my $self = shift;
|
||||
my $value = $self->get("value");
|
||||
unless (defined $value) {
|
||||
$value = $self->get("defaultValue");
|
||||
}
|
||||
if (ref $value eq 'ARRAY') {
|
||||
$value = $value->[0];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -125,17 +149,15 @@ Renders a select list form control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $output = '<select name="'.($self->get("name")||'').'" size="'.($self->get("size")||'').'" id="'.($self->get('id')||'').'" '.($self->get("extras")||'').'>';
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
%options = $self->orderedHash;
|
||||
my ($value) = $self->getValues();
|
||||
foreach my $key (keys %options) {
|
||||
my $options = $self->getOptions;
|
||||
my $value = $self->getDefaultValue();
|
||||
foreach my $key (keys %{$options}) {
|
||||
$output .= '<option value="'.$key.'"';
|
||||
if ($value eq $key) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
$output .= '>'.$self->get('options')->{$key}.'</option>';
|
||||
}
|
||||
$output .= '>'.$options->{$key}.'</option>';
|
||||
}
|
||||
$output .= '</select>'."\n";
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,32 +54,18 @@ The number of characters tall this list should be. Defaults to '5'.
|
|||
|
||||
A boolean indicating whether the user can select multiple items from this list like a checkList. Defaults to "1".
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("484"),
|
||||
},
|
||||
multiple=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>5
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "LONGTEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
|
|
@ -87,6 +73,31 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('484');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a select list form control.
|
||||
|
|
@ -97,18 +108,16 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my $multiple = $self->get("multiple") ? ' multiple="multiple"' : '';
|
||||
my $output = '<select name="'.($self->get("name")||'').'" size="'.($self->get("size")||'').'" id="'.($self->get('id')||'').'" '.($self->get("extras")||'').$multiple.'>';
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
%options = $self->orderedHash;
|
||||
my @values = $self->getValues();
|
||||
foreach my $key (keys %options) {
|
||||
my $options = $self->getOptions;
|
||||
my @values = $self->getDefaultValue();
|
||||
foreach my $key (keys %{$options}) {
|
||||
$output .= '<option value="'.$key.'"';
|
||||
foreach my $item (@values) {
|
||||
if ($item eq $key) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
}
|
||||
$output .= '>'.$self->get("options")->{$key}.'</option>';
|
||||
$output .= '>'.$options->{$key}.'</option>';
|
||||
}
|
||||
$output .= '</select>'."\n";
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
|
@ -57,11 +69,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push @{$definition}, {
|
||||
formName => {
|
||||
defaultValue => $i18n->get("475"),
|
||||
},
|
||||
defaultValue => {
|
||||
defaultValue => '',
|
||||
},
|
||||
|
|
@ -69,6 +77,19 @@ sub definition {
|
|||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('SelectRichEditor formName');
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 new
|
||||
|
|
|
|||
|
|
@ -41,29 +41,44 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=> $i18n->get("select slider")
|
||||
},
|
||||
options =>{
|
||||
defaultValue=>{},
|
||||
},
|
||||
value =>{
|
||||
defaultValue=>[],
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "TEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "TEXT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('select slider');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDisplayValue ( )
|
||||
|
||||
Returns the value that should be displayed initially.
|
||||
|
|
@ -73,7 +88,7 @@ Returns the value that should be displayed initially.
|
|||
sub getDisplayValue {
|
||||
my $self = shift;
|
||||
|
||||
return $self->get('options')->{$self->get('value')->[0]};
|
||||
return $self->getOptions->{$self->get('value')->[0]};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -90,7 +105,7 @@ sub getInputElement {
|
|||
return WebGUI::Form::selectList($self->session, {
|
||||
-name => $self->get('name'),
|
||||
-value => $self->get('value'),
|
||||
-options=> $self->get('options'),
|
||||
-options=> $self->getOptions,
|
||||
-id => 'view-'.$self->get('id'),
|
||||
-size => 1,
|
||||
});
|
||||
|
|
@ -131,6 +146,35 @@ sub getOnChangeSlider {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOptions ( )
|
||||
|
||||
Options are passed in for many list types. Those options can come in as a hash ref, or a \n separated string, or a key|value\n separated string. This method returns a hash ref regardless of what's passed in.
|
||||
|
||||
=cut
|
||||
|
||||
sub getOptions {
|
||||
my ($self) = @_;
|
||||
my $possibleValues = $self->get('options');
|
||||
my %options = ();
|
||||
tie %options, 'Tie::IxHash';
|
||||
if (ref $possibleValues eq "HASH") {
|
||||
%options = %{$possibleValues};
|
||||
}
|
||||
else {
|
||||
foreach my $line (split "\n", $possibleValues) {
|
||||
if ($line =~ m/(.*)|(.*)/) {
|
||||
$options{$1} = $2;
|
||||
}
|
||||
else {
|
||||
$options{$line} = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \%options;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSliderMaximum ( )
|
||||
|
||||
Returns the maximum value the slider can be set to in slider units.
|
||||
|
|
@ -140,7 +184,7 @@ Returns the maximum value the slider can be set to in slider units.
|
|||
sub getSliderMaximum {
|
||||
my $self = shift;
|
||||
|
||||
return scalar(keys %{$self->get('options')}) - 1;
|
||||
return scalar(keys %{$self->getOptions}) - 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -168,7 +212,7 @@ Returns the initial position of the slider in slider units.
|
|||
sub getSliderValue {
|
||||
my $self = shift;
|
||||
|
||||
my @keys = keys %{$self->get('options')};
|
||||
my @keys = keys %{$self->getOptions};
|
||||
for (my $i = 0; $i < @keys; $i++) {
|
||||
return $i if $keys[$i] eq $self->get('value')->[0];
|
||||
}
|
||||
|
|
@ -178,7 +222,7 @@ sub getSliderValue {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes
|
||||
back as undef, this method will return the defaultValue instead. Strip
|
||||
|
|
@ -190,21 +234,33 @@ A value to process instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my @args = @_;
|
||||
|
||||
my $properties = {
|
||||
-name => $self->get('name'),
|
||||
-value => $self->get('value'),
|
||||
-options=> $self->get('options'),
|
||||
-options=> $self->getOptions,
|
||||
-id => 'view-'.$self->get('id'),
|
||||
-size => 1,
|
||||
};
|
||||
|
||||
return WebGUI::Form::SelectList->new($self->session, $properties)->getValueFromPost(@args);
|
||||
return WebGUI::Form::SelectList->new($self->session, $properties)->getValue(@args);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,21 +60,13 @@ Defaults to "0". The minimum value that the slider can go to.
|
|||
Defaults to 1. Setting this option to 0 will hide the input element tied to the
|
||||
slider.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=> "No name",
|
||||
},
|
||||
maximum=>{
|
||||
defaultValue=> "100",
|
||||
},
|
||||
|
|
@ -84,9 +76,6 @@ sub definition {
|
|||
editable=>{
|
||||
defaultValue=> "1",
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0,
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -156,6 +145,19 @@ sub getInputVariable {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('slider');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOnChangeInputElement ( )
|
||||
|
||||
This method should return the javascript code that should be executed on an
|
||||
|
|
|
|||
|
|
@ -38,23 +38,15 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( )
|
||||
=head2 getName ( session )
|
||||
|
||||
See the super class for additional details.
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("submit")
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('submit');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -67,7 +59,7 @@ Renders a button.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixQuotes($self->get("value"));
|
||||
my $value = $self->fixQuotes($self->getDefaultValue);
|
||||
my $extras = $self->get("extras") || q|class="forwardButton"|;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
$self->{_params}{extras} ||= 'onclick="this.value=\''.$i18n->get(452).'\'"';
|
||||
|
|
|
|||
|
|
@ -36,36 +36,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("hidden")
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('SubscriptionGroup formName');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -78,7 +60,7 @@ Renders the form field to HTML as a table row. The row is not displayed because
|
|||
|
||||
sub toHtmlWithWrapper {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value")))) || '';
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getDefaultValue))) || '';
|
||||
|
||||
my $manageButton = " ";
|
||||
if($value) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -71,9 +83,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Template');
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("assetName")
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("assetName")
|
||||
},
|
||||
|
|
@ -86,15 +95,49 @@ sub definition {
|
|||
onlyCommitted=>{
|
||||
defaultValue=>''
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'Asset_Template')->get('assetName');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a template picker control.
|
||||
|
|
|
|||
|
|
@ -54,37 +54,39 @@ Defaults to 255. Determines the maximum number of characters allowed in this fie
|
|||
|
||||
Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big of a text box to display.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=> $i18n->get("475")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 255
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>$session->setting->get("textBoxSize") || 30
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('475');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value.
|
||||
|
||||
|
|
@ -94,22 +96,23 @@ An optional value to process, instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $formValue;
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\n\n//d;
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (@_) {
|
||||
$formValue = shift;
|
||||
}
|
||||
elsif ($self->session->request) {
|
||||
$formValue = $self->session->form->param($self->get("name"));
|
||||
}
|
||||
if (defined $formValue) {
|
||||
$formValue =~ tr/\r\n//d;
|
||||
return $formValue;
|
||||
} else {
|
||||
return $self->{defaultValue};
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -122,7 +125,7 @@ Renders an input tag of type text.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getDefaultValue)));
|
||||
return '<input id="'.$self->get('id').'" type="text" name="'.$self->get("name").'" value="'.$value.'" size="'.$self->get("size").'" maxlength="'.$self->get("maxlength").'" '.$self->get("extras").' />';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,10 +58,6 @@ The height of this control in pixels. Defaults to 150 pixels.
|
|||
|
||||
Style attributes besides width and height which should be specified using the above parameters. Be sure to escape quotes if you use any.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=head4 resizable
|
||||
|
||||
A boolean indicating whether the text area can be reized by users. Defaults to 1.
|
||||
|
|
@ -72,11 +68,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("476")
|
||||
},
|
||||
height=>{
|
||||
defaultValue=> 150
|
||||
},
|
||||
|
|
@ -89,18 +81,49 @@ sub definition {
|
|||
resizable => {
|
||||
defaultValue => 1,
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "LONGTEXT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "LONGTEXT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "LONGTEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('476');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an input tag of type text.
|
||||
|
|
@ -109,7 +132,7 @@ Renders an input tag of type text.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->get("value"))));
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->getDefaultValue)));
|
||||
my $width = $self->get('width') || 400;
|
||||
my $height = $self->get('height') || 150;
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
|
|
|
|||
|
|
@ -66,21 +66,13 @@ Defaults to 8. Determines the maximum number of characters allowed in this field
|
|||
|
||||
Default to 8. Determines how many characters wide the field wlll be.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("971")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=>8
|
||||
},
|
||||
|
|
@ -89,12 +81,6 @@ sub definition {
|
|||
},
|
||||
format => {
|
||||
defaultValue => undef,
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "BIGINT",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
|
|
@ -102,7 +88,32 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "BIGINT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "BIGINT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('971');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
If the defaultValue is a MySQL time, the value returned by this form element
|
||||
will be a MySQL time. Note: Will not be adjusted for the user's time zone.
|
||||
|
|
@ -116,11 +127,10 @@ An optional value to process, instead of POST input. This should be in the form
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if (@_) {
|
||||
my $value = shift;
|
||||
if ($self->get('format') ne 'mysql' && (
|
||||
!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|
|
@ -143,10 +153,10 @@ sub getValueFromPost {
|
|||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/)) {
|
||||
# epoch format
|
||||
return $self->session->datetime->timeToSeconds($self->session->form->param($self->get("name")))-($self->session->user->profileField("timeOffset")*3600);
|
||||
} else {
|
||||
return $self->session->datetime->timeToSeconds($value)-($self->session->user->profileField("timeOffset")*3600);
|
||||
}
|
||||
else {
|
||||
# Mysql format
|
||||
my $value = $self->session->form->param($self->get("name"));
|
||||
return undef unless $value =~ /^\d{2}\D\d{2}(\D\d{2})?$/;
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -154,6 +164,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a time field.
|
||||
|
|
@ -162,18 +184,7 @@ Renders a time field.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $self->session->datetime->secondsToTime($self->get("value"));
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->get("value");
|
||||
}
|
||||
my $value = $self->getDefaultValue;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
$self->session->style->setScript($self->session->url->extras('inputCheck.js'),{ type=>'text/javascript' });
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(document.getElementById(\''.$self->get("id").'\'),\'0123456789:\')"');
|
||||
|
|
@ -195,18 +206,7 @@ Renders the field as a hidden field.
|
|||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $self->session->datetime->secondsToTime($self->get("value"));
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->get("value");
|
||||
}
|
||||
my $value = $self->getDefaultValue;
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name"),
|
||||
value=>$value
|
||||
|
|
|
|||
|
|
@ -38,6 +38,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -48,16 +60,37 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("timezone", 'DateTime')
|
||||
},
|
||||
value=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'DateTime')->get('timezone');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Defaults to 2048. Determines the maximum number of characters allowed in this field.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
|
|
@ -62,36 +58,45 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("478")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 2048
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('478');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( )
|
||||
|
||||
Parses the posted value and tries to make corrections if necessary.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\r\n//d;
|
||||
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) {
|
||||
}
|
||||
elsif ($value =~ /^([A-Z0-9]+[._+-]?){1,}([A-Z0-9]+[_+-]?)+\@(([A-Z0-9]+[._-]?){1,}[A-Z0-9]+\.){1,}[A-Z]{2,4}$/i) {
|
||||
return "mailto:".$value;
|
||||
} elsif ($value =~ /^\// || $value =~ /:\/\// || $value =~ /^\^/) {
|
||||
}
|
||||
elsif ($value =~ /^\// || $value =~ /:\/\// || $value =~ /^\^/) {
|
||||
return $value;
|
||||
}
|
||||
return "http://".$value;
|
||||
|
|
@ -99,6 +104,33 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Formats as a link.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $url = $self->getValue;
|
||||
return '<a href="'.$url.'">'.$url.'</a>';
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a URL field.
|
||||
|
|
@ -106,7 +138,7 @@ Renders a URL field.
|
|||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
$self->session->style->setScript($self->session->url->extras('addHTTP.js'),{ type=>'text/javascript' });
|
||||
$self->set("extras", $self->get('extras') . ' onblur="addHTTP(this.form.'.$self->get("name").')"');
|
||||
return $self->SUPER::toHtml;
|
||||
|
|
|
|||
|
|
@ -69,9 +69,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, "WebGUI");
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("user"),
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("user"),
|
||||
},
|
||||
|
|
@ -81,15 +78,67 @@ sub definition {
|
|||
readOnly=>{
|
||||
defaultValue=>0,
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('user');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Formats as a name.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $user = WebGUI::User->new($self->session, $self->getValue);
|
||||
if (defined $user) {
|
||||
return $user->username;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a user selector.
|
||||
|
|
@ -98,7 +147,7 @@ Renders a user selector.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $user = WebGUI::User->new($self->session, $self->get("value"));
|
||||
my $user = WebGUI::User->new($self->session, $self->getDefaultValue);
|
||||
my $manage = undef;
|
||||
if ($self->session->user->isInGroup(3)) {
|
||||
$manage = " ".$self->session->icon->manage('op=listUsers');
|
||||
|
|
|
|||
|
|
@ -62,9 +62,6 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("744")
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("744")
|
||||
},
|
||||
|
|
@ -77,6 +74,31 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('744');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a question selector asking the user where they want to go.
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
|
@ -74,11 +86,8 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, 'Workflow');
|
||||
my $i18n = WebGUI::International->new($session, 'Workflow');
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("topicName")
|
||||
},
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("topicName")
|
||||
},
|
||||
|
|
@ -94,11 +103,33 @@ sub definition {
|
|||
includeRealtime => {
|
||||
defaultValue => 0
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "VARCHAR(22) BINARY",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "VARCHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "VARCHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'Workflow')->get('topicName');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -130,7 +161,6 @@ sub toHtmlWithWrapper {
|
|||
my $returnUrl = ";proceed=goBackToPage;returnUrl=".$self->session->url->escape($self->session->asset->getUrl) if $self->session->asset;
|
||||
my $buttons;
|
||||
# This edit button will not work with multiple workflows.
|
||||
#$buttons .= $self->session->icon->edit("op=editWorkflow;workflowId=".$self->get("value")->[0].$returnUrl) if ($self->get("value"));
|
||||
$buttons .= $self->session->icon->manage("op=manageWorkflows".$returnUrl);
|
||||
$self->set("subtext",$buttons . $self->get("subtext"));
|
||||
return $self->SUPER::toHtmlWithWrapper;
|
||||
|
|
|
|||
|
|
@ -51,53 +51,48 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Can be a 1 or 0. Defaults to 0 if no value is specified.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("483")
|
||||
},
|
||||
defaultValue=>{
|
||||
defaultValue=>0
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
dbDataType => {
|
||||
defaultValue => "bool",
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 yesNo ( )
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns either a 1 or 0 representing yes, no.
|
||||
Returns "BOOLEAN".
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
||||
sub yesNo {
|
||||
my $self = shift;
|
||||
if ($self->session->form->param($self->get("name")) > 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
sub getDatabaseFieldType {
|
||||
return "BOOLEAN";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('483');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
If value is present, we will process it, otherwise the superclass will handle the request.
|
||||
|
||||
|
|
@ -107,15 +102,43 @@ An optional value to process, instead of POST input. This should be in the form
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = shift;
|
||||
$value = $self->SUPER::getValueFromPost unless (defined $value);
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
return ($value =~ /^y/i || $value eq '1') ? 1 : 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ()
|
||||
|
||||
Shows either Yes or No.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
if ($self->getValue) {
|
||||
return $i18n->get(138);
|
||||
}
|
||||
return $i18n->get(139);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a yes/no question field.
|
||||
|
|
@ -126,7 +149,7 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my ($checkYes, $checkNo);
|
||||
if ($self->get("value")) {
|
||||
if ($self->getDefaultValue) {
|
||||
$checkYes = 1;
|
||||
} else {
|
||||
$checkNo = 1;
|
||||
|
|
|
|||
|
|
@ -50,34 +50,36 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Defaults to 10. Determines the maximum number of characters allowed in this field.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=> $i18n->get("944")
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 10
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('944');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a validated form post result. If the result does not pass validation, it returns undef instead.
|
||||
|
||||
|
|
@ -87,9 +89,9 @@ An optional value to use instead of POST input.
|
|||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = @_ ? shift : $self->session->form->param($self->get("name"));
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\r\n//d;
|
||||
if ($value =~ /^[A-Z\d\s\-]+$/) {
|
||||
return $value;
|
||||
|
|
@ -99,6 +101,18 @@ sub getValueFromPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a zip code field.
|
||||
|
|
|
|||
|
|
@ -50,58 +50,49 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big of a text box to display.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=> $i18n->get("475")
|
||||
},
|
||||
size=>{
|
||||
defaultValue=>$session->setting->get("textBoxSize") || 30
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueFromPost ( [ value ] )
|
||||
=head2 getName ( session )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead.
|
||||
|
||||
=head3 value
|
||||
|
||||
An optional value to process, instead of POST input.
|
||||
Returns the name of the form control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $formValue;
|
||||
sub getName {
|
||||
my ($class, $session) = @_;
|
||||
return WebGUI::International->new($session, "Form_MyControl")>get("topicName");
|
||||
}
|
||||
|
||||
if (@_) {
|
||||
$formValue = shift;
|
||||
}
|
||||
elsif ($self->session->request) {
|
||||
$formValue = $self->session->form->param($self->get("name"));
|
||||
}
|
||||
if (defined $formValue) {
|
||||
return $formValue;
|
||||
} else {
|
||||
return $self->{defaultValue};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Does some special processing.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
|
||||
# ... do your work here
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -114,7 +105,7 @@ Renders an input tag of type text.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getDefaultValue)));
|
||||
return '<input id="'.$self->get('id').'" type="text" name="'.$self->get("name").'" value="'.$value.'" size="'.$self->get("size").'" '.$self->get("extras").' />';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue