Override new in Form plugins that set their options, so the options are always available. Fixes bug #12190.

This commit is contained in:
Colin Kuskie 2011-07-11 13:04:22 -07:00
parent 1c08796d6c
commit 4b663fdf0b
14 changed files with 124 additions and 185 deletions

View file

@ -9,6 +9,7 @@
- fixed #12188: Thingy broken after upgrade to 7.9.32-stable
- fixed #12184: Apache error in modperl.error.log (William McKee, Knowmad Technologies)
- fixed #12186: keywords template variable not working properly in Article
- fixed #12190: List type form plugins that do not override getOptions show no value when getValueAsHtml is called
7.10.19
- fixed #12169: extras uploads symlink export

View file

@ -17,6 +17,7 @@ package WebGUI::Form::AdSpace;
use strict;
use base 'WebGUI::Form::SelectBox';
use WebGUI::International;
use WebGUI::AdSpace;
=head1 NAME
@ -137,34 +138,19 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
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.
Extend the base "new" to set options and the default value.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) };
$self->set('defaultValue', ( keys %{$options} )[0] );
$self->set('options', $options );
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) };
$self->set('defaultValue', ( keys %{$options} )[0] );
$self->set('options', $options );
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -118,29 +118,33 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a select list form control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
my %types;
my $i18n = WebGUI::International->new($self->session);
foreach my $type (@{ $self->get('types') }) {
if ($type eq "text") {
$types{text} = $i18n->get(1010);
} elsif ($type eq "mixed") {
$types{mixed} = $i18n->get(1008);
} elsif ($type eq "code") {
$types{code} = $i18n->get(1011);
} elsif ($type eq "html") {
$types{html} = $i18n->get(1009);
}
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my %types;
my $i18n = WebGUI::International->new($self->session);
foreach my $type (@{ $self->get('types') }) {
if ($type eq "text") {
$types{text} = $i18n->get(1010);
}
$self->set("options", \%types);
return $self->SUPER::toHtml();
elsif ($type eq "mixed") {
$types{mixed} = $i18n->get(1008);
}
elsif ($type eq "code") {
$types{code} = $i18n->get(1011);
}
elsif ($type eq "html") {
$types{html} = $i18n->get(1009);
}
}
$self->set("options", \%types);
return $self;
}
1;

View file

@ -245,20 +245,20 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a country picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my %countries;
tie %countries, 'Tie::IxHash';
%countries = map {$_ => $_} getCountries();
$self->set("options", \%countries);
return $self->SUPER::toHtml();
$self->set('options', \%countries);
return $self;
}
1;

View file

@ -145,16 +145,17 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a database connection picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set("options", WebGUI::DatabaseLink->getList($self->session));
return $self->SUPER::toHtml();
return $self;
}
#-------------------------------------------------------------------

View file

@ -144,26 +144,27 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Returns a select list containing the content filter options. This is for use with WebGUI::HTML::filter().
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $i18n = WebGUI::International->new($self->session);
my %filter;
tie %filter, 'Tie::IxHash';
%filter = (
'none'=>$i18n->get(420),
'macros'=>$i18n->get(891),
'javascript'=>$i18n->get(526),
'most'=>$i18n->get(421),
'all'=>$i18n->get(419)
);
my %filter;
tie %filter, 'Tie::IxHash';
%filter = (
'none' => $i18n->get(420),
'macros' => $i18n->get(891),
'javascript' => $i18n->get(526),
'most' => $i18n->get(421),
'all' => $i18n->get(419),
);
$self->set("options", \%filter);
return $self->SUPER::toHtml();
return $self;
}
1;

View file

@ -186,34 +186,21 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
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.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $where = '';
if (($self->get('excludeGroups')->[0]||'') ne "") {
$where = "and groupId not in (".$self->session->db->quoteAndJoin($self->get("excludeGroups")).")";
}
$self->set('options', $self->session->db->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName"));
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
$self->set("options", $self->session->db->buildHashRef("select groupId,groupName from groups"));
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -152,30 +152,17 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a database connection picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set("options", WebGUI::LDAPLink->getList($self->session));
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
$self->set("options", WebGUI::LDAPLink->getList($self->session));
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -123,15 +123,7 @@ Shows either Yes or No.
sub getValueAsHtml {
my $self = shift;
my $i18n = WebGUI::International->new($self->session,'Form_MatrixCompare');
my %options = (
0 => $i18n->get('no'),
1 => $i18n->get('limited'),
2 => $i18n->get('costs extra'),
3 => $i18n->get('free add on'),
4 => $i18n->get('yes'),
);
return $options{$self->getOriginalValue};
return $self->get('options')->{$self->getOriginalValue};
}
#-------------------------------------------------------------------
@ -148,14 +140,15 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a fieldType selector.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $i18n = WebGUI::International->new($self->session,'Form_MatrixCompare');
my %options;
tie %options, "Tie::IxHash";
@ -168,10 +161,7 @@ sub toHtml {
);
$self->set('options', \%options);
$self->set('defaultValue',0);
return $self->SUPER::toHtml();
return $self;
}
1;

View file

@ -127,27 +127,25 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a fieldType selector.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
my %options;
tie %options, "Tie::IxHash";
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my %options;
tie %options, "Tie::IxHash";
%options = (
MatrixCompare => WebGUI::Pluggable::instanciate('WebGUI::Form::MatrixCompare', 'getName',[$self->session]),
SelectBox => WebGUI::Pluggable::instanciate('WebGUI::Form::SelectBox', 'getName',[$self->session]),
Combo => WebGUI::Pluggable::instanciate('WebGUI::Form::Combo', 'getName',[$self->session]),
SelectBox => WebGUI::Pluggable::instanciate('WebGUI::Form::SelectBox', 'getName',[$self->session]),
Combo => WebGUI::Pluggable::instanciate('WebGUI::Form::Combo', 'getName',[$self->session]),
);
$self->set('options', \%options);
$self->set('defaultValue','MatrixCompare');
return $self->SUPER::toHtml();
return $self;
}
1;

View file

@ -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.
@ -92,24 +104,24 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a database connection picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
my $mimeTypes;
foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') {
$mimeTypes->{$_}=$_;
}
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $mimeTypes;
foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') {
$mimeTypes->{$_}=$_;
}
##Handle the combo box
my $value = $self->getOriginalValue();
$mimeTypes->{$value} = $value;
$self->set("options", $mimeTypes);
return $self->SUPER::toHtml();
$self->set("options", $mimeTypes);
return $self;
}
1;

View file

@ -110,24 +110,8 @@ sub new {
my $defaultValue = $self->get('defaultValue');
$defaultValue =~ tr/ /_/;
$self->set('defaultValue', $defaultValue);
$self->set("options", $self->session->datetime->getTimeZones());
return $self;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a database connection picker control.
=cut
sub toHtml {
my $self = shift;
$self->set("options", $self->session->datetime->getTimeZones());
return $self->SUPER::toHtml();
}
1;

View file

@ -141,30 +141,17 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Returns a group pull-down field. A group pull down provides a select list that provides name value pairs for all the vendors in the WebGUI system.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set('options', WebGUI::Shop::Vendor->getVendors($self->session, {asHashRef=>1}));
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
$self->set("options", WebGUI::Shop::Vendor->getVendors($self->session, {asHashRef=>1}));
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -141,14 +141,15 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a template picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $workflowList = WebGUI::Workflow->getList($self->session, $self->get("type"));
if ( $self->get("none") ) {
@ -157,7 +158,7 @@ sub toHtml {
}
$self->set("options", $workflowList);
return $self->SUPER::toHtml();
return $self;
}
#-------------------------------------------------------------------