diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 1f2971f48..5414d6902 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -8,6 +8,12 @@ - fix [ 1276695 ] Addition to 'viewRSS not working' (6.7.2) (Andrew Khmelev) - Fixed a layout problem with the user search form. - fix [ 1250418 ] unable to edit posts more than once + - fix [ 1245871 ] redirectAfterLogin url malformed + - fix [ 1274951 ] Unable to drag rank in asset manager + - fix [ 1276449 ] 6.7.1 content invisible after edit by content manager + - Fixed a few bugs in the new form system related to UI levels and hidden + fields. + 6.7.2 - fix [ 1163407 ] Ampersand XHTML 1.0 Non-Compliant diff --git a/lib/WebGUI/Asset/Wobject.pm b/lib/WebGUI/Asset/Wobject.pm index 71208cd7b..6b4281151 100644 --- a/lib/WebGUI/Asset/Wobject.pm +++ b/lib/WebGUI/Asset/Wobject.pm @@ -256,12 +256,13 @@ sub getEditForm { my %params; foreach my $key (keys %{$properties->{$fieldname}}) { next if ($key eq "tab" || $key eq "fieldType"); - $params{"-".$key} = $properties->{$fieldname}{$key} + $params{$key} = $properties->{$fieldname}{$key} } - $params{"-value"} = $self->getValue($fieldname); - $params{"-name"} = $fieldname; + $params{value} = $self->getValue($fieldname); + $params{name} = $fieldname; + $params{fieldType} = $properties->{$fieldname}{fieldType}; my $tab = $properties->{$fieldname}{tab} || "properties"; - $tabform->getTab($tab)->dynamicField($properties->{$fieldname}{fieldType},%params); + $tabform->getTab($tab)->dynamicField(%params); } } return $tabform; diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index 079c10c04..2ecca679c 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -76,87 +76,6 @@ sub AUTOLOAD { return $class->new(@params)->toHtml; } -#------------------------------------------------------------------- -sub _fixMacros { - my $value = shift; - $value =~ s/\^/\&\#94\;/g; - return $value; -} - -#------------------------------------------------------------------- -sub _fixQuotes { - my $value = shift; - $value =~ s/\"/\"\;/g; - return $value; -} - -#------------------------------------------------------------------- -sub _fixSpecialCharacters { - my $value = shift; - $value =~ s/\&/\&\;/g; - return $value; -} - -#------------------------------------------------------------------- -sub _fixTags { - my $value = shift; - $value =~ s/\/\>\;/g; - return $value; -} - - - -#------------------------------------------------------------------- - -=head2 dynamicField ( fieldType , hashRef ) - -Returns a dynamic configurable field. - -=head3 fieldType - -The field type to use. The field name is the name of the method from this forms package. - -=head3 options - -The field options. See the documentation for the desired field for more information. - -=cut - -sub dynamicField { - my $fieldType = ucfirst(shift); - my $param = shift; - - # Set options for fields that use a list. - if (isIn($fieldType,qw(SelectList CheckList RadioList))) { - delete $param->{size}; - my %options; - tie %options, 'Tie::IxHash'; - foreach (split(/\n/, $param->{possibleValues})) { - s/\s+$//; # remove trailing spaces - $options{$_} = $_; - } - if (exists $param->{options} && ref($param->{options}) eq "HASH") { - %options = (%{$param->{options}} , %options); - } - $param->{options} = \%options; - } - # Convert value to list for selectList / checkList - if (isIn($fieldType,qw(SelectList CheckList)) && ref $param->{value} ne "ARRAY") { - my @defaultValues; - foreach (split(/\n/, $param->{value})) { - s/\s+$//; # remove trailing spaces - push(@defaultValues, $_); - } - $param->{value} = \@defaultValues; - } - - # Return the appropriate field. - no strict 'refs'; - return &$fieldType($param); -} - - #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form/Date.pm b/lib/WebGUI/Form/Date.pm index 35a2547e9..0d56a2335 100644 --- a/lib/WebGUI/Form/Date.pm +++ b/lib/WebGUI/Form/Date.pm @@ -17,6 +17,7 @@ package WebGUI::Form::Date; use strict; use base 'WebGUI::Form::Text'; use WebGUI::DateTime; +use WebGUI::Form::Hidden; use WebGUI::Form::Text; use WebGUI::International; use WebGUI::Session; @@ -145,5 +146,21 @@ sub toHtml { '; } +#------------------------------------------------------------------- + +=head2 toHtmlAsHidden ( ) + +Renders the form field to HTML as a hidden field rather than whatever field type it was supposed to be. + +=cut + +sub toHtmlAsHidden { + my $self = shift; + return WebGUI::Form::Hidden->new( + name=>$self->{name}, + value=>WebGUI::DateTime::epochToSet($self->{value}) + )->toHtmlAsHidden; +} + 1; diff --git a/lib/WebGUI/Form/DateTime.pm b/lib/WebGUI/Form/DateTime.pm index a288d9dcc..e1cd97221 100644 --- a/lib/WebGUI/Form/DateTime.pm +++ b/lib/WebGUI/Form/DateTime.pm @@ -16,6 +16,7 @@ package WebGUI::Form::DateTime; use strict; use base 'WebGUI::Form::Text'; +use WebGUI::Form::Hidden; use WebGUI::DateTime; use WebGUI::International; use WebGUI::Session; @@ -144,5 +145,21 @@ sub toHtml { '; } +#------------------------------------------------------------------- + +=head2 toHtmlAsHidden ( ) + +Renders the form field to HTML as a hidden field rather than whatever field type it was supposed to be. + +=cut + +sub toHtmlAsHidden { + my $self = shift; + return WebGUI::Form::Hidden->new( + name=>$self->{name}, + value=>WebGUI::DateTime::epochToSet($self->{value},1) + )->toHtmlAsHidden; +} + 1; diff --git a/lib/WebGUI/Form/DynamicField.pm b/lib/WebGUI/Form/DynamicField.pm new file mode 100644 index 000000000..e043ad4f6 --- /dev/null +++ b/lib/WebGUI/Form/DynamicField.pm @@ -0,0 +1,145 @@ +package WebGUI::Form::DynamicField; + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2005 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Form::Control'; +use WebGUI::International; +use WebGUI::Session; +use WebGUI::Utility; + +=head1 NAME + +Package WebGUI::Form::DynamicField + +=head1 DESCRIPTION + +Creates the appropriate form field type given the inputs. + +=head1 SEE ALSO + +This is a subclass of WebGUI::Form::Control. + +=head1 METHODS + +The following methods are specifically available from this class. Check the superclass for additional methods. + +=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 fieldType + +Defaults to "Text". Should be any valid field type. + +=cut + +sub definition { + my $class = shift; + my $definition = shift || []; + push(@{$definition}, { + fieldType=>{ + defaultValue=> "Text" + }, + }); + return $class->SUPER::definition($definition); +} + +#------------------------------------------------------------------- + +=head2 getName () + +Returns the human readable name or type of this form control. + +=cut + +sub getName { + return WebGUI::International::get("475","WebGUI"); +} + + + +#------------------------------------------------------------------- + +=head2 new ( params) + +Creates the object for the appropriate field type. + +=head3 params + +The normal params you'd pass in to the field. Included in this list must be one element called "fieldType" which specifies what type of field to dynamically render. + +=cut + +sub new { + my $class = shift; + my $self = $class->SUPER::new(@_); + my $param = {}; + foreach my $key (keys %{$self}) { + $param->{$key} = $self->{$key}; + } + my $fieldType = ucfirst($param->{fieldType}); + delete $param->{fieldType}; + # Set options for fields that use a list. + if (isIn($fieldType,qw(SelectList CheckList RadioList))) { + delete $param->{size}; + my %options; + tie %options, 'Tie::IxHash'; + foreach (split(/\n/, $param->{possibleValues})) { + s/\s+$//; # remove trailing spaces + $options{$_} = $_; + } + if (exists $param->{options} && ref($param->{options}) eq "HASH") { + %options = (%{$param->{options}} , %options); + } + $param->{options} = \%options; + } + # Convert value to list for selectList / checkList + if (isIn($fieldType,qw(SelectList CheckList)) && ref $param->{value} ne "ARRAY") { + my @defaultValues; + foreach (split(/\n/, $param->{value})) { + s/\s+$//; # remove trailing spaces + push(@defaultValues, $_); + } + $param->{value} = \@defaultValues; + } + + # Return the appropriate field object. + if ($fieldType eq "") { + WebGUI::ErrorHandler::warn("Something is trying to create a dynamic field called ".$param->{name}.", but didn't pass in a field type."); + $fieldType = "Text"; + } + no strict 'refs'; + my $cmd = "WebGUI::Form::".$fieldType; + my $load = "use ".$cmd; + eval ($load); + if ($@) { + WebGUI::ErrorHandler::error("Couldn't compile form control: ".$fieldType.". Root cause: ".$@); + return undef; + } + return $cmd->new($param); +} + +1; + diff --git a/lib/WebGUI/Form/HiddenList.pm b/lib/WebGUI/Form/HiddenList.pm index 5a0acf1ee..5ad545985 100644 --- a/lib/WebGUI/Form/HiddenList.pm +++ b/lib/WebGUI/Form/HiddenList.pm @@ -110,7 +110,7 @@ sub toHtmlAsHidden { my $self = shift; my $output; foreach my $key (keys %{$self->{options}}) { - foreach my $item (@{$self->{values}}) { + foreach my $item (@{$self->{value}}) { if ($item eq $key) { $output .= WebGUI::Form::Hidden->( name=>$self->{name}, diff --git a/lib/WebGUI/Form/Interval.pm b/lib/WebGUI/Form/Interval.pm index e0cd09eea..20c31442e 100644 --- a/lib/WebGUI/Form/Interval.pm +++ b/lib/WebGUI/Form/Interval.pm @@ -149,13 +149,13 @@ sub toHtmlAsHidden { my $self = shift; my ($interval, $units) = WebGUI::DateTime::secondsToInterval($self->{value}); return WebGUI::Form::Hidden->new( - "name"=>$self->{name}.'_interval', - "value"=>$interval + name=>$self->{name}.'_interval', + value=>$interval )->toHtmlAsHidden .WebGUI::Form::Hidden->new( - "name"=>$self->{name}.'_units', - "value"=>$units - )->toHtmmlAsHidden; + name=>$self->{name}.'_units', + value=>$units + )->toHtmlAsHidden; } 1; diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index 1d0cc58c8..657322e3e 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -63,38 +63,6 @@ These methods are available from this class: =cut -#------------------------------------------------------------------- -sub _subtext { - my $output; - if ($_[0] ne "") { - $output .= ' '.$_[0].''; - } - return $output; -} - -#------------------------------------------------------------------- -sub _tableFormRow { - my $self = shift; - my $label = shift; - my $formControl = shift; - my $hoverHelp = shift; - my $class = $self->{_class}; - $class = qq| class="$class" | if($class); - $hoverHelp =~ s/\r/ /g; - $hoverHelp =~ s/\n/ /g; - $hoverHelp =~ s/&/& amp;/g; - $hoverHelp =~ s/>/& gt;/g; - $hoverHelp =~ s/</& lt;/g; - $hoverHelp =~ s/&/&/g; - $hoverHelp =~ s/>/>/g; - $hoverHelp =~ s/'.$label.''.$formControl."\n"; -} - #------------------------------------------------------------------- sub _uiLevelChecksOut { if ($_[0] <= $session{user}{uiLevel}) { @@ -142,50 +110,6 @@ sub DESTROY { } - -#------------------------------------------------------------------- - -=head2 dynamicField ( fieldType , options ) - -Adds a dynamic field to this form. This is primarily useful for building dynamic form fields. -Because of the dynamic nature of this field, it supports only the -option=>value -way of specifying parameters. - -=head3 fieldType - -The field type to use. The field name is the name of the method from this forms package. - -=head3 options - -The field options. See the documentation for the desired field for more information. - -=cut - -sub dynamicField { - my $self = shift; - my $fieldType = ucfirst(shift); - my %param = @_; - foreach my $key (keys %param) { # strip off the leading minus sign in each parameter key. - $key=~/^-(.*)$/; - $param{$1} = $param{$key}; - delete $param{$key}; - } - my $output; - if (_uiLevelChecksOut($param{uiLevel})) { - $output = WebGUI::Form::dynamicField($fieldType, \%param); - $output .= _subtext($param{subtext}); - $output = $self->_tableFormRow($param{label},$output,$param{hoverHelp}); - } else { - $output = WebGUI::Form::Hidden({ - "name"=>$param{name}, - "value"=>$param{value}, - "defaultValue"=>$param{defaultValue} - }); - } - $self->{_data} .= $output; -} - - #------------------------------------------------------------------- =head2 new ( [ action, method, extras, enctype, tableExtras ] ) diff --git a/www/extras/assetManager/assetManager.js b/www/extras/assetManager/assetManager.js index e91e462aa..70ecee9a2 100644 --- a/www/extras/assetManager/assetManager.js +++ b/www/extras/assetManager/assetManager.js @@ -471,10 +471,18 @@ function AssetManager_addAssetMetaData(url, rank,title) { //********Event Handlers*********** function AssetManager_initializeDragEventHandlers() { - var old = (document.onmousedown) ? document.onmousedown : function () {}; - document.onmousedown= function () {old();AssetManager_documentMouseDown();}; - document.onmouseup=AssetManager_documentMouseUp; - document.onmousemove=AssetManager_documentMouseMove; + document.onmousedown=AssetManager_documentMouseDown; + document.onmouseup=AssetManager_documentMouseUp; + document.onmousemove=AssetManager_documentMouseMove; +/* + // Failed attempt at making it more compatible. + var oldOnMouseDown = (document.onmousedown) ? document.onmousedown : function () {}; + document.onmousedown= function () {oldOnMouseDown();AssetManager_documentMouseDown();}; + var oldOnMouseUp = (document.onmouseup) ? document.onmouseup : function () {}; + document.onmouseup= function () { oldOnMouseUp();AssetManager_documentMouseUp();}; + var oldOnMouseMove= (document.onmousemove) ? document.onmousemove : function () {}; + document.onmousemove= function () { oldOnMouseMove();AssetManager_documentMouseMove();}; +*/ } /* called on document mouse down. Gets a reference to the asset manager and passes in event*/