Covert File, CheckList over to headTags

This commit is contained in:
Colin Kuskie 2010-09-14 13:39:59 -07:00
parent 702dad8254
commit 445dbff297
2 changed files with 29 additions and 4 deletions

View file

@ -237,6 +237,20 @@ sub getValueAsHtml {
#-------------------------------------------------------------------
=head2 headTags ( )
Set the head tags for this form plugin
=cut
sub headTags {
my $self = shift;
$self->session->style->setScript($self->session->url->extras('FileUploadControl.js'),{type=>"text/javascript"});
$self->session->style->setScript($self->session->url->extras('fileIcons.js'),{type=>"text/javascript"});
}
#-------------------------------------------------------------------
=head2 isDynamicCompatible ( )
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
@ -272,14 +286,13 @@ Renders a file upload control.
sub toHtml {
my $self = shift;
$self->headTags;
my $i18n = WebGUI::International->new($self->session);
my $uploadControl = '';
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'));
$self->session->style->setScript($self->session->url->extras('fileIcons.js'));
$uploadControl = '<script type="text/javascript">'
. sprintf(q!var uploader = new FileUploadControl("%s", fileIcons, "%s","%d", "%s"); uploader.addRow();!
, $self->get("name")."_file", $i18n->get("removeLabel"), $maxFiles, $self->get("size"))