Made a central attachment management system for wobjects that attach files directly to their property lists.

This commit is contained in:
JT Smith 2002-09-30 01:58:29 +00:00
parent 1be05a3391
commit 67d6329c22
5 changed files with 84 additions and 91 deletions

View file

@ -54,26 +54,6 @@ sub set {
$_[0]->SUPER::set($_[1],[qw(image linkTitle linkURL attachment convertCarriageReturns alignImage allowDiscussion)]);
}
#-------------------------------------------------------------------
sub www_deleteAttachment {
if (WebGUI::Privilege::canEditPage()) {
$_[0]->set({attachment=>''});
return $_[0]->www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteImage {
if (WebGUI::Privilege::canEditPage()) {
$_[0]->set({image=>''});
return $_[0]->www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, $editTimeout, $groupToModerate, %hash, $f);
@ -88,24 +68,14 @@ sub www_edit {
$output = helpIcon(1,$namespace);
$output .= '<h1>'.WebGUI::International::get(12,$namespace).'</h1>';
$f = WebGUI::HTMLForm->new;
if ($_[0]->get("image") ne "") {
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteImage&wid='.$session{form}{wid}).'">'.
WebGUI::International::get(391).'</a>',WebGUI::International::get(6,$namespace));
} else {
$f->file("image",WebGUI::International::get(6,$namespace));
}
$f->raw($_[0]->fileProperty("image",6));
%hash = (
right => WebGUI::International::get(15,$namespace),
left => WebGUI::International::get(16,$namespace),
center => WebGUI::International::get(17,$namespace)
);
$f->select("alignImage",\%hash,WebGUI::International::get(14,$namespace),[$_[0]->get("alignImage")]);
if ($_[0]->get("attachment") ne "") {
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteAttachment&wid='.$session{form}{wid}).'">'.
WebGUI::International::get(391).'</a>',WebGUI::International::get(9,$namespace));
} else {
$f->file("attachment",WebGUI::International::get(9,$namespace));
}
$f->raw($_[0]->fileProperty("attachment",9));
$f->text("linkTitle",WebGUI::International::get(7,$namespace),$_[0]->get("linkTitle"));
$f->url("linkURL",WebGUI::International::get(8,$namespace),$_[0]->get("linkURL"));
$f->yesNo("convertCarriageReturns",WebGUI::International::get(10,$namespace),$_[0]->get("convertCarriageReturns")

View file

@ -45,16 +45,6 @@ sub set {
$_[0]->SUPER::set($_[1],[qw(linkURL attachment)]);
}
#-------------------------------------------------------------------
sub www_deleteAttachment {
if (WebGUI::Privilege::canEditPage()) {
$_[0]->set({attachment=>''});
return $_[0]->www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, $f);
@ -63,12 +53,7 @@ sub www_edit {
$output .= '<h1>'.WebGUI::International::get(6,$namespace).'</h1>';
$f = WebGUI::HTMLForm->new;
$f->url("linkURL",WebGUI::International::get(1,$_[0]->get("namespace")),$_[0]->get("linkURL"));
if ($_[0]->get("attachment") eq "") {
$f->file("attachment",WebGUI::International::get(2,$_[0]->get("namespace")))
} else {
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteAttachment&wid='.$session{form}{wid}).'">'
.WebGUI::International::get(3,$namespace).'</a>',WebGUI::International::get(2,$_[0]->get("namespace")))
}
$f->raw($_[0]->fileProperty("attachment",2));
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly);
return $output;
} else {

View file

@ -27,22 +27,6 @@ our $namespace = "Product";
our $name = WebGUI::International::get(1,$namespace);
#-------------------------------------------------------------------
sub _fileProperty {
my ($filename, $f, $labelId, $name);
$name = shift;
$labelId = shift;
$filename = shift;
$f = WebGUI::HTMLForm->new;
if ($filename ne "") {
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteFile&file='.$name.'&wid='.$session{form}{wid}).'">'.
WebGUI::International::get(391).'</a>',WebGUI::International::get($labelId,$namespace));
} else {
$f->file($name,WebGUI::International::get($labelId,$namespace));
}
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub _reorderAccessories {
my ($sth, $i, $id);
@ -344,25 +328,6 @@ sub www_deleteFeatureConfirm {
}
}
#-------------------------------------------------------------------
sub www_deleteFile {
$_[0]->confirm(
WebGUI::International::get(12,$namespace),
WebGUI::URL::page('func=deleteFileConfirm&wid='.$_[0]->get("wobjectId").'&file='.$session{form}{file}),
WebGUI::URL::page('func=edit&wid='.$_[0]->get("wobjectId"))
);
}
#-------------------------------------------------------------------
sub www_deleteFileConfirm {
if (WebGUI::Privilege::canEditPage()) {
$_[0]->set({$session{form}{file}=>''});
return $_[0]->www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteRelated {
$_[0]->confirm(
@ -437,12 +402,12 @@ sub www_edit {
$f = WebGUI::HTMLForm->new;
$f->text("price",WebGUI::International::get(10,$namespace),$_[0]->get("price"));
$f->text("productNumber",WebGUI::International::get(11,$namespace),$_[0]->get("productNumber"));
$f->raw(_fileProperty("image1",7,$_[0]->get("image1")));
$f->raw(_fileProperty("image2",8,$_[0]->get("image2")));
$f->raw(_fileProperty("image3",9,$_[0]->get("image3")));
$f->raw(_fileProperty("brochure",13,$_[0]->get("brochure")));
$f->raw(_fileProperty("manual",14,$_[0]->get("manual")));
$f->raw(_fileProperty("warranty",15,$_[0]->get("warranty")));
$f->raw($_[0]->fileProperty("image1",7));
$f->raw($_[0]->fileProperty("image2",8));
$f->raw($_[0]->fileProperty("image3",9));
$f->raw($_[0]->fileProperty("brochure",13));
$f->raw($_[0]->fileProperty("manual",14));
$f->raw($_[0]->fileProperty("warranty",15));
$templates = WebGUI::SQL->buildHashRef("select productTemplateId,name from Product_template order by name");
$f->select("productTemplateId",$templates,WebGUI::International::get(61,$namespace),[$template]);
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly);