From 057d743dfbb75b03d5b5de29f2f0256cb85d507e Mon Sep 17 00:00:00 2001 From: Drake Date: Wed, 27 Sep 2006 02:00:49 +0000 Subject: [PATCH] Fix problem with attachment section of post form miscalculating the number of new attachments uploadable. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Form/Image.pm | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 1e71ca98f..44dedcb7c 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -31,6 +31,7 @@ profile field options. - Fixed the search function that broke in 7.0.7. - fix: typo + obsolete approve section in Collaboration System Default Thread template + - fix: attachments section of post form not working correctly on edit 7.0.7 - rfe: Image Management (funded by Formation Design Systems) diff --git a/lib/WebGUI/Form/Image.pm b/lib/WebGUI/Form/Image.pm index 6491e4f8d..cc7bde672 100644 --- a/lib/WebGUI/Form/Image.pm +++ b/lib/WebGUI/Form/Image.pm @@ -160,9 +160,9 @@ sub toHtml { 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 = $storage->getFiles if (defined $storage); - my $maxFiles = $self->get('maxAttachments') - scalar(@files); - if ($maxFiles > 0) { + 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"), $i18n->get("removeLabel"), $maxFiles; + !, $self->get("name"), $i18n->get("removeLabel"), $maxNewFiles; $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()."
"; } - if (scalar(@files)) { - foreach my $file (@{$storage->getFiles}) { - if ($self->get("deleteFileUrl")) { - $uploadControl .= '

' - .'x

'; - } - my $image = $storage->isImage($file) ? $storage->getThumbnailUrl($file) : $storage->getFileIconUrl($file); - $uploadControl .= '

' - .''
-				.$file.' '.$file.'


'; + foreach my $file (@files) { + if ($self->get("deleteFileUrl")) { + $uploadControl .= '

' + .'x

'; } + my $image = $storage->isImage($file) ? $storage->getThumbnailUrl($file) : $storage->getFileIconUrl($file); + $uploadControl .= '

' + .''
+			.$file.' '.$file.'


'; } return $uploadControl; }