lots of bug fixes

This commit is contained in:
JT Smith 2005-02-14 18:08:11 +00:00
parent 1744f0d10b
commit 9d025d7c28
20 changed files with 75 additions and 46 deletions

View file

@ -84,17 +84,13 @@ sub definition {
return $class->SUPER::definition($definition);
}
sub getBox {
my $self = shift;
my %var;
$var{"attachment.icon"} = $self->getFileIcon;
$var{"attachment.url"} = $self->getFileUrl;
$var{"attachment.name"} = $self->get("filename");
$var{"attachment.size"} = $self->getStorageLocation->getSize;
$var{"attachment.type"} = $self->getStorageLocation->getFileExtension;
return $self->processTemplate(\%var,"PBtmpl0000000000000003");
}
#-------------------------------------------------------------------
sub DESTROY {
my $self = shift;
$self->{_storageLocation}->DESTROY if (exists $self->{_storageLocation});
$self->SUPER::DESTROY;
}
#-------------------------------------------------------------------
@ -106,6 +102,18 @@ sub duplicate {
}
#-------------------------------------------------------------------
sub getBox {
my $self = shift;
my %var;
$var{"attachment.icon"} = $self->getFileIcon;
$var{"attachment.url"} = $self->getFileUrl;
$var{"attachment.name"} = $self->get("filename");
$var{"attachment.size"} = $self->getStorageLocation->getSize;
$var{"attachment.type"} = $self->getStorageLocation->getFileExtension;
return $self->processTemplate(\%var,"PBtmpl0000000000000003");
}
#-------------------------------------------------------------------
=head2 getEditForm ()
@ -170,11 +178,17 @@ sub getName {
return "File";
}
#-------------------------------------------------------------------
sub getStorageLocation {
my $self = shift;
unless (exists $self->{_storageLocation}) {
$self->{_storageLocation} = WebGUI::Storage->get($self->get("storageId"));
if ($self->get("storageId") eq "") {
$self->{_storageLocation} = WebGUI::Storage->create;
$self->update({storageId=>$self->{_storageLocation}->getId});
} else {
$self->{_storageLocation} = WebGUI::Storage->get($self->get("storageId"));
}
}
return $self->{_storageLocation};
}
@ -184,7 +198,7 @@ sub getStorageLocation {
sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
my $storage = $self->{_storageLocation} = WebGUI::Storage->create;
my $storage = $self->getStorageLocation->create;
my $filename = $storage->addFileFromFormPost("file");
if (defined $filename) {
my $oldVersions;
@ -203,6 +217,7 @@ sub processPropertiesFromFormPost {
$self->update(\%data);
$self->setSize($storage->getFileSize($filename));
$storage->setPrivileges($self->get("ownerUserId"), $self->get("groupIdView"), $self->get("groupIdEdit"));
$self->{_storageLocation} = $storage;
} else {
$storage->delete;
$self->getStorageLocation->setPrivileges($self->get("ownerUserId"), $self->get("groupIdView"), $self->get("groupIdEdit"));
@ -221,14 +236,14 @@ sub purge {
my @old = split("\n",$self->get("olderVersions"));
foreach my $oldone (@old) {
my ($storageId, $filename) = split("|",$oldone);
my $storage = WebGUI::Storage->get($storageId);
$storage->delete;
$self->getStorageLocation->delete;
}
$self->getStorageLocation->delete;
return $self->SUPER::purge;
}
#-------------------------------------------------------------------
sub view {
my $self = shift;
my %var = %{$self->get};

View file

@ -160,7 +160,12 @@ sub getName {
sub getStorageLocation {
my $self = shift;
unless (exists $self->{_storageLocation}) {
$self->{_storageLocation} = WebGUI::Storage::Image->get($self->get("storageId"));
if ($self->get("storageId") eq "") {
$self->{_storageLocation} = WebGUI::Storage::Image->create;
$self->update({storageId=>$self->{_storageLocation}->getId});
} else {
$self->{_storageLocation} = WebGUI::Storage::Image->get($self->get("storageId"));
}
}
return $self->{_storageLocation};
}
@ -168,7 +173,7 @@ sub getStorageLocation {
#-------------------------------------------------------------------
sub getThumbnailUrl {
my $self = shift;
return $self->getStorageLocation->getThumbnailUrl;
return $self->getStorageLocation->getThumbnailUrl($self->get("filename"));
}

View file

@ -16,11 +16,13 @@ package WebGUI::Asset::FilePile;
use strict;
use WebGUI::Asset;
use WebGUI::Asset::File;
use WebGUI::Asset::File::Image;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Storage;
use WebGUI::Storage::Image;
use WebGUI::TabForm;
use WebGUI::Utility;
@ -140,16 +142,16 @@ sub edit {
#-------------------------------------------------------------------
sub editSave {
my $class = shift;
my $parent = WebGUI::Asset->newByUrl;
my $tempStorage = WebGUI::Storage->create;
$tempStorage->addFileFromFormPost("file");
foreach my $filename (@{$tempStorage->getFiles}) {
my $storage = WebGUI::Storage->create;
my $storage = WebGUI::Storage::Image->create;
$storage->addFileFromFilesystem($tempStorage->getPath($filename));
$storage->setPrivileges($class->getParent->get("ownerUserId"),$class->getParent->get("groupIdView"),$class->getParent->get("groupIdEdit"));
my %data;
my $class = 'WebGUI::Asset::File';
$class = "WebGUI::Asset::File::Image" if (isIn($storage->getFileExtension($filename),qw(jpg jpeg gif png)));
foreach my $definition (@{$class->definition}) {
my $className = 'WebGUI::Asset::File';
$className = "WebGUI::Asset::File::Image" if ($storage->isImage($filename));
foreach my $definition (@{$className->definition}) {
foreach my $property (keys %{$definition->{properties}}) {
$data{$property} = WebGUI::FormProcessor::process(
$property,
@ -158,17 +160,17 @@ sub editSave {
);
}
}
$data{className} = $class;
$data{className} = $className;
$data{storageId} = $storage->getId;
$data{filename} = $data{title} = $data{menuTitle} = $filename;
$data{url} = $parent->getUrl.'/'.$filename;
my $newAsset = $parent->addChild(\%data);
$data{url} = $class->getParent->getUrl.'/'.$filename;
my $newAsset = $class->getParent->addChild(\%data);
$newAsset->setSize($storage->getFileSize($filename));
$newAsset->generateThumbnail if ($class eq "WebGUI::Asset::File::Image");
$newAsset->generateThumbnail if ($className eq "WebGUI::Asset::File::Image");
}
$tempStorage->delete;
return $parent->www_manageAssets if ($session{form}{proceed} eq "manageAssets");
return $parent->www_view;
return $class->getParent->www_manageAssets if ($session{form}{proceed} eq "manageAssets");
return $class->getParent->www_view;
}
#-------------------------------------------------------------------
@ -176,9 +178,9 @@ sub getIcon {
my $self = shift;
my $small = shift;
if ($small) {
return $session{config}{extrasURL}.'/assets/small/folder.gif';
return $session{config}{extrasURL}.'/assets/small/filePile.gif';
}
return $session{config}{extrasURL}.'/assets/folder.gif';
return $session{config}{extrasURL}.'/assets/filePile.gif';
}
@ -200,6 +202,7 @@ sub getUploadControl {
WebGUI::Style::setScript($session{config}{extrasURL}.'/FileUploadControl.js',{type=>"text/javascript"});
my $uploadControl = '<div id="fileUploadControl"> </div>
<script>
var fileLimit = 100;
var images = new Array();
';
opendir(DIR,$session{config}{extrasPath}.'/fileIcons');

View file

@ -157,6 +157,7 @@ sub definition {
sub DESTROY {
my $self = shift;
$self->{_thread}->DESTROY if (exists $self->{_thread});
$self->{_storageLocation}->DESTROY if (exists $self->{_storageLocation});
$self->SUPER::DESTROY;
}

View file

@ -155,6 +155,7 @@ sub view {
push(@{$vars{"file_loop"}},{
id=>$child->getId,
title=>$child->get("title"),
synopsis=>$child->get("synopsis"),
size=>WebGUI::Utility::formatBytes($child->get("assetSize")),
"date.epoch"=>$child->get("dateStamp"),
"icon.small"=>$child->getIcon(1),

View file

@ -64,23 +64,23 @@ The file to generate a thumbnail for.
=head3 thumbnailSize
A size, in pixels, of the maximum height or width of a thumbnail. If specified this will change the thumbnail size of the image. If unspecified the thumbnail size set in the properties of this asset will be used.
The size in pixels of the thumbnail to be generated. If not specified the thumbnail size in the global settings will be used.
=cut
sub generateThumbnail {
my $self = shift;
my $filename = shift;
my $thumbnailSize = shift;
if (defined $filename) {
my $thumbnailSize = shift || $session{setting}{thumbnailSize};
unless (defined $filename) {
WebGUI::ErrorHandler::warn("Can't generate a thumbnail when you haven't specified a file.");
return 0;
}
if ($hasImageMagick) {
unless ($hasImageMagick) {
WebGUI::ErrorHandler::warn("Can't generate a thumbnail if you don't have Image Magick.");
return 0;
}
if ($self->isImage($filename)) {
unless ($self->isImage($filename)) {
WebGUI::ErrorHandler::warn("Can't generate a thumbnail for something that's not an image.");
return 0;
}