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 #12188: Thingy broken after upgrade to 7.9.32-stable
- fixed #12184: Apache error in modperl.error.log (William McKee, Knowmad Technologies) - fixed #12184: Apache error in modperl.error.log (William McKee, Knowmad Technologies)
- fixed #12186: keywords template variable not working properly in Article - 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 7.10.19
- fixed #12169: extras uploads symlink export - fixed #12169: extras uploads symlink export

View file

@ -17,6 +17,7 @@ package WebGUI::Form::AdSpace;
use strict; use strict;
use base 'WebGUI::Form::SelectBox'; use base 'WebGUI::Form::SelectBox';
use WebGUI::International; use WebGUI::International;
use WebGUI::AdSpace;
=head1 NAME =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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) }; my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) };
$self->set('defaultValue', ( keys %{$options} )[0] ); $self->set('defaultValue', ( keys %{$options} )[0] );
$self->set('options', $options ); $self->set('options', $options );
return $self->SUPER::toHtml(); return $self;
}
#-------------------------------------------------------------------
=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();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my %types; my $self = $class->SUPER::new(@_);
my $i18n = WebGUI::International->new($self->session); my %types;
foreach my $type (@{ $self->get('types') }) { my $i18n = WebGUI::International->new($self->session);
if ($type eq "text") { foreach my $type (@{ $self->get('types') }) {
$types{text} = $i18n->get(1010); if ($type eq "text") {
} elsif ($type eq "mixed") { $types{text} = $i18n->get(1010);
$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); elsif ($type eq "mixed") {
return $self->SUPER::toHtml(); $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; 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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
my %countries; my %countries;
tie %countries, 'Tie::IxHash'; tie %countries, 'Tie::IxHash';
%countries = map {$_ => $_} getCountries(); %countries = map {$_ => $_} getCountries();
$self->set("options", \%countries); $self->set('options', \%countries);
return $self->SUPER::toHtml(); return $self;
} }
1; 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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set("options", WebGUI::DatabaseLink->getList($self->session)); $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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
my $i18n = WebGUI::International->new($self->session); my $i18n = WebGUI::International->new($self->session);
my %filter; my %filter;
tie %filter, 'Tie::IxHash'; tie %filter, 'Tie::IxHash';
%filter = ( %filter = (
'none'=>$i18n->get(420), 'none' => $i18n->get(420),
'macros'=>$i18n->get(891), 'macros' => $i18n->get(891),
'javascript'=>$i18n->get(526), 'javascript' => $i18n->get(526),
'most'=>$i18n->get(421), 'most' => $i18n->get(421),
'all'=>$i18n->get(419) 'all' => $i18n->get(419),
); );
$self->set("options", \%filter); $self->set("options", \%filter);
return $self->SUPER::toHtml(); return $self;
} }
1; 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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
my $where = ''; my $where = '';
if (($self->get('excludeGroups')->[0]||'') ne "") { if (($self->get('excludeGroups')->[0]||'') ne "") {
$where = "and groupId not in (".$self->session->db->quoteAndJoin($self->get("excludeGroups")).")"; $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")); $self->set('options', $self->session->db->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName"));
return $self->SUPER::toHtml(); return $self;
}
#-------------------------------------------------------------------
=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();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set("options", WebGUI::LDAPLink->getList($self->session)); $self->set("options", WebGUI::LDAPLink->getList($self->session));
return $self->SUPER::toHtml(); return $self;
}
#-------------------------------------------------------------------
=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();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -123,15 +123,7 @@ Shows either Yes or No.
sub getValueAsHtml { sub getValueAsHtml {
my $self = shift; my $self = shift;
my $i18n = WebGUI::International->new($self->session,'Form_MatrixCompare'); return $self->get('options')->{$self->getOriginalValue};
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};
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -148,14 +140,15 @@ sub isDynamicCompatible {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 toHtml ( ) =head2 new ( )
Renders a fieldType selector. Extend the base "new" to set options.
=cut =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
my $i18n = WebGUI::International->new($self->session,'Form_MatrixCompare'); my $i18n = WebGUI::International->new($self->session,'Form_MatrixCompare');
my %options; my %options;
tie %options, "Tie::IxHash"; tie %options, "Tie::IxHash";
@ -168,10 +161,7 @@ sub toHtml {
); );
$self->set('options', \%options); $self->set('options', \%options);
$self->set('defaultValue',0); $self->set('defaultValue',0);
return $self->SUPER::toHtml(); return $self;
} }
1; 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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my %options; my $self = $class->SUPER::new(@_);
tie %options, "Tie::IxHash"; my %options;
tie %options, "Tie::IxHash";
%options = ( %options = (
MatrixCompare => WebGUI::Pluggable::instanciate('WebGUI::Form::MatrixCompare', 'getName',[$self->session]), MatrixCompare => WebGUI::Pluggable::instanciate('WebGUI::Form::MatrixCompare', 'getName',[$self->session]),
SelectBox => WebGUI::Pluggable::instanciate('WebGUI::Form::SelectBox', 'getName',[$self->session]), SelectBox => WebGUI::Pluggable::instanciate('WebGUI::Form::SelectBox', 'getName',[$self->session]),
Combo => WebGUI::Pluggable::instanciate('WebGUI::Form::Combo', 'getName',[$self->session]), Combo => WebGUI::Pluggable::instanciate('WebGUI::Form::Combo', 'getName',[$self->session]),
); );
$self->set('options', \%options); $self->set('options', \%options);
$self->set('defaultValue','MatrixCompare'); $self->set('defaultValue','MatrixCompare');
return $self->SUPER::toHtml(); return $self;
} }
1; 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 ] ) =head2 definition ( [ additionalTerms ] )
See the super class for additional details. 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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $mimeTypes; my $self = $class->SUPER::new(@_);
foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') { my $mimeTypes;
$mimeTypes->{$_}=$_; foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') {
} $mimeTypes->{$_}=$_;
}
##Handle the combo box
my $value = $self->getOriginalValue(); my $value = $self->getOriginalValue();
$mimeTypes->{$value} = $value; $mimeTypes->{$value} = $value;
$self->set("options", $mimeTypes); $self->set("options", $mimeTypes);
return $self->SUPER::toHtml(); return $self;
} }
1; 1;

View file

@ -110,24 +110,8 @@ sub new {
my $defaultValue = $self->get('defaultValue'); my $defaultValue = $self->get('defaultValue');
$defaultValue =~ tr/ /_/; $defaultValue =~ tr/ /_/;
$self->set('defaultValue', $defaultValue); $self->set('defaultValue', $defaultValue);
$self->set("options", $self->session->datetime->getTimeZones());
return $self; 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; 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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set('options', WebGUI::Shop::Vendor->getVendors($self->session, {asHashRef=>1})); $self->set('options', WebGUI::Shop::Vendor->getVendors($self->session, {asHashRef=>1}));
return $self->SUPER::toHtml(); return $self;
}
#-------------------------------------------------------------------
=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();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

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 =cut
sub toHtml { sub new {
my $self = shift; my $class = shift;
my $self = $class->SUPER::new(@_);
my $workflowList = WebGUI::Workflow->getList($self->session, $self->get("type")); my $workflowList = WebGUI::Workflow->getList($self->session, $self->get("type"));
if ( $self->get("none") ) { if ( $self->get("none") ) {
@ -157,7 +158,7 @@ sub toHtml {
} }
$self->set("options", $workflowList); $self->set("options", $workflowList);
return $self->SUPER::toHtml(); return $self;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------