CS a little closer to bliss
This commit is contained in:
parent
b8f2e10e20
commit
63fcf47836
9 changed files with 236 additions and 488 deletions
|
|
@ -74,6 +74,8 @@
|
|||
We recommend AWStats instead (www.awstats.org)
|
||||
- Added the ability to switch the style for user functions like profiles,
|
||||
authentication, etc.
|
||||
- Merged the forum and USS into a new asset type called the Collaboration
|
||||
System with all the best features of each system.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,14 @@ save you many hours of grief.
|
|||
subscriptionCodeBatch, subscriptionCodeSubscriptions, transaction,
|
||||
transactionItem
|
||||
|
||||
* Due to the sweeping changes in this release the migration script may not
|
||||
work perfectly on your site. It should get you 90% of the way there,
|
||||
but it will be up to you to fix the problems it can't catch. Some of
|
||||
the things to look out for are Collaboration System (formerly USS
|
||||
and forum) templates. Also look at images and navigations as they've
|
||||
been moved from outside the content system, to inside it as assets
|
||||
in the new asset tree.
|
||||
|
||||
|
||||
6.2.10
|
||||
--------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -540,7 +540,6 @@ while (my ($id, $template, $namespace) = $sth->array) {
|
|||
$template =~ s/thread\.new\.url/add.url/ixsg;
|
||||
$template =~ s/thread\.new\.label/add.label/ixsg;
|
||||
$template =~ s/thread\.root\.subject/title/ixsg;
|
||||
$template =~ s/thread\.root\.url/url/ixsg;
|
||||
$template =~ s/thread\.root\.epoch/dateSubmitted/ixsg;
|
||||
$template =~ s/thread\.root\.url/url/ixsg;
|
||||
$template =~ s/thread\.root\.date/dateSubmitted.human/ixsg;
|
||||
|
|
@ -550,7 +549,7 @@ while (my ($id, $template, $namespace) = $sth->array) {
|
|||
$template =~ s/thread\.root\.user\.name/username/ixsg;
|
||||
$template =~ s/thread\.root\.user\.id/ownerUserId/ixsg;
|
||||
$template =~ s/thread\.root\.user\.isVisitor/user.isVisitor/ixsg;
|
||||
$template =~ s/thread\.root\..status/status/ixsg;
|
||||
$template =~ s/thread\.root\.status/status/ixsg;
|
||||
$template =~ s/thread\.last\.subject/lastReply.title/ixsg;
|
||||
$template =~ s/thread\.last\.epoch/lastReply.dateSubmitted/ixsg;
|
||||
$template =~ s/thread\.last\.date/lastReply.dateSubmitted.human/ixsg;
|
||||
|
|
@ -610,25 +609,39 @@ while (my ($id, $template, $namespace) = $sth->array) {
|
|||
$newNamespace = "Collaboration";
|
||||
} elsif ($namespace eq "USS/SubmissionForm") {
|
||||
$newNamespace = "Collaboration/PostForm";
|
||||
if ($template =~ /image\.form/ixsg && $template =~ /attachment\.form/ixsg) {
|
||||
$template =~ s/\<tmpl_var\s+image\.form\>//ixsg;
|
||||
$template =~ s/\<tmpl_var\s+image\.label\>//ixsg;
|
||||
} elsif ($template =~ /image\.form/) {
|
||||
$template =~ s/image\.form/attachment.form/ixsg;
|
||||
}
|
||||
} elsif ($namespace eq "USS/Submission") {
|
||||
$newNamespace = "Collaboration/Thread";
|
||||
if ($template =~ /attachment\.box/ixsg) {
|
||||
my $box = '<div><a href="<tmpl_var attachment.url>"><img src="<tmpl_var attachment.icon>" border="0"> <tmpl_var attachment.name></a></div>';
|
||||
$template =~ s/\<tmpl_var\s+attachment\.box\>/$box/ixsg;
|
||||
}
|
||||
}
|
||||
$template =~ s/\<tmpl_var\s+search\.form\>//ixsg;
|
||||
$template =~ s/\<tmpl_var\s+leave\.url\>//ixsg;
|
||||
$template =~ s/\<tmpl_var\s+leave\.label\>//ixsg;
|
||||
$template =~ s/canPost/user.canPost/ixsg;
|
||||
$template =~ s/canModerate/user.canModerate/ixsg;
|
||||
$template =~ s/isCurrentUser/user.isPoster/ixsg;
|
||||
$template =~ s/submission\.id/assetId/ixsg;
|
||||
$template =~ s/submission\.isNew/isNewPost/ixsg;
|
||||
$template =~ s/submission\.content\.full/content/ixsg;
|
||||
$template =~ s/submission\.content/synopsis/ixsg;
|
||||
$template =~ s/submission\.responses/replies/ixsg;
|
||||
$template =~ s/submission\.userId/ownerUserId/ixsg;
|
||||
$template =~ s/submission\.date/dateSubmitted.human/ixsg;
|
||||
$template =~ s/submission\.date.updated/dateUpdated.human/ixsg;
|
||||
$template =~ s/submission\.date/dateSubmitted.human/ixsg;
|
||||
$template =~ s/submission\.userProfile/userProfile.url/ixsg;
|
||||
$template =~ s/submission\.currentUser/isCurrentUser/ixsg;
|
||||
$template =~ s/submission\.//ixsg;
|
||||
$template =~ s/user\.Profile/userProfile.url/ixsg;
|
||||
$template =~ s/user\.id/ownerUserId/ixsg;
|
||||
$template =~ s/user\.id/ownerUserId/ixsg;
|
||||
$template =~ s/user\.alias/username/ixsg;
|
||||
$template =~ s/user\.username/username/ixsg;
|
||||
$template =~ s/date\.epoch/dateSubmitted/ixsg;
|
||||
$template =~ s/date\.human/dateSubmitted.human/ixsg;
|
||||
|
|
@ -641,6 +654,10 @@ while (my ($id, $template, $namespace) = $sth->array) {
|
|||
$template =~ s/previous\.more/previous.url/ixsg;
|
||||
$template =~ s/next\.more/next.url/ixsg;
|
||||
$template =~ s/canReply/user.canReply/ixsg;
|
||||
$template =~ s/title\.value/title/ixsg;
|
||||
$template =~ s/body\.form\.textarea/content.form/ixsg;
|
||||
$template =~ s/body\.form/content.form/ixsg;
|
||||
$template =~ s/body\.value/content/ixsg;
|
||||
$template =~ s/back\.url/collaboration.url/ixsg;
|
||||
$template =~ s/submissions_loop/post_loop/ixsg;
|
||||
$template = '<a name="<tmpl_var assetId>"></a> <tmpl_if session.var.adminOn> <p><tmpl_var controls></p> </tmpl_if>'.$template;
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ create table Post (
|
|||
userDefined3 text,
|
||||
userDefined4 text,
|
||||
userDefined5 text,
|
||||
storageId varchar(22),
|
||||
rating int not null default 0
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ sub getName {
|
|||
return "File";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getStorageLocation {
|
||||
my $self = shift;
|
||||
unless (exists $self->{_storageLocation}) {
|
||||
|
|
@ -179,6 +180,7 @@ sub getStorageLocation {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@ package WebGUI::Asset::File::Image;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset::File;
|
||||
use WebGUI::Storage::Image;
|
||||
use WebGUI::HTTP;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
||||
# do a check to see if they've installed Image::Magick
|
||||
my $hasImageMagick = 1;
|
||||
eval " use Image::Magick; "; $hasImageMagick=0 if $@;
|
||||
|
||||
our @ISA = qw(WebGUI::Asset::File);
|
||||
|
||||
|
|
@ -101,33 +99,7 @@ sub generateThumbnail {
|
|||
if (defined $thumbnailSize) {
|
||||
$self->update({thumbnailSize=>$thumbnailSize});
|
||||
}
|
||||
if (defined $self->get("filename") && $hasImageMagick) {
|
||||
my $storage = $self->getStorageLocation;
|
||||
my $image = Image::Magick->new;
|
||||
my $error = $image->Read($storage->getPath($self->get("filename")));
|
||||
if ($error) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't read image for thumbnail creation: ".$error);
|
||||
return 0;
|
||||
}
|
||||
my ($x, $y) = $image->Get('width','height');
|
||||
my $n = $self->get("thumbnailSize");
|
||||
if ($x > $n || $y > $n) {
|
||||
my $r = $x>$y ? $x / $n : $y / $n;
|
||||
$image->Scale(width=>($x/$r),height=>($y/$r));
|
||||
}
|
||||
if (isIn($storage->getFileExtension($self->get("filename")), qw(tif tiff bmp))) {
|
||||
$error = $image->Write($storage->getPath.$session{os}{slash}.'thumb-'.$self->get("filename").'.png');
|
||||
} else {
|
||||
$error = $image->Write($storage->getPath.$session{os}{slash}.'thumb-'.$self->get("filename"));
|
||||
}
|
||||
if ($error) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't create thumbnail: ".$error);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
WebGUI::ErrorHandler::warn("Can't generate a thumbnail when you haven't uploaded a file.");
|
||||
return 0; # couldn't generate thumbnail
|
||||
$self->getStorageLocation->generateThumbnail($self->get("filename"),$self->get("thumbnailSize"));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -184,12 +156,23 @@ sub getName {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getStorageLocation {
|
||||
my $self = shift;
|
||||
unless (exists $self->{_storageLocation}) {
|
||||
$self->{_storageLocation} = WebGUI::Storage::Image->get($self->get("storageId"));
|
||||
}
|
||||
return $self->{_storageLocation};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getThumbnailUrl {
|
||||
my $self = shift;
|
||||
return $self->getStorageLocation->getUrl("thumb-".$self->get("filename"));
|
||||
return $self->getStorageLocation->getThumbnailUrl;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
|
|
@ -200,6 +183,7 @@ sub processPropertiesFromFormPost {
|
|||
$self->generateThumbnail;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my %var = %{$self->get};
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ sub definition {
|
|||
tableName=>'Post',
|
||||
className=>'WebGUI::Asset::Post',
|
||||
properties=>{
|
||||
storageId => {
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>undef
|
||||
},
|
||||
threadId => {
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>undef
|
||||
|
|
@ -328,8 +332,9 @@ sub getSynopsisAndContentFromFormPost {
|
|||
#-------------------------------------------------------------------
|
||||
sub getTemplateVars {
|
||||
my $self = shift;
|
||||
my %var = %{$self->get};
|
||||
my %var = (%{$self->get});
|
||||
$var{"userId"} = $self->get("ownerUserId");
|
||||
$var{"user.isPoster"} = ($self->get("ownerUserId") eq $session{user}{userId});
|
||||
|
||||
$var{"dateSubmitted.human"} = epochToHuman($self->get("dateSubmitted"));
|
||||
$var{"dateUpdated.human"} = epochToHuman($self->get("dateUpdated"));
|
||||
|
|
@ -381,6 +386,38 @@ sub getThread {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getUploadControl {
|
||||
my $self = shift;
|
||||
my $existingFiles = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/FileUploadControl.js',{type=>"text/javascript"});
|
||||
my $uploadControl = '<div id="fileUploadControl"> </div>
|
||||
<script>
|
||||
var images = new Array();
|
||||
var fileLimit = '.$self->getThread->getParent->get("attachmentsPerPost").';
|
||||
';
|
||||
opendir(DIR,$session{config}{extrasPath}.'/fileIcons');
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
foreach my $file (@files) {
|
||||
unless ($file eq "." || $file eq "..") {
|
||||
my $ext = $file;
|
||||
$ext =~ s/(.*?)\.gif/$1/;
|
||||
$uploadControl .= 'images["'.$ext.'"] = "'.$session{config}{extrasURL}.'/fileIcons/'.$file.'";'."\n";
|
||||
}
|
||||
}
|
||||
$uploadControl .= 'var uploader = new FileUploadControl("fileUploadControl", images);
|
||||
uploader.addRow();
|
||||
</script>';
|
||||
if ($self->get("storageId")) {
|
||||
foreach my $filename (@{$self->getStorageLocation->getFiles}) {
|
||||
$uploadControl .= '<a href="'.$self->getStorageLocation->getFileUrl($filename).'">'.$filename.'</a><br />';
|
||||
}
|
||||
}
|
||||
return $uploadControl;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 hasRated ( )
|
||||
|
|
@ -806,22 +843,7 @@ sub www_edit {
|
|||
value=>$content
|
||||
});
|
||||
}
|
||||
# if ($submission->{image} ne "") {
|
||||
# $var{'image.form'} = '<a href="'.WebGUI::URL::page('func=deleteFile&file=image&wid='.$session{form}{wid}
|
||||
# .'&sid='.$submission->{USS_submissionId}).'">'.WebGUI::International::get(391).'</a>';
|
||||
# } else {
|
||||
# $var{'image.form'} = WebGUI::Form::file({
|
||||
# name=>"image"
|
||||
# });
|
||||
# }
|
||||
# if ($submission->{attachment} ne "") {
|
||||
# $var{'attachment.form'} = '<a href="'.WebGUI::URL::page('func=deleteFile&file=attachment&wid='
|
||||
# .$session{form}{wid}.'&sid='.$submission->{USS_submissionId}).'">'.WebGUI::International::get(391).'</a>';
|
||||
# } else {
|
||||
# $var{'attachment.form'} = WebGUI::Form::file({
|
||||
# name=>"attachment"
|
||||
# });
|
||||
# }
|
||||
$var{'attachment.form'} = $self->getUploadControl;
|
||||
$var{'contentType.form'} = WebGUI::Form::contentType({
|
||||
name=>'contentType',
|
||||
value=>$self->getValue("contentType") || "mixed"
|
||||
|
|
|
|||
|
|
@ -1,436 +0,0 @@
|
|||
package WebGUI::Asset::USS_submission;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::Asset::Wobject::USS;
|
||||
use WebGUI::DateTime;
|
||||
#use WebGUI::Forum;
|
||||
#use WebGUI::Forum::UI;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::HTTP;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::Id;
|
||||
use WebGUI::International;
|
||||
use WebGUI::MessageLog;
|
||||
use WebGUI::Operation;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Style;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(WebGUI::Asset);
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub canContribute {
|
||||
my $self = shift;
|
||||
return WebGUI::Grouping::isInGroup($self->getParent->get("groupToContribute"));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
return ( ($session{form}{func} eq "add" && $self->canContribute) || $self->canModerate || $self->canEdit);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub canModerate {
|
||||
my $self = shift;
|
||||
return WebGUI::Grouping::isInGroup($self->getParent->get("groupToApprove"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $definition = shift;
|
||||
push(@{$definition}, {
|
||||
tableName=>'USS_submission',
|
||||
className=>'WebGUI::Asset::Wobject::USS_submission',
|
||||
properties=>{
|
||||
dateSubmitted => {
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>time()
|
||||
},
|
||||
dateUpdated => {
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>time()
|
||||
},
|
||||
username => {
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>$session{user}{username}
|
||||
},
|
||||
status => {
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>'Approved'
|
||||
},
|
||||
views => {
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>0
|
||||
},
|
||||
contentType => {
|
||||
fieldType=>"contentType",
|
||||
defaultValue=>"mixed"
|
||||
},
|
||||
userDefined1 => {
|
||||
fieldType=>"HTMLArea",
|
||||
defaultValue=>undef
|
||||
},
|
||||
userDefined2 => {
|
||||
fieldType=>"HTMLArea",
|
||||
defaultValue=>undef
|
||||
},
|
||||
userDefined3 => {
|
||||
fieldType=>"HTMLArea",
|
||||
defaultValue=>undef
|
||||
},
|
||||
userDefined4 => {
|
||||
fieldType=>"HTMLArea",
|
||||
defaultValue=>undef
|
||||
},
|
||||
userDefined5 => {
|
||||
fieldType=>"HTMLArea",
|
||||
defaultValue=>undef
|
||||
},
|
||||
content => {
|
||||
fieldType=>"HTMLArea",
|
||||
defaultValue=>undef
|
||||
}
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($definition);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getIcon {
|
||||
my $self = shift;
|
||||
my $small = shift;
|
||||
return $session{config}{extrasURL}.'/assets/small/userSubmissionSystem.gif' if ($small);
|
||||
return $session{config}{extrasURL}.'/assets/userSubmissionSystem.gif';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getImageUrl {
|
||||
return '/image.jpg';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getName {
|
||||
return "USS Submission";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getResponseCount {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getThumbnailUrl {
|
||||
return '/thumbnail.jpg';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
my %data = (
|
||||
ownerUserId => $session{user}{userId},
|
||||
groupIdView => $self->getParent->get("groupIdView"),
|
||||
groupIdEdit => $self->getParent->get("groupIdEdit")
|
||||
);
|
||||
$data{startDate} = $self->getParent->get("startDate") unless ($session{form}{startDate});
|
||||
$data{endDate} = $self->getParent->get("endDate") unless ($session{form}{endDate});
|
||||
unless ($session{form}{synopsis}) {
|
||||
my $body = $session{form}{content};
|
||||
$body =~ s/\n/\^\-\;/ unless ($body =~ m/\^\-\;/);
|
||||
my @content = split(/\^\-\;/,$body);
|
||||
$content[0] = WebGUI::HTML::filter($content[0],"none");
|
||||
$data{synopsis} = $content[0];
|
||||
$body =~ s/\^\-\;/\n/;
|
||||
$data{content} = $body;
|
||||
}
|
||||
$data{isHidden} = 1;
|
||||
$self->update(\%data);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my %var;
|
||||
#my $callback = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),"func=viewSubmission&wid=".$self->wid."&sid=".$submission->{USS_submissionId});
|
||||
# if ($session{form}{forumOp} ne "" && $session{form}{forumOp} ne "viewForum") {
|
||||
# return WebGUI::Forum::UI::forumOp({
|
||||
# callback=>$callback,
|
||||
# title=>$submission->{title},
|
||||
# forumId=>$submission->{forumId}
|
||||
# });
|
||||
# }
|
||||
$self->update({views=>$self->get("views")+1});
|
||||
$var{content} = WebGUI::HTML::filter($self->get("content"),$self->get("filterContent"));
|
||||
$var{content} = WebGUI::HTML::format($var{content},"USS");
|
||||
$var{"user.label"} = WebGUI::International::get(21,"USS");
|
||||
$var{"user.Profile"} = $self->getUrl('op=viewProfile&uid='.$self->get("ownerUserId"));
|
||||
$var{"user.Id"} = $self->get("ownerUserId");
|
||||
$var{"user.username"} = $self->get("username");
|
||||
$var{"date.label"} = WebGUI::International::get(13,"USS");
|
||||
$var{"date.epoch"} = $self->get("dateSubmitted");
|
||||
$var{"date.human"} = epochToHuman($self->get("dateSubmitted"));
|
||||
$var{"date.updated.label"} = WebGUI::International::get(78,"USS");
|
||||
$var{"date.updated.human"} = epochToHuman($self->get("dateUpdated"));
|
||||
$var{"date.updated.epoch"} = $self->get("dateUpdated");
|
||||
$var{"status.label"} = WebGUI::International::get(14,"USS");
|
||||
$var{"status.status"} = $self->getParent->status($self->get("status"));
|
||||
$var{"views.label"} = WebGUI::International::get(514);
|
||||
$var{"views.count"} = $self->getResponseCount;
|
||||
$var{canPost} = $self->canContribute;
|
||||
$var{"post.url"} = $self->getUrl("func=edit");
|
||||
$var{"post.label"} = WebGUI::International::get(20,"USS");
|
||||
my $previous = WebGUI::Asset::USS_submission->newByPropertyHashRef(
|
||||
WebGUI::SQL->quickHashRef("
|
||||
select *
|
||||
from USS_submission
|
||||
left join asset on asset.assetId=USS_submission.assetId
|
||||
where asset.parentId=".quote($self->get("parentId"))."
|
||||
and asset.state='published'
|
||||
and ".$self->getParent->getValue("sortBy")."<".quote($self->get($self->getParent->getValue("sortBy")))."
|
||||
and (userId=".quote($self->get("ownerUserId"))." or status='Approved')
|
||||
order by ".$self->getParent->getValue("sortBy")." desc
|
||||
",WebGUI::SQL->getSlave)
|
||||
);
|
||||
$var{"previous.more"} = defined $previous;
|
||||
$var{"previous.url"} = $previous->getUrl if ($var{"previous.more"});
|
||||
$var{"previous.label"} = WebGUI::International::get(58,"USS");
|
||||
my $next = WebGUI::Asset::USS_submission->newByPropertyHashRef(
|
||||
WebGUI::SQL->quickHashRef("
|
||||
select *
|
||||
from USS_submission
|
||||
left join asset on asset.assetId=USS_submission.assetId
|
||||
where asset.parentId=".quote($self->get("parentId"))."
|
||||
and asset.state='published'
|
||||
and ".$self->getParent->getValue("sortBy").">".quote($self->get($self->getParent->getValue("sortBy")))."
|
||||
and (userId=".quote($self->get("ownerUserId"))." or status='Approved')
|
||||
order by ".$self->getParent->getValue("sortBy")." asc
|
||||
",WebGUI::SQL->getSlave)
|
||||
);
|
||||
$var{"next.more"} = defined $next;
|
||||
$var{"next.url"} = $next->getUrl if ($var{"next.more"});
|
||||
$var{"next.label"} = WebGUI::International::get(59,"USS");
|
||||
$var{canEdit} = $self->canEdit;
|
||||
$var{"delete.url"} = $self->getUrl("func=delete");
|
||||
$var{"delete.label"} = WebGUI::International::get(37,"USS");
|
||||
$var{"edit.url"} = $self->getUrl("func=edit");
|
||||
$var{"edit.label"} = WebGUI::International::get(27,"USS");
|
||||
$var{canChangeStatus} = $self->canModerate;
|
||||
$var{"approve.url"} = $self->getUrl("func=approve&mlog=".$session{form}{mlog});
|
||||
$var{"approve.label"} = WebGUI::International::get(572);
|
||||
$var{"leave.url"} = $self->getUrl('op=viewMessageLog');
|
||||
$var{"leave.label"} = WebGUI::International::get(573);
|
||||
$var{"deny.url"} = $self->getUrl("func=deny&mlog=".$session{form}{mlog});
|
||||
$var{"deny.label"} = WebGUI::International::get(574);
|
||||
$var{"canReply"} = $self->get("allowDiscussion");
|
||||
# $var{"reply.url"} = WebGUI::Forum::UI::formatNewThreadURL($callback,$submission->{forumId});
|
||||
# $var{"reply.label"} = WebGUI::International::get(47,"USS");
|
||||
$var{"search.url"} = WebGUI::Search::toggleURL("",$self->getParent->get("url"));
|
||||
$var{"search.label"} = WebGUI::International::get(364);
|
||||
$var{"back.url"} = $self->getParent->getUrl;
|
||||
$var{"back.label"} = WebGUI::International::get(28,"USS");
|
||||
$var{'userDefined1.value'} = $self->get("userDefined1");
|
||||
$var{'userDefined2.value'} = $self->get("userDefined2");
|
||||
$var{'userDefined3.value'} = $self->get("userDefined3");
|
||||
$var{'userDefined4.value'} = $self->get("userDefined4");
|
||||
$var{'userDefined5.value'} = $self->get("userDefined5");
|
||||
# if ($submission->{image} ne "") {
|
||||
# $file = WebGUI::Attachment->new($submission->{image},$self->wid,$submissionId);
|
||||
# $var{"image.url"} = $file->getURL;
|
||||
# $var{"image.thumbnail"} = $file->getThumbnail;
|
||||
# }
|
||||
# if ($submission->{attachment} ne "") {
|
||||
# $file = WebGUI::Attachment->new($submission->{attachment},$self->wid,$submissionId);
|
||||
# $var{"attachment.box"} = $file->box;
|
||||
# $var{"attachment.url"} = $file->getURL;
|
||||
# $var{"attachment.icon"} = $file->getIcon;
|
||||
# $var{"attachment.name"} = $file->getFilename;
|
||||
# }
|
||||
if ($self->get("allowDiscussion")) {
|
||||
# $var{"replies"} = WebGUI::Forum::UI::www_viewForum(
|
||||
# {callback=>$callback,title=>$submission->{title},forumId=>$submission->{forumId}},
|
||||
# $submission->{forumId});
|
||||
}
|
||||
return $self->processTemplate(\%var,$self->getParent->get("submissionTemplateId"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_approve {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless ($self->canModerate);
|
||||
$self->update({"status"=>'Approved'});
|
||||
WebGUI::MessageLog::addInternationalizedEntry($self->get("ownerUserId"),'',$self->getUrl,4,"USS");
|
||||
if ($session{form}{mlog}) {
|
||||
WebGUI::MessageLog::completeEntry($session{form}{mlog});
|
||||
return WebGUI::Operation::www_viewMessageLog();
|
||||
}
|
||||
return $self->www_view;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deny {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless ($self->canModerate);
|
||||
$self->update({status=>'Denied'});
|
||||
WebGUI::MessageLog::addInternationalizedEntry($self->get("ownerUserId"),'',$self->getUrl,5,"USS");
|
||||
if ($session{form}{mlog}) {
|
||||
WebGUI::MessageLog::completeEntry($session{form}{mlog});
|
||||
return WebGUI::Operation::www_viewMessageLog();
|
||||
}
|
||||
return $self->www_view;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless ($self->canEdit);
|
||||
my %var;
|
||||
if ($session{form}{func} eq "add") {
|
||||
$self->{_properties}{contentType} = "mixed";
|
||||
$var{'submission.isNew'} = 1;
|
||||
}
|
||||
$var{'link.header.label'} = WebGUI::International::get(90,"USS");
|
||||
$var{'question.header.label'} = WebGUI::International::get(84,"USS");
|
||||
$var{'submission.header.label'} = WebGUI::International::get(19,"USS");
|
||||
$var{'user.isVisitor'} = ($session{user}{userId} eq '1');
|
||||
$var{'visitorName.label'} = WebGUI::International::get(438);
|
||||
$var{'visitorName.form'} = WebGUI::Form::text({
|
||||
name=>"visitorName"
|
||||
});
|
||||
$var{'form.header'} = WebGUI::Form::formHeader()
|
||||
.WebGUI::Form::hidden({
|
||||
name=>"func",
|
||||
value=>"editSave"
|
||||
});
|
||||
if ($self->getId eq "new") {
|
||||
$var{'form.header'} .= WebGUI::Form::hidden({
|
||||
name=>"assetId",
|
||||
value=>"new"
|
||||
}).WebGUI::Form::hidden({
|
||||
name=>"class",
|
||||
value=>$session{form}{class}
|
||||
});
|
||||
}
|
||||
$var{'url.label'} = WebGUI::International::get(91,"USS");
|
||||
$var{'newWindow.label'} = WebGUI::International::get(92,"USS");
|
||||
for my $x (1..5) {
|
||||
$var{'userDefined'.$x.'.form'} = WebGUI::Form::text({
|
||||
name=>"userDefined".$x,
|
||||
value=>$self->get("userDefined".$x)
|
||||
});
|
||||
$var{'userDefined'.$x.'.form.yesNo'} = WebGUI::Form::yesNo({
|
||||
name=>"userDefined".$x,
|
||||
value=>$self->get("userDefined".$x)
|
||||
});
|
||||
$var{'userDefined'.$x.'.form.textarea'} = WebGUI::Form::textarea({
|
||||
name=>"userDefined".$x,
|
||||
value=>$self->get("userDefined".$x)
|
||||
});
|
||||
$var{'userDefined'.$x.'.form.textarea'} = WebGUI::Form::HTMLArea({
|
||||
name=>"userDefined".$x,
|
||||
value=>$self->get("userDefined".$x)
|
||||
});
|
||||
$var{'userDefined'.$x.'.value'} = $self->get('userDefined'.$x);
|
||||
}
|
||||
$var{'question.label'} = WebGUI::International::get(85,"USS");
|
||||
$var{'title.label'} = WebGUI::International::get(35,"USS");
|
||||
$var{'title.form'} = WebGUI::Form::text({
|
||||
name=>"title",
|
||||
value=>$self->get("title")
|
||||
});
|
||||
$var{'title.form.textarea'} = WebGUI::Form::textarea({
|
||||
name=>"title",
|
||||
value=>$self->get("title")
|
||||
});
|
||||
$var{'title.value'} = $self->get("title");
|
||||
$var{'body.label'} = WebGUI::International::get(31,"USS");
|
||||
$var{'answer.label'} = WebGUI::International::get(86,"USS");
|
||||
$var{'description.label'} = WebGUI::International::get(85);
|
||||
$var{'body.value'} = $self->get("content");
|
||||
$var{'body.form'} = WebGUI::Form::HTMLArea({
|
||||
name=>"content",
|
||||
value=>$self->get("content")
|
||||
});
|
||||
$var{'body.form.textarea'} = WebGUI::Form::textarea({
|
||||
name=>"content",
|
||||
value=>$self->get("content")
|
||||
});
|
||||
# $var{'image.label'} = WebGUI::International::get(32,"USS");
|
||||
# if ($submission->{image} ne "") {
|
||||
# $var{'image.form'} = '<a href="'.WebGUI::URL::page('func=deleteFile&file=image&wid='.$session{form}{wid}
|
||||
# .'&sid='.$submission->{USS_submissionId}).'">'.WebGUI::International::get(391).'</a>';
|
||||
# } else {
|
||||
# $var{'image.form'} = WebGUI::Form::file({
|
||||
# name=>"image"
|
||||
# });
|
||||
# }
|
||||
# $var{'attachment.label'} = WebGUI::International::get(33,"USS");
|
||||
# if ($submission->{attachment} ne "") {
|
||||
# $var{'attachment.form'} = '<a href="'.WebGUI::URL::page('func=deleteFile&file=attachment&wid='
|
||||
# .$session{form}{wid}.'&sid='.$submission->{USS_submissionId}).'">'.WebGUI::International::get(391).'</a>';
|
||||
# } else {
|
||||
# $var{'attachment.form'} = WebGUI::Form::file({
|
||||
# name=>"attachment"
|
||||
# });
|
||||
# }
|
||||
$var{'contentType.label'} = WebGUI::International::get(1007);
|
||||
$var{'contentType.form'} = WebGUI::Form::contentType({
|
||||
name=>'contentType',
|
||||
value=>$self->get("contentType") || "mixed"
|
||||
});
|
||||
$var{'startDate.label'} = WebGUI::International::get(497);
|
||||
$var{'endDate.label'} = WebGUI::International::get(498);
|
||||
$var{'startDate.form'} = WebGUI::Form::dateTime({
|
||||
name => 'startDate',
|
||||
value => $self->get("startDate")
|
||||
});
|
||||
$var{'endDate.form'} = WebGUI::Form::dateTime({
|
||||
name => 'endDate',
|
||||
value => $self->get("endDate")
|
||||
});
|
||||
$var{'form.submit'} = WebGUI::Form::submit();
|
||||
$var{'form.footer'} = WebGUI::Form::formFooter();
|
||||
return $self->getParent->processStyle($self->processTemplate(\%var,$self->getParent->get("submissionFormTemplateId")));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
return $self->getParent->processStyle(WebGUI::Privilege::noAccess()) unless $self->canView;
|
||||
return $self->getParent->processStyle($self->view);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
148
lib/WebGUI/Storage/Image.pm
Normal file
148
lib/WebGUI/Storage/Image.pm
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
package WebGUI::Storage::Image;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2005 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
||||
# do a check to see if they've installed Image::Magick
|
||||
my $hasImageMagick = 1;
|
||||
eval " use Image::Magick; "; $hasImageMagick=0 if $@;
|
||||
|
||||
our @ISA = qw(WebGUI::Storage);
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Storage::Image
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Extends WebGUI::Storageto add image manipulation operations.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Storage::Image;
|
||||
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
my $boolean = $self->generateThumbnail($filename);
|
||||
my $url = $self->getThumbnailUrl;
|
||||
my $boolean = $self->isImage;
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 generateThumbnail ( filename, [ thumbnailSize ] )
|
||||
|
||||
Generates a thumbnail for this image.
|
||||
|
||||
=head3 filename
|
||||
|
||||
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.
|
||||
|
||||
=cut
|
||||
|
||||
sub generateThumbnail {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $thumbnailSize = shift;
|
||||
if (defined $filename) {
|
||||
WebGUI::ErrorHandler::warn("Can't generate a thumbnail when you haven't specified a file.");
|
||||
return 0;
|
||||
}
|
||||
if ($hasImageMagick) {
|
||||
WebGUI::ErrorHandler::warn("Can't generate a thumbnail if you don't have Image Magick.");
|
||||
return 0;
|
||||
}
|
||||
if ($self->isImage($filename)) {
|
||||
WebGUI::ErrorHandler::warn("Can't generate a thumbnail for something that's not an image.");
|
||||
return 0;
|
||||
}
|
||||
my $image = Image::Magick->new;
|
||||
my $error = $image->Read($self->getPath($filename));
|
||||
if ($error) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't read image for thumbnail creation: ".$error);
|
||||
return 0;
|
||||
}
|
||||
my ($x, $y) = $image->Get('width','height');
|
||||
my $n = $thumbnailSize;
|
||||
if ($x > $n || $y > $n) {
|
||||
my $r = $x>$y ? $x / $n : $y / $n;
|
||||
$image->Scale(width=>($x/$r),height=>($y/$r));
|
||||
}
|
||||
$error = $image->Write($self->getPath.$session{os}{slash}.'thumb-'.$filename);
|
||||
if ($error) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't create thumbnail: ".$error);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getThumbnailUrl ( filename )
|
||||
|
||||
Returns the URL to a thumbnail for a given image.
|
||||
|
||||
=head3 filename
|
||||
|
||||
The file to retrieve the thumbnail for.
|
||||
|
||||
=cut
|
||||
|
||||
sub getThumbnailUrl {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
return $self->getUrl("thumb-".$filename);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isImage ( filename )
|
||||
|
||||
Checks to see that the file specified is an image. Returns a 1 or 0 depending upon the result.
|
||||
|
||||
=head3 filename
|
||||
|
||||
The file to check.
|
||||
|
||||
=cut
|
||||
|
||||
sub isImage {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
return isIn($self->getFileExtension($filename), qw(jpeg jpg gif png))
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue