diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt
index ed03aa50b..99992683c 100644
--- a/docs/changelog/7.x.x.txt
+++ b/docs/changelog/7.x.x.txt
@@ -2,6 +2,7 @@
- Data Forms set reply to to the same as the from field
- Config file bugs fixed, see gotcha.txt for details.
- Added export to context menu in asset manager
+ - fix: XHTML 1.0 strict, FileUploadControl.js, resizable textarea
- Polls now use JSON instead of Storable to serialize graph config
diff --git a/lib/WebGUI/Form/File.pm b/lib/WebGUI/Form/File.pm
index f063f7a4c..f0dabf9ae 100644
--- a/lib/WebGUI/Form/File.pm
+++ b/lib/WebGUI/Form/File.pm
@@ -147,6 +147,49 @@ sub displayValue {
return $fileValue;
}
+#-------------------------------------------------------------------
+
+=head2 getFilePreview ( storage )
+
+Returns a preview of the files attached to this form control.
+
+=head3 storage
+
+A WebGUI::Storage object.
+
+=cut
+
+sub getFilePreview {
+ my $self = shift;
+ my $storage = shift;
+ my $preview = "";
+ foreach my $file (@{$storage->getFiles}) {
+ if ($self->get("deleteFileUrl")) {
+ $preview = '
'
+ .'
';
+ }
+ $preview .= ''
+ .' '.$file.'
';
+ }
+ return $preview;
+}
+
+#-------------------------------------------------------------------
+
+=head2 getStorageLocation ( )
+
+Returns the WebGUI::Storage object for this control.
+
+=cut
+
+sub getStorageLocation {
+ my $self = shift;
+ my $storage = WebGUI::Storage->get($self->session, $self->get("value")) if ($self->get("value"));
+ return $storage;
+}
+
+
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
@@ -199,43 +242,51 @@ sub toHtml {
my $self = shift;
my $i18n = WebGUI::International->new($self->session);
my $uploadControl = undef;
- my $storage = WebGUI::Storage->get($self->session, $self->get("value")) if ($self->get("value"));
+ my $storage = $self->getStorageLocation;
my @files = $storage->getFiles if (defined $storage);
my $maxFiles = $self->get('maxAttachments') - scalar(@files);
if ($maxFiles > 0) {
- $self->session->style->setScript($self->session->url->extras('FileUploadControl.js'),{type=>"text/javascript"});
- $uploadControl = '!
- , $self->get("name")."_file", $i18n->get("removeLabel"), $maxFiles, $self->get("size");
- $uploadControl .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'upload'})->toHtml()." ";
- } else {
- $uploadControl .= WebGUI::Form::Hidden->new($self->session, {-name => $self->get("name"), -value => $self->get("value")})->toHtml()." ";
- $uploadControl .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'keep'})->toHtml()." ";
+ $self->session->style->setScript($self->session->url->extras('FileUploadControl.js'),{type=>"text/javascript"});
+ $uploadControl = '
+
+ ';
+ $uploadControl .= '!
+ , $self->get("name")."_file", $i18n->get("removeLabel"), $maxFiles, $self->get("size");
+ $uploadControl .= WebGUI::Form::Hidden->new($self->session, {
+ name => $self->privateName('action'),
+ value => 'upload',
+ id => $self->get('id')
+ })->toHtml()." ";
+ }
+ else {
+ $uploadControl .= WebGUI::Form::Hidden->new($self->session, {
+ name => $self->get("name"),
+ value => $self->get("value"),
+ id => $self->get("id")
+ })->toHtml()." ";
+ $uploadControl .= WebGUI::Form::Hidden->new($self->session, {
+ name => $self->privateName('action'),
+ value => 'keep',
+ id => $self->get("id")
+ })->toHtml()." ";
}
if (scalar(@files)) {
- foreach my $file (@{$storage->getFiles}) {
- if ($self->get("deleteFileUrl")) {
- $uploadControl .= ''
- .'
';
- }
- $uploadControl .= ''
- .' '.$file.'
';
- }
+ $uploadControl .= $self->getFilePreview($storage);
}
- return $uploadControl;
+ return $uploadControl;
}
1;
diff --git a/lib/WebGUI/Form/Image.pm b/lib/WebGUI/Form/Image.pm
index d899b4489..92b266e36 100644
--- a/lib/WebGUI/Form/Image.pm
+++ b/lib/WebGUI/Form/Image.pm
@@ -135,6 +135,50 @@ sub displayValue {
return $fileValue;
}
+#-------------------------------------------------------------------
+
+=head2 getFilePreview ( storage )
+
+Returns a preview of the files attached to this form control.
+
+=head3 storage
+
+A WebGUI::Storage object.
+
+=cut
+
+sub getFilePreview {
+ my $self = shift;
+ my $storage = shift;
+ my $preview = "";
+ foreach my $file (@{$storage->getFiles}) {
+ if ($self->get("deleteFileUrl")) {
+ $preview = ''
+ .'
';
+ }
+ my $image = $storage->isImage($file) ? $storage->getThumbnailUrl($file) : $storage->getFileIconUrl($file);
+ $preview .= ''
+ .' '.$file.'
';
+ }
+ return $preview;
+}
+
+#-------------------------------------------------------------------
+
+=head2 getStorageLocation ( )
+
+Returns the WebGUI::Storage object for this control.
+
+=cut
+
+sub getStorageLocation {
+ my $self = shift;
+ my $storage = WebGUI::Storage::Image->get($self->session, $self->get("value")) if ($self->get("value"));
+ return $storage;
+}
+
+
#-------------------------------------------------------------------
=head2 getValueFromPost ( )
@@ -164,54 +208,4 @@ sub getValueFromPost {
}
-#-------------------------------------------------------------------
-
-=head2 toHtml ( )
-
-Renders a file upload control.
-
-=cut
-
-sub toHtml {
- my $self = shift;
- my $i18n = WebGUI::International->new($self->session);
- my $uploadControl = undef;
- my $storage = WebGUI::Storage::Image->get($self->session, $self->get("value")) if ($self->get("value"));
- my @files = defined($storage)? @{$storage->getFiles} : ();
- my $maxNewFiles = $self->get('maxAttachments') - scalar(@files);
- if ($maxNewFiles > 0) {
- $self->session->style->setScript($self->session->url->extras('/FileUploadControl.js'),{type=>"text/javascript"});
- $uploadControl = '!,
- $self->get("name")."_file", $i18n->get("removeLabel"), $maxNewFiles, $self->get("size");
- $uploadControl .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'upload'})->toHtml()." ";
- } else {
- $uploadControl .= WebGUI::Form::Hidden->new($self->session, {-name => $self->get("name"), -value => $self->get("value")})->toHtml()." ";
- $uploadControl .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'keep'})->toHtml()." ";
- }
- foreach my $file (@files) {
- if ($self->get("deleteFileUrl")) {
- $uploadControl .= ''
- .'
';
- }
- my $image = $storage->isImage($file) ? $storage->getThumbnailUrl($file) : $storage->getFileIconUrl($file);
- $uploadControl .= ''
- .' '.$file.'
';
- }
- return $uploadControl;
-}
-
1;
diff --git a/lib/WebGUI/Form/Textarea.pm b/lib/WebGUI/Form/Textarea.pm
index 355c39b7d..eb3594cc1 100644
--- a/lib/WebGUI/Form/Textarea.pm
+++ b/lib/WebGUI/Form/Textarea.pm
@@ -112,11 +112,12 @@ sub toHtml {
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->get("value"))));
my $width = $self->get('width') || 400;
my $height = $self->get('height') || 150;
- my $style = "width: ".$width."px; height: ".$height."px; ".$self->get("style");
- my $out = '';
+ my ($style, $url) = $self->session->quick(qw(style url));
+ my $styleAttribute = "width: ".$width."px; height: ".$height."px; ".$self->get("style");
+ $style->setRawHeadTags(qq||);
+ my $out = '';
if ($self->get("resizable")) {
$out = ''.$out.'
';
- my ($style, $url) = $self->session->quick(qw(style url));
$style->setScript($url->extras("yui/build/yahoo/yahoo-min.js"), {type=>"text/javascript"});
$style->setScript($url->extras("yui/build/event/event-min.js"), {type=>"text/javascript"});
$style->setScript($url->extras("yui/build/dom/dom-min.js"), {type=>"text/javascript"});
diff --git a/www/extras/FileUploadControl.js b/www/extras/FileUploadControl.js
index 4dbd5757c..53e6ece14 100755
--- a/www/extras/FileUploadControl.js
+++ b/www/extras/FileUploadControl.js
@@ -20,10 +20,10 @@ function FileUploadControl(fieldName, imageArray, removeLabel, fileLimit, size)
str +='';
@@ -69,11 +69,13 @@ function FileUploadControl_swapImage(firedobj) {
var parts = firedobj.value.split('.');
var imgPath = this.images["unknown"];
+ var alternative;
if (parts.length !=1) {
var extension = parts[parts.length -1].toLowerCase();
if (this.images[extension]) {
imgPath = this.images[extension];
+ alternative = extension;
}
}
var row = this.getRow(firedobj);
@@ -83,6 +85,7 @@ function FileUploadControl_swapImage(firedobj) {
var img = row.childNodes[0].childNodes[0];
img.src = imgPath;
img.style.visibility="visible";
+ img.alt = alternate;
}
//removes a row from the control
@@ -94,7 +97,8 @@ function FileUploadControl_removeRow(firedobj) {
//adds a row to the control
function FileUploadControl_addRow() {
var row = this.rowTemplate.cloneNode(true);
- row.id = new Date().getTime();
+ row.id = "id";
+ row.id += new Date().getTime();
this.tbody.appendChild(row);
}