Missing session variables in Operation subroutines.
Forward port of Form/File,Image big fixes.
This commit is contained in:
parent
d35d57e1b8
commit
8639f53783
6 changed files with 72 additions and 50 deletions
|
|
@ -52,10 +52,6 @@ The following additional parameters have been added via this sub class.
|
|||
|
||||
If no name is specified a default name of "file" will be used.
|
||||
|
||||
=head4 maxAttachments
|
||||
|
||||
Defaults to 1. Determines how many files the user can upload with this form control.
|
||||
|
||||
=head4 profileEnabled
|
||||
|
||||
Flag that tells the User Profile system that this is a valid form element in a User Profile
|
||||
|
|
@ -72,10 +68,7 @@ sub definition {
|
|||
defaultValue=>$i18n->get("image")
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>"file"
|
||||
},
|
||||
maxAttachments=>{
|
||||
defaultValue=>1
|
||||
defaultValue=>"image"
|
||||
},
|
||||
profileEnabled=>{
|
||||
defaultValue=>1
|
||||
|
|
@ -85,6 +78,33 @@ sub definition {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayForm ( )
|
||||
|
||||
If an image is uploaded, then return the image and a control to
|
||||
delete it. Otherwise, display a form element to upload a file.
|
||||
|
||||
=cut
|
||||
|
||||
sub displayForm {
|
||||
my ($self) = @_;
|
||||
return $self->toHtml unless $self->get('value');
|
||||
##There are files inside here, for each one, display the image
|
||||
##and another form control for deleting it.
|
||||
my $location = WebGUI::Storage->get($self->session, $self->get('value'));
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $fileForm = '';
|
||||
my $file = shift @{ $location->getFiles };
|
||||
$fileForm .= sprintf qq!<img src="%s" /><br />!, $location->getUrl($file);
|
||||
$fileForm .= $i18n->get(392)
|
||||
. " "x4
|
||||
. WebGUI::Form::YesNo->new($self->session, {-name=>$self->privateName('delete'), -value=>0})->toHtml;
|
||||
$fileForm .= $self->toHtmlAsHidden();
|
||||
$fileForm .= WebGUI::Form::Hidden->new($self->session, {-name => $self->privateName('action'), -value => 'keep'})->toHtml();
|
||||
return $fileForm;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 displayValue ( )
|
||||
|
|
@ -99,9 +119,8 @@ sub displayValue {
|
|||
my ($self) = @_;
|
||||
return '' unless $self->get("value");
|
||||
my $location = WebGUI::Storage->get($self->session,$self->get("value"));
|
||||
local $_;
|
||||
my @files = map { sprintf qq!<img src="%s" />!, $location->getUrl($_) } @{ $location->getFiles };
|
||||
my $fileValue = join "<br />\n", @files;
|
||||
my $file = shift @{ $location->getFiles };
|
||||
my $fileValue = sprintf qq!<img src="%s" /> %s!, $location->getUrl($file), $file;
|
||||
return $fileValue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue