USS display is now working...still a ways to go to make it perfect

This commit is contained in:
JT Smith 2005-02-07 17:11:48 +00:00
parent 2e893f053b
commit b322296e0c
3 changed files with 74 additions and 38 deletions

View file

@ -6,6 +6,7 @@ use File::Path;
use File::Copy;
use Getopt::Long;
use strict;
use WebGUI::HTML;
use WebGUI::Id;
use WebGUI::Session;
use WebGUI::SQL;
@ -193,9 +194,9 @@ WebGUI::SQL->write("alter table USS_submission drop column USS_id");
WebGUI::SQL->write("alter table USS_submission drop column endDate");
WebGUI::SQL->write("alter table USS_submission drop column USS_submissionId");
WebGUI::SQL->write("alter table USS_submission drop column pageId");
WebGUI::SQL->write("alter table USS_submission drop column content");
WebGUI::SQL->write("alter table USS_submission drop column image");
WebGUI::SQL->write("alter table USS_submission drop column attachment");
WebGUI::SQL->write("alter table USS_submission add primary key (assetId)");
WebGUI::SQL->write("alter table Product_accessory drop column wobjectId");
WebGUI::SQL->write("alter table Product_benefit drop column wobjectId");
WebGUI::SQL->write("alter table Product_feature drop column wobjectId");
@ -1000,6 +1001,7 @@ sub walkTree {
$sth->finish;
rmtree($session{config}{uploadsPath}.'/'.$wobject->{wobjectId});
} elsif ($wobject->{namespace} eq "Product") {
print "\t\t\tMigrating information for Product ".$wobject->{wobjectId}."\n" unless ($quiet);
my ($newProductStoreId);
# do a check to see if they've installed Image::Magick
my $hasImageMagick = 1;
@ -1039,6 +1041,7 @@ sub walkTree {
WebGUI::SQL->write("update $table set assetId=".quote($wobjectId)." where wobjectId=".quote($wobject->{wobjectId}));
}
} elsif ($wobject->{namespace} eq "USS") {
print "\t\t\tMigrating submissions for USS ".$wobject->{wobjectId}."\n" unless ($quiet);
#| dateSubmitted | int(11) | YES | | NULL | |
#| username | varchar(30) | YES | | NULL | |
#| userId | varchar(22) | YES | | NULL | |
@ -1062,29 +1065,37 @@ sub walkTree {
#| content | text | YES | | NULL | |
#| image | varchar(255) | YES | | NULL | |
#| attachment | varchar(255) | YES | | NULL | |
my $sth = WebGUI::SQL->read("select * from USS_submission where USS_id=".quote($wobject->{USS_id}));
my ($ussId) = WebGUI::SQL->quickArray("select USS_id from USS where wobjectId=".quote($wobject->{wobjectId}));
my $sth = WebGUI::SQL->read("select * from USS_submission where USS_id=".quote($ussId));
my $usssubrank = 1;
while (my $submission = $sth->hashRef) {
print "\t\t\t\tMigrating submission ".$submission->{USS_submissionId}."\n" unless ($quiet);
my $body = $submission->{content};
$body =~ s/\n/\^\-\;/ unless ($body =~ m/\^\-\;/);
my @content = split(/\^\-\;/,$body);
$content[0] = WebGUI::HTML::filter($content[0],"none");
$body =~ s/\^\-\;/\n/;
my $id = WebGUI::SQL->setRow("asset","assetId",{
assetId => "new",
title => $submission->{title},
menuTitle => $submission->{title},
startDate => $submission->{startDate},
endDate => $submission->{endDate},
url => fixUrl($wobjectId,$submission->{title}),
className=>'WebGUI::Asset::Wobject::USS_submission',
url => fixUrl('notknownyet',$submission->{title}),
className=>'WebGUI::Asset::USS_submission',
state=>'published',
ownerUserId=>$submission->{userId},
groupIdView=>,
groupIdEdit=>,
synopsis=>,
fileSize=>length($submission->{content}),
groupIdView=>$page->{groupIdView},
groupIdEdit=>$page->{groupIdEdit},
synopsis=>$content[0],
assetSize=>length($submission->{content}),
parentId=>$wobjectId,
lineage=>$wobjectLineage.sprintf("%06d",1),
lineage=>$wobjectLineage.sprintf("%06d",$usssubrank),
isHidden => 1
});
WebGUI::SQL->setRow("wobject","assetId",{
description => $submission->{content}
}, undef, $id);
WebGUI::SQL->write("update USS_submission set assetId=".quote($id)." where USS_id=".quote($wobject->{USS_id}));
WebGUI::SQL->write("update USS_submission set content=".quote($body).",
assetId=".quote($id)." where USS_submissionId=".quote($submission->{USS_submissionId}));
$usssubrank++;
}
# migrate master forum
# migrate submissions

View file

@ -12,9 +12,12 @@ package WebGUI::Asset::USS_submission;
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::Forum;
#use WebGUI::Forum::UI;
use WebGUI::Grouping;
use WebGUI::HTML;
use WebGUI::HTMLForm;
@ -29,12 +32,9 @@ use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Style;
use WebGUI::Template;
use WebGUI::URL;
use WebGUI::User;
use WebGUI::Utility;
use WebGUI::Asset;
use WebGUI::Asset::Wobject::USS;
our @ISA = qw(WebGUI::Asset);
@ -112,7 +112,8 @@ sub definition {
userDefined5 => {
fieldType=>"text",
defaultValue=>undef
},
}
}
});
return $class->SUPER::definition($definition);
}
@ -126,11 +127,31 @@ sub getIcon {
return $session{config}{extrasURL}.'/assets/userSubmissionSystem.gif';
}
#-------------------------------------------------------------------
sub getImageUrl {
return '/image.jpg';
}
#-------------------------------------------------------------------
sub getName {
return "USS Submission";
}
#-------------------------------------------------------------------
sub getResponseCount {
return 0;
}
#-------------------------------------------------------------------
sub getStatus {
return 'Approved';
}
#-------------------------------------------------------------------
sub getThumbnailUrl {
return '/thumbnail.jpg';
}
#-------------------------------------------------------------------
sub processPropertiesFromFormPost {
my $self = shift;
@ -143,13 +164,13 @@ sub processPropertiesFromFormPost {
$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}{description};
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{description} = $body;
$data{content} = $body;
}
$self->update(\%data);
}
@ -270,7 +291,7 @@ sub view {
{callback=>$callback,title=>$submission->{title},forumId=>$submission->{forumId}},
$submission->{forumId});
}
return $self->processTemplate(\%var,"USS/Submission",$self->get("submissionTemplateId"));
return $self->processTemplate(\%var,$self->get("submissionTemplateId"));
}
#-------------------------------------------------------------------
@ -306,8 +327,8 @@ sub www_edit {
my $self = shift;
return WebGUI::Privilege::insufficient() unless ($self->canEdit);
my %var;
if ($submission->{USS_submissionId} eq "new") {
$submission->{contentType} = "mixed";
if ($session{form}{func} eq "add") {
$self->{_properties}{contentType} = "mixed";
$var{'submission.isNew'} = 1;
}
$var{'link.header.label'} = WebGUI::International::get(90,"USS");
@ -367,14 +388,14 @@ sub www_edit {
$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("description");
$var{'body.value'} = $self->get("content");
$var{'body.form'} = WebGUI::Form::HTMLArea({
name=>"body",
value=>$self->get("description")
value=>$self->get("content")
});
$var{'body.form.textarea'} = WebGUI::Form::textarea({
name=>"body",
value=>$self->get("description")
value=>$self->get("content")
});
# $var{'image.label'} = WebGUI::International::get(32,"USS");
# if ($submission->{image} ne "") {
@ -411,11 +432,11 @@ sub www_edit {
});
$var{'form.submit'} = WebGUI::Form::submit();
$var{'form.footer'} = WebGUI::Form::formFooter();
return $self->getParent->processStyle($self->processTemplate(\%var,"USS/SubmissionForm",$self->getParent->get("submissionFormTemplate")));
return $self->getParent->processStyle($self->processTemplate(\%var,$self->getParent->get("submissionFormTemplate")));
}
#-------------------------------------------------------------------
sub www_editSave {
sub www_editSave2 {
my ($submission, %hash, $file, $u);
$submission = $_[0]->getCollateral("USS_submission","USS_submissionId",$session{form}{sid});
if ($submission->{userId} eq $session{user}{userId}

View file

@ -27,6 +27,7 @@ use WebGUI::Style;
use WebGUI::URL;
use WebGUI::Utility;
use WebGUI::Asset::Wobject;
use WebGUI::Asset::USS_submission;
our @ISA = qw(WebGUI::Asset::Wobject);
@ -50,6 +51,7 @@ sub _xml_encode {
return $_[0];
}
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $definition = shift;
@ -315,7 +317,7 @@ sub view {
my $constraints;
if ($session{scratch}{search}) {
$numResults = $session{scratch}{numResults};
$constraints = WebGUI::Search::buildConstraints([qw(USS_submission.username asset.title wobject.description USS_submission.userDefined1 USS_submission.userDefined2 USS_submission.userDefined3 USS_submission.userDefined4 USS_submission.userDefined5)]);
$constraints = WebGUI::Search::buildConstraints([qw(USS_submission.username asset.synopsis asset.title USS_submission.content USS_submission.userDefined1 USS_submission.userDefined2 USS_submission.userDefined3 USS_submission.userDefined4 USS_submission.userDefined5)]);
}
if ($constraints ne "") {
$constraints = "USS_submission.status='Approved' and ".$constraints;
@ -326,16 +328,18 @@ sub view {
}
$constraints .= ")";
}
my $p = WebGUI::Paginator->new(WebGUI::URL::page('func=view'),$numResults);
$p->setDataByQuery("select * from USS_submission left join asset on USS_submission.assetId=asset.assetId
where asset.parentId=".quote($self->getId)." and asset.className='WebGUI:Asset::Wobject::USS_submission' and $constraints
order by ".$self->getValue("sortBy")." ".$self->getValue("sortOrder"));
my $p = WebGUI::Paginator->new($self->getUrl,$numResults);
my $sql = "select * from USS_submission left join asset on USS_submission.assetId=asset.assetId
where asset.parentId=".quote($self->getId)." and asset.className='WebGUI::Asset::USS_submission' and $constraints
order by ".$self->getValue("sortBy")." ".$self->getValue("sortOrder");
WebGUI::ErrorHandler::warn($sql);
$p->setDataByQuery($sql);
my $page = $p->getPageData;
my $i = 0;
my $imageURL = "";
foreach my $row (@$page) {
my $submission = WebGUI::Asset::Wobject::USS_submission->newByPropertyHashRef($row);
my $body = WebGUI::HTML::filter($submission->get("description"),$self->get("filterContent"));
my $submission = WebGUI::Asset::USS_submission->newByPropertyHashRef($row);
my $body = WebGUI::HTML::filter($submission->get("content"),$self->get("filterContent"));
$body = WebGUI::HTML::format($body,$submission->get("contentType"));
my $controls = deleteIcon('func=delete',$submission->getUrl,WebGUI::International::get(17,"USS")).editIcon('func=edit',$submission->getUrl);
if ($self->get("sortBy") eq "lineage") {
@ -354,8 +358,8 @@ sub view {
push(@{$var{submissions_loop}}, {
"submission.id"=>$submission->getId,
"submission.url"=>$submission->getUrl,
"submission.content"=>$submission->{synopsis},
"submission.content.full"=>$submission->{description},
"submission.content"=>$submission->get("synopsis"),
"submission.content.full"=>$submission->get("content"),
"submission.responses"=>$submission->getResponseCount,
"submission.title"=>$submission->get("title"),
"submission.userDefined1"=>$submission->get("userDefined1"),