Merge commit 'v7.10.20' into WebGUI8
This commit is contained in:
commit
fdb979ca8a
72 changed files with 830 additions and 224 deletions
|
|
@ -2395,6 +2395,7 @@ sub processTemplate {
|
|||
%{$self->get},
|
||||
'title' => $self->getTitle,
|
||||
'menuTitle' => $self->getMenuTitle,
|
||||
'keywords' => $self->get('keywords'),
|
||||
%{$var},
|
||||
);
|
||||
return $template->process(\%vars);
|
||||
|
|
|
|||
|
|
@ -1516,12 +1516,16 @@ Extend the base method to handle cleaning up storage locations.
|
|||
|
||||
override purge => sub {
|
||||
my $self = shift;
|
||||
my $sth = $self->session->db->read("select storageId from Post where assetId=".$self->session->db->quote($self->getId));
|
||||
while (my ($storageId) = $sth->array) {
|
||||
my $storage = WebGUI::Storage->get($self->session, $storageId);
|
||||
$storage->delete if defined $storage;
|
||||
my $purged = super();
|
||||
if ($purged) {
|
||||
my $sth = $self->session->db->read("select storageId from Post where assetId=?",[$self->getId]);
|
||||
while (my ($storageId) = $sth->array) {
|
||||
my $storage = WebGUI::Storage->get($self->session, $storageId);
|
||||
$storage->delete if defined $storage;
|
||||
}
|
||||
$sth->finish;
|
||||
$self->disqualifyAsLastPost;
|
||||
}
|
||||
$sth->finish;
|
||||
return super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1037,18 +1037,22 @@ sub getFieldValue {
|
|||
my $dateFormat = shift || "%z";
|
||||
my $dateTimeFormat = shift;
|
||||
my $processedValue = $value;
|
||||
my $dbh = $self->session->db->dbh;
|
||||
my $session = $self->session;
|
||||
my $dbh = $session->db->dbh;
|
||||
|
||||
if (lc $field->{fieldType} eq "date"){
|
||||
$processedValue = $self->session->datetime->epochToHuman($value,$dateFormat);
|
||||
my $fieldType = lc $field->{fieldType};
|
||||
if ($fieldType eq "date"){
|
||||
my $dt = WebGUI::DateTime->new($session, $value);
|
||||
$processedValue = $dt->webguiDate($dateFormat);
|
||||
}
|
||||
elsif (lc $field->{fieldType} eq "datetime"){
|
||||
$processedValue = $self->session->datetime->epochToHuman($value,$dateTimeFormat);
|
||||
elsif ($fieldType eq "datetime"){
|
||||
my $dt = WebGUI::DateTime->new($session, $value);
|
||||
$processedValue = $dt->webguiDate($dateTimeFormat);
|
||||
}
|
||||
# TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be
|
||||
# safely removed. However, this requires more testing than I can provide right now, so for now this stays the
|
||||
# way it was.
|
||||
elsif ($field->{fieldType} =~ m/^otherThing/x) {
|
||||
elsif ($field->{fieldType} =~ m/^otherthing/x) {
|
||||
my $otherThingId = $field->{fieldType};
|
||||
$otherThingId =~ s/^otherThing_//x;
|
||||
my $tableName = 'Thingy_'.$otherThingId;
|
||||
|
|
|
|||
|
|
@ -491,7 +491,9 @@ sub session {
|
|||
Change a WebGUI format into a Strftime format.
|
||||
|
||||
NOTE: %M in WebGUI's format has no equivalent in strftime format, so it will
|
||||
be replaced with "_varmonth_". Do something with it.
|
||||
be replaced with "{month}". Single digit hours are handled similarly. DateTime's
|
||||
strftime will use {method} to call a method on the object to fill in that part of
|
||||
the format.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -514,13 +516,13 @@ sub webguiToStrftime {
|
|||
"c" => "B",
|
||||
"C" => "b",
|
||||
"d" => "d",
|
||||
"D" => "e",
|
||||
"D" => "{day}",
|
||||
"h" => "I",
|
||||
"H" => "l",
|
||||
"j" => "H",
|
||||
"J" => "k",
|
||||
"m" => "m",
|
||||
"M" => "_varmonth_",
|
||||
"M" => "{month}",
|
||||
"n" => "M",
|
||||
"t" => "Z",
|
||||
"O" => "z",
|
||||
|
|
@ -587,12 +589,7 @@ sub webguiDate {
|
|||
|
||||
my $format = $self->webguiToStrftime( shift || "%z %Z" );
|
||||
|
||||
#--- %M
|
||||
my $datestr = $self->strftime($format);
|
||||
my $temp = int($self->month);
|
||||
$datestr =~ s/\%_varmonth_/$temp/g;
|
||||
|
||||
#--- return
|
||||
return $datestr;
|
||||
}
|
||||
#######################################################################
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -122,15 +122,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};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -147,14 +139,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";
|
||||
|
|
@ -167,10 +160,7 @@ sub toHtml {
|
|||
);
|
||||
$self->set('options', \%options);
|
||||
$self->set('defaultValue',0);
|
||||
return $self->SUPER::toHtml();
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -126,27 +126,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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
64
lib/WebGUI/Macro/FormField.pm
Normal file
64
lib/WebGUI/Macro/FormField.pm
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
package WebGUI::Macro::FormField;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::FormField
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Renders an instance of a Form object.
|
||||
|
||||
=head2 process( $session, $type, $field_name [, $default_value, @form_constructor_arguments ] )
|
||||
|
||||
C<$type> is one of the L<WebGUI::Form::Control> subclasses in L<WebGUI::Form>.
|
||||
|
||||
C<$field_name> is the name the field will be given in the HTML "name" attribute.
|
||||
|
||||
C<$default_value> is the currently selected value to use for the form field if no GET/POST parameter or field of the
|
||||
current asset of the same name has a value.
|
||||
|
||||
A form posted form parameter of the same name as the C<$field_name>, if present, will be used instead of the default.
|
||||
Failing that, an attribute of the current asset of the same name, if present, will be used instead of the default value.
|
||||
|
||||
C<@form_constructor_arguments> get passed to the L<WebGUI::Form> subclass constructor.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $type = shift;
|
||||
my $name = shift;
|
||||
my $default_value = shift || '';
|
||||
my @extras = @_;
|
||||
|
||||
my $form_class = "WebGUI::Form::" . ucfirst $type;
|
||||
|
||||
my $value = $session->form->get($name);
|
||||
$value ||= $session->asset->get($name) if $session->asset;
|
||||
$value ||= $default_value;
|
||||
|
||||
my $control = eval { WebGUI::Pluggable::instanciate($form_class, 'new', [ $session, { name => $name, value => $value, @extras } ]) };
|
||||
if ($@) {
|
||||
$session->log->warn("FormField Macro could not load class ``$form_class'': $@");
|
||||
return '';
|
||||
}
|
||||
|
||||
return $control->toHtml;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -86,6 +86,10 @@ sub add {
|
|||
unless exists($params->{taxRate}) and defined $params->{taxRate};
|
||||
|
||||
$params->{taxId} = 'new';
|
||||
##Remove spaces around commas, which will break tax lookups
|
||||
foreach my $param (qw/country city state code/) {
|
||||
$params->{$param} =~ s/\s*,\s*/,/g;
|
||||
}
|
||||
my $id = $self->session->db->setRow('tax_generic_rates', 'taxId', $params);
|
||||
return $id;
|
||||
}
|
||||
|
|
@ -213,6 +217,24 @@ sub getAllItems {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getItem ( $taxId )
|
||||
|
||||
Returns all data for one tax item as a hash reference.
|
||||
|
||||
=head3 $taxId
|
||||
|
||||
The identifier for the row of tax data to return.
|
||||
|
||||
=cut
|
||||
|
||||
sub getItem {
|
||||
my $self = shift;
|
||||
my $result = $self->session->db->quickHashRef('select * from tax_generic_rates where taxId=?',[shift]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getItems ( )
|
||||
|
||||
Returns a WebGUI::SQL::Result object for accessing all of the data in the tax table. This
|
||||
|
|
|
|||
|
|
@ -711,8 +711,9 @@ sub getGroupIdsRecursive {
|
|||
my $self = shift;
|
||||
my $groupingIds = $self->getGroups( "withoutExpired" );
|
||||
my %groupIds = map { $_ => 1 } @{ $groupingIds };
|
||||
while ( my $groupingId = shift @{ $groupingIds } ) {
|
||||
GROUPINGID: while ( my $groupingId = shift @{ $groupingIds } ) {
|
||||
my $group = WebGUI::Group->new( $self->session, $groupingId );
|
||||
next GROUPINGID unless $group;
|
||||
for my $groupGroupingId ( @{ $group->getGroupsFor } ) {
|
||||
if ( !$groupIds{ $groupGroupingId } ) {
|
||||
push @{ $groupingIds }, $groupGroupingId;
|
||||
|
|
|
|||
|
|
@ -456,8 +456,8 @@ ipAddress etc?|,
|
|||
|
||||
'default value description' => {
|
||||
message => q|Enter the default value (if any) for the field. If you have defined the possible values for
|
||||
this field using a hash, then the default value has to be a key in that hash, and not a value. For Yes/No fields, enter "yes" to select "Yes" and "no" to select "No".|,
|
||||
lastUpdated => 1223372150,
|
||||
this field using a hash, then the default value has to be a key in that hash, and not a value. For Yes/No fields, enter "yes" to select "Yes" and "no" to select "No". For Date and Date/Time fields, enter an epoch date, or a date in YYYY-MM-DD HH:MM:SS, the ISO 9601 format with optional time|,
|
||||
lastUpdated => 1309814047,
|
||||
},
|
||||
|
||||
'default value subtext' => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue