added attachments for CS
This commit is contained in:
parent
018223cd1a
commit
ebae62c366
4 changed files with 97 additions and 24 deletions
|
|
@ -29,6 +29,7 @@ use WebGUI::Paginator;
|
||||||
use WebGUI::Privilege;
|
use WebGUI::Privilege;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
|
use WebGUI::Storage::Image;
|
||||||
use WebGUI::URL;
|
use WebGUI::URL;
|
||||||
use WebGUI::User;
|
use WebGUI::User;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
|
|
@ -248,6 +249,21 @@ sub getIcon {
|
||||||
return $session{config}{extrasURL}.'/assets/post.gif';
|
return $session{config}{extrasURL}.'/assets/post.gif';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub getImageUrl {
|
||||||
|
my $self = shift;
|
||||||
|
return undef if ($self->get("storageId") eq "");
|
||||||
|
my $storage = $self->getStorageLocation;
|
||||||
|
my $url;
|
||||||
|
foreach my $filename (@{$storage->getFiles}) {
|
||||||
|
if ($storage->isImage($filename)) {
|
||||||
|
$url = $storage->getUrl($filename);
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub getName {
|
sub getName {
|
||||||
return "Post";
|
return "Post";
|
||||||
|
|
@ -315,6 +331,20 @@ sub getStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub getStorageLocation {
|
||||||
|
my $self = shift;
|
||||||
|
unless (exists $self->{_storageLocation}) {
|
||||||
|
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};
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub getSynopsisAndContentFromFormPost {
|
sub getSynopsisAndContentFromFormPost {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
@ -361,18 +391,30 @@ sub getTemplateVars {
|
||||||
$var{'rate.url.4'} = $self->getRateUrl(4);
|
$var{'rate.url.4'} = $self->getRateUrl(4);
|
||||||
$var{'rate.url.5'} = $self->getRateUrl(5);
|
$var{'rate.url.5'} = $self->getRateUrl(5);
|
||||||
$var{'hasRated'} = $self->hasRated;
|
$var{'hasRated'} = $self->hasRated;
|
||||||
# if ($submission->{image} ne "") {
|
my $gotImage;
|
||||||
# $file = WebGUI::Attachment->new($submission->{image},$self->wid,$submissionId);
|
my $gotAttachment;
|
||||||
# $var{"image.url"} = $file->getURL;
|
unless ($self->get("storageId") eq "") {
|
||||||
# $var{"image.thumbnail"} = $file->getThumbnail;
|
my $storage = $self->getStorageLocation;
|
||||||
# }
|
foreach my $filename (@{$storage->getFiles}) {
|
||||||
# if ($submission->{attachment} ne "") {
|
if (!$gotImage && $storage->isImage($filename)) {
|
||||||
# $file = WebGUI::Attachment->new($submission->{attachment},$self->wid,$submissionId);
|
$var{"image.url"} = $storage->getUrl($filename);
|
||||||
# $var{"attachment.box"} = $file->box;
|
$var{"image.thumbnail"} = $storage->getThumbnailUrl($filename);
|
||||||
# $var{"attachment.url"} = $file->getURL;
|
$gotImage = 1;
|
||||||
# $var{"attachment.icon"} = $file->getIcon;
|
}
|
||||||
# $var{"attachment.name"} = $file->getFilename;
|
if (!$gotAttachment && !$storage->isImage($filename)) {
|
||||||
# }
|
$var{"attachment.url"} = $storage->getUrl($filename);
|
||||||
|
$var{"attachment.icon"} = $storage->getFileIconUrl($filename);
|
||||||
|
$var{"attachment.name"} = $filename;
|
||||||
|
}
|
||||||
|
push(@{$var{"attachment_loop"}}, {
|
||||||
|
url=>$storage->getUrl($filename),
|
||||||
|
icon=>$storage->getFileIconUrl($filename),
|
||||||
|
filename=>$filename,
|
||||||
|
thumbnail=>$storage->getThumbnailUrl($filename),
|
||||||
|
isImage=>$storage->isImage($filename)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
return \%var;
|
return \%var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -385,13 +427,36 @@ sub getThread {
|
||||||
return $self->{_thread};
|
return $self->{_thread};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub getThumbnailUrl {
|
||||||
|
my $self = shift;
|
||||||
|
return undef if ($self->get("storageId") eq "");
|
||||||
|
my $storage = $self->getStorageLocation;
|
||||||
|
my $url;
|
||||||
|
foreach my $filename (@{$storage->getFiles}) {
|
||||||
|
if ($storage->isImage($filename)) {
|
||||||
|
$url = $storage->getThumbnailUrl($filename);
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub getUploadControl {
|
sub getUploadControl {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $existingFiles = shift;
|
my $uploadControl;
|
||||||
|
if ($self->get("storageId")) {
|
||||||
|
my $i;
|
||||||
|
foreach my $filename (@{$self->getStorageLocation->getFiles}) {
|
||||||
|
$uploadControl .= '<a href="'.$self->getStorageLocation->getUrl($filename).'">'.$filename.'</a><br />';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
return $uploadControl unless ($i < $self->getThread->getParent->get("attachmentsPerPost"));
|
||||||
|
}
|
||||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/FileUploadControl.js',{type=>"text/javascript"});
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/FileUploadControl.js',{type=>"text/javascript"});
|
||||||
my $uploadControl = '<div id="fileUploadControl"> </div>
|
$uploadControl .= '<div id="fileUploadControl"> </div>
|
||||||
<script>
|
<script>
|
||||||
var images = new Array();
|
var images = new Array();
|
||||||
var fileLimit = '.$self->getThread->getParent->get("attachmentsPerPost").';
|
var fileLimit = '.$self->getThread->getParent->get("attachmentsPerPost").';
|
||||||
|
|
@ -409,11 +474,6 @@ sub getUploadControl {
|
||||||
$uploadControl .= 'var uploader = new FileUploadControl("fileUploadControl", images);
|
$uploadControl .= 'var uploader = new FileUploadControl("fileUploadControl", images);
|
||||||
uploader.addRow();
|
uploader.addRow();
|
||||||
</script>';
|
</script>';
|
||||||
if ($self->get("storageId")) {
|
|
||||||
foreach my $filename (@{$self->getStorageLocation->getFiles}) {
|
|
||||||
$uploadControl .= '<a href="'.$self->getStorageLocation->getFileUrl($filename).'">'.$filename.'</a><br />';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $uploadControl;
|
return $uploadControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -579,6 +639,13 @@ sub processPropertiesFromFormPost {
|
||||||
} else {
|
} else {
|
||||||
$self->setStatusApproved;
|
$self->setStatusApproved;
|
||||||
}
|
}
|
||||||
|
my $storage = $self->getStorageLocation;
|
||||||
|
my $filename = $storage->addFileFromFormPost("file");
|
||||||
|
if (defined $filename) {
|
||||||
|
$self->setSize($storage->getFileSize($filename));
|
||||||
|
$storage->setPrivileges($self->get("ownerUserId"), $self->get("groupIdView"), $self->get("groupIdEdit"));
|
||||||
|
$storage->generateThumbnail($filename);
|
||||||
|
}
|
||||||
$session{form}{proceed} = "redirectToParent";
|
$session{form}{proceed} = "redirectToParent";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ sub appendPostListTemplateVars {
|
||||||
foreach my $row (@$page) {
|
foreach my $row (@$page) {
|
||||||
my $post = WebGUI::Asset::Wobject::Collaboration->newByPropertyHashRef($row);
|
my $post = WebGUI::Asset::Wobject::Collaboration->newByPropertyHashRef($row);
|
||||||
$post->{_parent} = $self; # caching parent for efficiency
|
$post->{_parent} = $self; # caching parent for efficiency
|
||||||
my $controls = deleteIcon('func=delete',$post->get("url"),"Delete").editIcon('func=edit',$post->get("ur"));
|
my $controls = deleteIcon('func=delete',$post->get("url"),"Delete").editIcon('func=edit',$post->get("url"));
|
||||||
if ($self->get("sortBy") eq "lineage") {
|
if ($self->get("sortBy") eq "lineage") {
|
||||||
if ($self->get("sortOrder") eq "desc") {
|
if ($self->get("sortOrder") eq "desc") {
|
||||||
$controls .= moveUpIcon('func=demote',$post->get("url")).moveDownIcon('func=promote',$post->get("url"));
|
$controls .= moveUpIcon('func=demote',$post->get("url")).moveDownIcon('func=promote',$post->get("url"));
|
||||||
|
|
@ -68,8 +68,8 @@ sub appendPostListTemplateVars {
|
||||||
rating_loop=>\@rating_loop,
|
rating_loop=>\@rating_loop,
|
||||||
"content"=>$post->formatContent,
|
"content"=>$post->formatContent,
|
||||||
"status"=>$post->getStatus,
|
"status"=>$post->getStatus,
|
||||||
# "thumbnail"=>$submission->getThumbnailUrl,
|
"thumbnail"=>$post->getThumbnailUrl,
|
||||||
# "submission.image"=>$submission->getImageUrl,
|
"image.url"=>$post->getImageUrl,
|
||||||
"dateSubmitted.human"=>epochToHuman($post->get("dateSubmitted"),"%z"),
|
"dateSubmitted.human"=>epochToHuman($post->get("dateSubmitted"),"%z"),
|
||||||
"dateUpdated.human"=>epochToHuman($post->get("dateUpdated"),"%z"),
|
"dateUpdated.human"=>epochToHuman($post->get("dateUpdated"),"%z"),
|
||||||
"timeSubmitted.human"=>epochToHuman($post->get("dateSubmitted"),"%Z"),
|
"timeSubmitted.human"=>epochToHuman($post->get("dateSubmitted"),"%Z"),
|
||||||
|
|
|
||||||
|
|
@ -498,7 +498,7 @@ sub getFiles {
|
||||||
}
|
}
|
||||||
return \@list;
|
return \@list;
|
||||||
}
|
}
|
||||||
return undef;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
function FileUploadControl(workspaceId, imageArray) {
|
function FileUploadControl(workspaceId, imageArray) {
|
||||||
|
|
||||||
this.images = images;
|
this.images = images;
|
||||||
|
this.fileLimit = fileLimit;
|
||||||
|
this.fileCount = 1;
|
||||||
this.dom=document.getElementById&&!document.all;
|
this.dom=document.getElementById&&!document.all;
|
||||||
this.topLevelElement=this.dom? "HTML" : "BODY"
|
this.topLevelElement=this.dom? "HTML" : "BODY"
|
||||||
|
|
||||||
|
|
@ -104,6 +106,7 @@ function FileUploadControl_removeButtonClick(e) {
|
||||||
var control = FileUploadControl_getControl(firedobj);
|
var control = FileUploadControl_getControl(firedobj);
|
||||||
|
|
||||||
control.removeRow(firedobj);
|
control.removeRow(firedobj);
|
||||||
|
control.fileCount--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,7 +119,10 @@ function FileUploadControl_valueChange(e) {
|
||||||
var control = FileUploadControl_getControl(firedobj);
|
var control = FileUploadControl_getControl(firedobj);
|
||||||
|
|
||||||
if (control.tbody.childNodes[control.tbody.childNodes.length -1].childNodes[1].childNodes[0].value != "") {
|
if (control.tbody.childNodes[control.tbody.childNodes.length -1].childNodes[1].childNodes[0].value != "") {
|
||||||
control.addRow();
|
if (control.fileCount < control.fileLimit) {
|
||||||
|
control.addRow();
|
||||||
|
control.fileCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
control.swapImage(firedobj);
|
control.swapImage(firedobj);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue