[ 1276593 ] 6.7.2 Product Images don't upload

This commit is contained in:
Matthew Wilson 2005-10-16 23:04:51 +00:00
parent f11dd7c753
commit 04329085dc
2 changed files with 129 additions and 101 deletions

View file

@ -1,5 +1,6 @@
6.7.7 6.7.7
- fix [ 1324230 ] 6.7.6 - Template, Rich Text Editor options not showing - fix [ 1324230 ] 6.7.6 - Template, Rich Text Editor options not showing
- fix [ 1276593 ] 6.7.2 Product Images don't upload
- fix [ 1324128 ] Help: List of Available Macros not working - fix [ 1324128 ] Help: List of Available Macros not working
- fix [ 1315408 ] Navigation sometimes fails to use correct startpoint - fix [ 1315408 ] Navigation sometimes fails to use correct startpoint
- fix [ 1305577 ] 6.7.5 Cannot insert a Link to a Page in the WebGUI page - fix [ 1305577 ] 6.7.5 Cannot insert a Link to a Page in the WebGUI page

View file

@ -27,23 +27,23 @@ our @ISA = qw(WebGUI::Asset::Wobject);
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _addFileTab { sub _addFileTab {
my $self = shift; my $self = shift;
my $tabform = $_[0]; my $tabform = $_[0];
my $column = $_[1]; my $column = $_[1];
my $internationalId = $_[2]; my $internationalId = $_[2];
unless ($self->get($column)){ unless ($self->get($column)){
$tabform->getTab("properties")->file( $tabform->getTab("properties")->file(
-name=>$column, -name=>$column,
-label=>WebGUI::International::get($internationalId,"Asset_Product"), -label=>WebGUI::International::get($internationalId,"Asset_Product"),
); );
return; return;
} }
my $file = WebGUI::Storage->get($self->get($column)); my $file = WebGUI::Storage->get($self->get($column));
$tabform->getTab("properties")->readOnly( $tabform->getTab("properties")->readOnly(
-value=>'<a href="'.$self->getUrl('func=deleteFileConfirm&file='.$column).'">'.WebGUI::International::get("deleteImage","Asset_Product").'</a>', -value=>'<a href="'.$self->getUrl('func=deleteFileConfirm&file='.$column).'">'.WebGUI::International::get("deleteImage","Asset_Product").'</a>',
-label=>WebGUI::International::get($internationalId,"Asset_Product"), -label=>WebGUI::International::get($internationalId,"Asset_Product"),
); );
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -60,12 +60,15 @@ sub _duplicateFile {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _save { sub _save {
my $self = shift; my $self = shift;
return "" unless ($session{form}{$_[0]}); my $file = WebGUI::Storage::Image->create;
my $file = WebGUI::Storage::Image->create; my $filename = $file->addFileFromFormPost($_[0]);
my $filename = $file->addFileFromFormPost($_[0]); unless ($filename) {
$file->delete;
return "";
}
$file->generateThumbnail($filename); $file->generateThumbnail($filename);
WebGUI::SQL->write("update Product set $_[0]=".quote($file->getId)." where assetId=".quote($self->getId)); WebGUI::SQL->write("update Product set $_[0]=".quote($file->getId)." where assetId=".quote($self->getId)." and revisionDate=".quote($self->get("revisionDate")));
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -77,15 +80,16 @@ Override the default method in order to deal with attachments.
=cut =cut
sub addRevision { sub addRevision {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = $self->SUPER::addRevision(@_);
foreach my $field (qw(image1 image2 image3 brochure manual warranty)) { foreach my $field (qw(image1 image2 image3 brochure manual warranty)) {
if ($self->get($field)) { if ($self->get($field)) {
my $newStorage = WebGUI::Storage->get($self->get($field))->copy; my $newStorage = WebGUI::Storage->get($self->get($field))->copy;
$newSelf->update({$field=>$newStorage->getId}); $newSelf->update({$field=>$newStorage->getId});
} WebGUI::SQL->write("update Product set $field=".quote($newStorage->getId)." where assetId=".quote($newSelf->getId)." and revisionDate=".quote($newSelf->get("revisionDate")));
}
} }
return $newSelf; return $newSelf;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -101,18 +105,42 @@ sub definition {
templateId =>{ templateId =>{
fieldType=>"template", fieldType=>"template",
defaultValue=>'PBtmpl0000000000000056' defaultValue=>'PBtmpl0000000000000056'
}, },
price=>{ price=>{
fieldType=>"text", fieldType=>"text",
defaultValue=>undef defaultValue=>undef
}, },
productNumber=>{ productNumber=>{
fieldType=>"text", fieldType=>"text",
defaultValue=>undef defaultValue=>undef
}, },
} # image1=>{
}); # fieldType=>"text",
return $class->SUPER::definition($definition); # defaultValue=>undef
# },
# image2=>{
# fieldType=>"text",
# defaultValue=>undef
# },
# image3=>{
# fieldType=>"text",
# defaultValue=>undef
# },
# brochure=>{
# fieldType=>"text",
# defaultValue=>undef
# },
# manual=>{
# fieldType=>"text",
# defaultValue=>undef
# },
# warranty=>{
# fieldType=>"text",
# defaultValue=>undef
# },
}
});
return $class->SUPER::definition($definition);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -232,41 +260,41 @@ sub getIndexerParams {
my $now = shift; my $now = shift;
return { return {
Product => { Product => {
sql => "select Product.assetId, sql => "select Product.assetId,
Product.image1, Product.image1,
Product.image2, Product.image2,
Product.image3, Product.image3,
Product.brochure, Product.brochure,
Product.manual, Product.manual,
Product.warranty, Product.warranty,
Product.price, Product.price,
Product.productNumber, Product.productNumber,
Product_benefit.benefit, Product_benefit.benefit,
Product_feature.feature, Product_feature.feature,
Product_specification.name, Product_specification.name,
Product_specification.value, Product_specification.value,
Product_specification.units, Product_specification.units,
asset.ownerUserId as ownerId, asset.ownerUserId as ownerId,
asset.url, asset.url,
asset.groupIdView, asset.groupIdView,
asset.title, asset.title,
asset.menuTitle, asset.menuTitle,
asset.className, asset.className,
asset.synopsis asset.synopsis
from Product, asset from Product, asset
left join Product_benefit on Product_benefit.assetId=Product.assetId left join Product_benefit on Product_benefit.assetId=Product.assetId
left join Product_feature on Product_feature.assetId=Product.assetId left join Product_feature on Product_feature.assetId=Product.assetId
left join Product_specification on Product_specification.assetId=Product.assetId left join Product_specification on Product_specification.assetId=Product.assetId
where Product.assetId = asset.assetId where Product.assetId = asset.assetId
and asset.startDate < $now and asset.startDate < $now
and asset.endDate > $now", and asset.endDate > $now",
fieldsToIndex => ["image1", "image2", "image3", "brochure", "manual", "warranty", "price", fieldsToIndex => ["image1", "image2", "image3", "brochure", "manual", "warranty", "price",
"productNumber", "benefit", "feature", "name", "value", "units"], "productNumber", "benefit", "feature", "name", "value", "units"],
contentType => 'content', contentType => 'content',
url => 'WebGUI::URL::gateway($data{url})', url => 'WebGUI::URL::gateway($data{url})',
headerShortcut => 'select title from asset where assetId = \'$data{assetId}\'', headerShortcut => 'select title from asset where assetId = \'$data{assetId}\'',
bodyShortcut => 'select synopsis from asset where assetId = \'$data{asssetId}\'', bodyShortcut => 'select synopsis from asset where assetId = \'$data{asssetId}\'',
} }
}; };
} }
@ -312,15 +340,15 @@ sub purge {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub purgeRevision { sub purgeRevision {
my $self = shift; my $self = shift;
WebGUI::Storage->get($self->get("image1"))->delete if ($self->get("image1")); WebGUI::Storage->get($self->get("image1"))->delete if ($self->get("image1"));
WebGUI::Storage->get($self->get("image2"))->delete if ($self->get("image2")); WebGUI::Storage->get($self->get("image2"))->delete if ($self->get("image2"));
WebGUI::Storage->get($self->get("image3"))->delete if ($self->get("image3")); WebGUI::Storage->get($self->get("image3"))->delete if ($self->get("image3"));
WebGUI::Storage->get($self->get("brochure"))->delete if ($self->get("brochure")); WebGUI::Storage->get($self->get("brochure"))->delete if ($self->get("brochure"));
WebGUI::Storage->get($self->get("manual"))->delete if ($self->get("manual")); WebGUI::Storage->get($self->get("manual"))->delete if ($self->get("manual"));
WebGUI::Storage->get($self->get("warranty"))->delete if ($self->get("warranty")); WebGUI::Storage->get($self->get("warranty"))->delete if ($self->get("warranty"));
return $self->SUPER::purgeRevision; return $self->SUPER::purgeRevision;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -467,10 +495,9 @@ sub www_deleteSpecificationConfirm {
#} #}
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editSave { sub processPropertiesFromFormPost {
my $self = shift; my $self = shift;
return WebGUI::Privilege::insufficient() unless ($self->canEdit); $self->SUPER::processPropertiesFromFormPost;
$self->SUPER::www_editSave();
$self->_save("image1"); $self->_save("image1");
$self->_save("image2"); $self->_save("image2");
$self->_save("image3"); $self->_save("image3");
@ -621,20 +648,20 @@ sub www_editSpecification {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editSpecificationSave { sub www_editSpecificationSave {
my $self = shift; my $self = shift;
return WebGUI::Privilege::insufficient() unless ($self->canEdit); return WebGUI::Privilege::insufficient() unless ($self->canEdit);
$session{form}{name} = $session{form}{name_new} if ($session{form}{name_new} ne ""); $session{form}{name} = $session{form}{name_new} if ($session{form}{name_new} ne "");
$session{form}{units} = $session{form}{units_new} if ($session{form}{units_new} ne ""); $session{form}{units} = $session{form}{units_new} if ($session{form}{units_new} ne "");
$self->setCollateral("Product_specification", "Product_specificationId", { $self->setCollateral("Product_specification", "Product_specificationId", {
Product_specificationId => $session{form}{sid}, Product_specificationId => $session{form}{sid},
name => $session{form}{name}, name => $session{form}{name},
value => $session{form}{value}, value => $session{form}{value},
units => $session{form}{units} units => $session{form}{units}
}); });
return "" unless($session{form}{proceed}); return "" unless($session{form}{proceed});
$session{form}{sid} = "new"; $session{form}{sid} = "new";
return $self->www_editSpecification(); return $self->www_editSpecification();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------