Made a central attachment management system for wobjects that attach files directly to their property lists.
This commit is contained in:
parent
1be05a3391
commit
67d6329c22
5 changed files with 84 additions and 91 deletions
|
|
@ -1,5 +1,5 @@
|
|||
insert into webguiVersion values ('4.7.0','upgrade',unix_timestamp());
|
||||
|
||||
update international set internationalId=728, namespace='WebGUI' where internationalId=12 and namespace='Product';
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -245,6 +245,41 @@ sub duplicate {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 fileProperty ( name, labelId )
|
||||
|
||||
Returns a file property form row which can be used in any Wobject
|
||||
properties page.
|
||||
|
||||
NOTE: This method is meant for use with www_deleteFile.
|
||||
|
||||
=item name
|
||||
|
||||
The name of the property that stores the filename.
|
||||
|
||||
=item labelId
|
||||
|
||||
The internationalId of the form label for this file.
|
||||
|
||||
=cut
|
||||
|
||||
sub fileProperty {
|
||||
my ($self, $f, $labelId, $name);
|
||||
$self = shift;
|
||||
$name = shift;
|
||||
$labelId = shift;
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
if ($self->get($name) ne "") {
|
||||
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteFile&file='.$name.'&wid='.$self->get("wobjectId")).'">'.
|
||||
WebGUI::International::get(391).'</a>',
|
||||
WebGUI::International::get($labelId,$self->get("namespace")));
|
||||
} else {
|
||||
$f->file($name,WebGUI::International::get($labelId,$self->get("namespace")));
|
||||
}
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 get ( [ propertyName ] )
|
||||
|
||||
Returns a hash reference containing all of the properties of this
|
||||
|
|
@ -720,6 +755,39 @@ sub www_deleteConfirm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteFile ( )
|
||||
|
||||
Displays a confirmation message relating to the deletion of a file.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteFile {
|
||||
$_[0]->confirm(
|
||||
WebGUI::International::get(728),
|
||||
WebGUI::URL::page('func=deleteFileConfirm&wid='.$_[0]->get("wobjectId").'&file='.$session{form}{file}),
|
||||
WebGUI::URL::page('func=edit&wid='.$_[0]->get("wobjectId"))
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteFileConfirm ( )
|
||||
|
||||
Deletes a file from this instance.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteFileConfirm {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$_[0]->set({$session{form}{file}=>''});
|
||||
return $_[0]->www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteMessage ( )
|
||||
|
||||
Displays a message asking for confirmation to delete a message from
|
||||
|
|
@ -1019,10 +1087,15 @@ sub www_search {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_showMessage ( )
|
||||
=head2 www_showMessage ( [menuItem] )
|
||||
|
||||
Shows a message from a discussion.
|
||||
|
||||
=item menuItem
|
||||
|
||||
You can optionally extend this method by passing in an HTML string
|
||||
of menu items to be added to the menu of this display.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_showMessage {
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue