From e00c3dfbe933ec7bc4aacd0d509bf2d98f183386 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 1 Dec 2002 20:30:06 +0000 Subject: [PATCH] A little code cleanup. --- lib/WebGUI/Wobject/ExtraColumn.pm | 22 ++++--- lib/WebGUI/Wobject/USS.pm | 96 +++++++++++++++--------------- lib/WebGUI/Wobject/WobjectProxy.pm | 16 ++++- 3 files changed, 73 insertions(+), 61 deletions(-) diff --git a/lib/WebGUI/Wobject/ExtraColumn.pm b/lib/WebGUI/Wobject/ExtraColumn.pm index c8dced208..e904c92d5 100644 --- a/lib/WebGUI/Wobject/ExtraColumn.pm +++ b/lib/WebGUI/Wobject/ExtraColumn.pm @@ -19,6 +19,7 @@ use WebGUI::International; use WebGUI::Privilege; use WebGUI::Session; use WebGUI::SQL; +use WebGUI::Template; use WebGUI::Wobject; our @ISA = qw(WebGUI::Wobject); @@ -51,16 +52,12 @@ sub uiLevel { #------------------------------------------------------------------- sub www_edit { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage()); - my ($output, $f, $endDate, $width, $class, $spacer,$startDate); + my ($output, $f, $endDate, $width, $class, $spacer,$startDate, $templatePosition); $output = helpIcon(1,$namespace); $output .= '

'.WebGUI::International::get(6,$namespace).'

'; - if ($_[0]->get("wobjectId") eq "new") { - $width = 200; - $spacer = 10; - } else { - $width = $_[0]->get("width"); - $spacer = $_[0]->get("spacer"); - } + $width = $_[0]->get("width") || 200; + $spacer = $_[0]->get("spacer") || 10; + $templatePosition = $_[0]->get("templatePosition") || 1; $class = $_[0]->get("class") || "content"; $startDate = $_[0]->get("startDate") || $session{page}{startDate}; $endDate = $_[0]->get("endDate") || $session{page}{endDate}; @@ -72,7 +69,14 @@ sub www_edit { $f->hidden("title",$namespace); $f->hidden("displayTitle",0); $f->hidden("processMacros",0); - $f->hidden("templatePosition",0); + $f->select( + -name=>"templatePosition", + -label=>WebGUI::International::get(363), + -value=>[$templatePosition], + -uiLevel=>5, + -options=>WebGUI::Template::getPositions($session{page}{templateId}), + -subtext=>WebGUI::Template::draw($session{page}{templateId}) + ); $f->date("startDate",WebGUI::International::get(497),$startDate); $f->date("endDate",WebGUI::International::get(498),$endDate); $f->integer("spacer",WebGUI::International::get(3,$namespace),$spacer); diff --git a/lib/WebGUI/Wobject/USS.pm b/lib/WebGUI/Wobject/USS.pm index b0a224304..ee307f81e 100644 --- a/lib/WebGUI/Wobject/USS.pm +++ b/lib/WebGUI/Wobject/USS.pm @@ -386,67 +386,65 @@ sub www_viewSubmission { $var{content} = WebGUI::HTML::filter($submission->{content},$session{setting}{filterContributedHTML}); $var{content} =~ s/\^\-\;//g; $var{content} =~ s/\n/\/g if ($submission->{convertCarriageReturns}); - $var{"label.by"} = WebGUI::International::get(21,$namespace); - $var{userProfile} = WebGUI::URL::page('op=viewProfile&uid='.$submission->{userId}); - $var{userId} = $submission->{userId}; - $var{username} = $submission->{username}; - $var{"label.date"} = WebGUI::International::get(13,$namespace); - $var{date} = epochToHuman($submission->{dateSubmitted}); - $var{"label.status"} = WebGUI::International::get(14,$namespace); - $var{status} = $submissionStatus{$submission->{status}}; - $var{"label.views"} = WebGUI::International::get(514); - $var{views} = $submission->{views}; + $var{"user.label"} = WebGUI::International::get(21,$namespace); + $var{"user.Profile"} = WebGUI::URL::page('op=viewProfile&uid='.$submission->{userId}); + $var{"user.Id"} = $submission->{userId}; + $var{"user.username"} = $submission->{username}; + $var{"date.label"} = WebGUI::International::get(13,$namespace); + $var{"date.epoch"} = $submission->{dateSubmitted}; + $var{"date.human"} = epochToHuman($submission->{dateSubmitted}); + $var{"status.label"} = WebGUI::International::get(14,$namespace); + $var{"status.status"} = $submissionStatus{$submission->{status}}; + $var{"views.label"} = WebGUI::International::get(514); + $var{"views.count"} = $submission->{views}; + $var{canPost} = WebGUI::Privilege::isInGroup($_[0]->get("groupToContribute")); + $var{"post.url"} = WebGUI::URL::page('func=editSubmission&sid=new&wid='.$_[0]->get("wobjectId")); + $var{"post.label"} = WebGUI::International::get(20,$namespace); @data = WebGUI::SQL->quickArray("select max(USS_submissionId) from USS_submission where wobjectId=$submission->{wobjectId} and USS_submissionId<$submission->{USS_submissionId} and (userId=$submission->{userId} or status='Approved')"); - if ($data[0] ne "") { - $var{previousSubmission} = '« '.WebGUI::International::get(58,$namespace).''; - } + $var{"previous.more"} = ($data[0] ne ""); + $var{"previous.url"} = WebGUI::URL::page('func=viewSubmission&sid='.$data[0].'&wid='.$session{form}{wid}); + $var{"previous.label"} = WebGUI::International::get(58,$namespace); @data = WebGUI::SQL->quickArray("select min(USS_submissionId) from USS_submission where wobjectId=$submission->{wobjectId} and USS_submissionId>$submission->{USS_submissionId} and (userId=$submission->{userId} or status='Approved')"); - if ($data[0] ne "") { - $var{nextSubmission} = ''.WebGUI::International::get(59,$namespace).' »'; - } - if ($submission->{userId} == $session{user}{userId} || WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) { - $var{deleteSubmission} = ''.WebGUI::International::get(37,$namespace).''; - $var{editSubmission} = ''.WebGUI::International::get(27,$namespace).''; - } - if ($submission->{status} ne "Approved" && WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"),$session{user}{userId})) { - $var{approveSubmission} = ''. - WebGUI::International::get(572).''; - $var{leaveSubmission} = ''. - WebGUI::International::get(573).''; - $var{denySubmission} = ''. - WebGUI::International::get(574).''; - } - if ($_[0]->get("allowDiscussion")) { - $var{postReply} = ''.WebGUI::International::get(47,$namespace).''; - } - $var{search} = '' - .WebGUI::International::get(364).''; - $var{backToList} = ''.WebGUI::International::get(28,$namespace).''; + $var{"next.more"} = ($data[0] ne ""); + $var{"next.url"} = WebGUI::URL::page('func=viewSubmission&sid='.$data[0].'&wid='.$session{form}{wid}); + $var{"next.label"} = WebGUI::International::get(59,$namespace); + $var{canEdit} = ($submission->{userId} == $session{user}{userId} || WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))); + $var{"delete.url"} = WebGUI::URL::page('func=deleteSubmission&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}); + $var{"delete.label"} = WebGUI::International::get(37,$namespace); + $var{"edit.url"} = WebGUI::URL::page('func=editSubmission&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}); + $var{"edit.label"} = WebGUI::International::get(27,$namespace); + $var{canChangeStatus} = ($submission->{status} ne "Approved" && WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"),$session{user}{userId})); + $var{"approve.url"} = WebGUI::URL::page('func=approveSubmission&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}.'&mlog='.$session{form}{mlog}); + $var{"approve.label"} = WebGUI::International::get(572); + $var{"leave.url"} = WebGUI::URL::page('op=viewMessageLog'); + $var{"leave.label"} = WebGUI::International::get(573); + $var{"deny.url"} = WebGUI::URL::page('func=denySubmission&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}.'&mlog='.$session{form}{mlog}); + $var{"deny.label"} = WebGUI::International::get(574); + $var{"canDiscuss"} = ($_[0]->get("allowDiscussion")); + $var{"reply.url"} = WebGUI::URL::page('func=post&mid=new&wid='.$_[0]->get("wobjectId").'&sid='.$session{form}{sid}); + $var{"reply.label"} = WebGUI::International::get(47,$namespace); + $var{"search.url"} = WebGUI::Search::toggleURL(); + $var{"search.label"} = WebGUI::International::get(364); + $var{"back.url"} = WebGUI::URL::page(); + $var{"back.label"} = WebGUI::International::get(28,$namespace); if ($submission->{image} ne "") { $file = WebGUI::Attachment->new($submission->{image},$session{form}{wid},$session{form}{sid}); - $var{image} = $file->getURL; - $var{thumbnail} = $file->getThumbnail; + $var{"image.url"} = $file->getURL; + $var{"image.thumbnail"} = $file->getThumbnail; } if ($submission->{attachment} ne "") { $file = WebGUI::Attachment->new($submission->{attachment},$session{form}{wid},$session{form}{sid}); - $var{attachment} = $file->box; + $var{"attachment.box"} = $file->box; + $var{"attachment.url"} = $file->getURL; + $var{"attachment.icon"} = $file->getIcon; + $var{"attachment.name"} = $file->getFilename; } - $output = WebGUI::Template::process(WebGUI::Template::get($_[0]->get("submissionTemplateId"),"USS/Submission"), \%var); - if ($_[0]->get("allowDiscussion")) { - $output .= WebGUI::Discussion::showThreads(); - } - return $output; + $var{"replies"} = WebGUI::Discussion::showThreads(); + return WebGUI::Template::process(WebGUI::Template::get($_[0]->get("submissionTemplateId"),"USS/Submission"), \%var); } diff --git a/lib/WebGUI/Wobject/WobjectProxy.pm b/lib/WebGUI/Wobject/WobjectProxy.pm index eb77330c2..91a7d84ca 100644 --- a/lib/WebGUI/Wobject/WobjectProxy.pm +++ b/lib/WebGUI/Wobject/WobjectProxy.pm @@ -19,6 +19,7 @@ use WebGUI::International; use WebGUI::Privilege; use WebGUI::Session; use WebGUI::SQL; +use WebGUI::Template; use WebGUI::Wobject; our @ISA = qw(WebGUI::Wobject); @@ -55,7 +56,7 @@ sub www_edit { tie %wobjects, 'Tie::IxHash'; $output = helpIcon(1,$namespace); $output .= '

'.WebGUI::International::get(2,$namespace).'

'; - $templatePosition = $_[0]->get("templatePosition") || '0'; + $templatePosition = $_[0]->get("templatePosition") || 1; $startDate = $_[0]->get("startDate") || $session{page}{startDate}; $endDate = $_[0]->get("endDate") || $session{page}{endDate}; $f = WebGUI::HTMLForm->new; @@ -66,12 +67,21 @@ sub www_edit { $f->hidden("title",$namespace); $f->hidden("displayTitle",0); $f->hidden("processMacros",0); - $f->select("templatePosition",WebGUI::Template::getPositions($session{page}{templateId}),WebGUI::International::get(363),[$templatePosition]); + $f->select( + -name=>"templatePosition", + -label=>WebGUI::International::get(363), + -value=>[$templatePosition], + -uiLevel=>5, + -options=>WebGUI::Template::getPositions($session{page}{templateId}), + -subtext=>WebGUI::Template::draw($session{page}{templateId}) + ); $f->date("startDate",WebGUI::International::get(497),$startDate); $f->date("endDate",WebGUI::International::get(498),$endDate); $a = WebGUI::SQL->read("select pageId,menuTitle from page where pageId<2 or pageId>25 order by title"); while (%page = $a->hash) { - $b = WebGUI::SQL->read("select wobjectId,title from wobject where pageId=".$page{pageId}." and namespace<>'WobjectProxy' and namespace<>'ExtraColumn' and endDate=>".time()." and pageId<>3 order by sequenceNumber"); + $b = WebGUI::SQL->read("select wobjectId,title from wobject + where pageId=".$page{pageId}." and namespace<>'WobjectProxy' and + namespace<>'ExtraColumn' and endDate>=".time()." and pageId<>3 order by sequenceNumber"); while (%wobject = $b->hash) { $wobjects{$wobject{wobjectId}} = $page{menuTitle}." / ".$wobject{title}." (".$wobject{wobjectId}.")"; }