- 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.
This commit is contained in:
JT Smith 2005-08-31 19:23:46 +00:00
parent 97161c798e
commit c687487df1
10 changed files with 208 additions and 171 deletions

View file

@ -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

View file

@ -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;

View file

@ -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/\"/\&quot\;/g;
return $value;
}
#-------------------------------------------------------------------
sub _fixSpecialCharacters {
my $value = shift;
$value =~ s/\&/\&amp\;/g;
return $value;
}
#-------------------------------------------------------------------
sub _fixTags {
my $value = shift;
$value =~ s/\</\&lt\;/g;
$value =~ s/\>/\&gt\;/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);
}
#-------------------------------------------------------------------

View file

@ -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 {
</script>';
}
#-------------------------------------------------------------------
=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;

View file

@ -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 {
</script>';
}
#-------------------------------------------------------------------
=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;

View file

@ -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;

View file

@ -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},

View file

@ -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;

View file

@ -63,38 +63,6 @@ These methods are available from this class:
=cut
#-------------------------------------------------------------------
sub _subtext {
my $output;
if ($_[0] ne "") {
$output .= '<span class="formSubtext"> '.$_[0].'</span>';
}
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;/& amp;/g;
$hoverHelp =~ s/&gt;/& gt;/g;
$hoverHelp =~ s/&lt;/& lt;/g;
$hoverHelp =~ s/&/&amp;/g;
$hoverHelp =~ s/>/&gt;/g;
$hoverHelp =~ s/</&lt;/g;
$hoverHelp =~ s/"/&quot;/g;
$hoverHelp =~ s/'/\\'/g;
$hoverHelp =~ s/^\s+//;
my $tooltip = qq|onmouseover="return escape('$hoverHelp')"| if ($hoverHelp);
return '<tr'.$class.'><td '.$tooltip.' class="formDescription" valign="top" style="width: 25%;">'.$label.'</td><td class="tableData" style="width: 75%;">'.$formControl."</td></tr>\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 ] )

View file

@ -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*/