Templatized Article.

This commit is contained in:
JT Smith 2002-11-08 03:31:18 +00:00
parent 5909c00640
commit f14a0c707b
2 changed files with 39 additions and 56 deletions

View file

@ -3,5 +3,17 @@ update incrementer set nextValue=100000 where incrementerId='messageId';
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (748,1,'WebGUI','User Count', 1036553016);
INSERT INTO template VALUES (5,'Classifieds','<tmpl_var searchForm>\r\n\r\n<tmpl_if post>\r\n <tmpl_var post> ·\r\n</tmpl_if>\r\n<tmpl_var search><p/>\r\n\r\n<table width=\"100%\" cellpadding=3 cellspacing=0 border=0>\r\n<tr>\r\n<tmpl_loop submissions_loop>\r\n\r\n<td valign=\"top\" class=\"tableData\" width=\"33%\" style=\"border: 1px dotted black; padding: 10px;\">\r\n <h2><a href=\"<tmpl_var submission.url>\"><tmpl_var submission.title></a></h2>\r\n <tmpl_if submission.currentUser>\r\n (<tmpl_var submission.status>)\r\n </tmpl_if>\r\n<br/>\r\n <tmpl_if submission.thumbnail>\r\n <a href=\"<tmpl_var submission.url>\"><img src=\"<tmpl_var submission.thumbnail>\" border=\"0\"/ align=\"right\"></a><br/>\r\n </tmpl_if>\r\n<tmpl_var submission.content>\r\n</td>\r\n\r\n<tmpl_if submission.thirdColumn>\r\n </tr><tr>\r\n</tmpl_if>\r\n\r\n</tmpl_loop>\r\n</tr>\r\n</table>\r\n\r\n<tmpl_if multiplePages>\r\n <div class=\"pagination\">\r\n <tmpl_var previousPage> · <tmpl_var pageList> · <tmpl_var nextPage>\r\n </div>\r\n</tmpl_if>\r\n','USS');
INSERT INTO template VALUES (6,'Guest Book','<tmpl_if post>\r\n <tmpl_var post><p>\r\n</tmpl_if>\r\n\r\n<tmpl_loop submissions_loop>\r\n\r\n<tmpl_if __odd__>\r\n<div class=\"highlight\">\r\n</tmpl_if>\r\n\r\n<b>On <tmpl_var submission.date> <a href=\"<tmpl_var submission.userProfile>\"><tmpl_var submission.username></a> from <a href=\"<tmpl_var submission.url>\">the <tmpl_var submission.title> department</a> wrote</b>, <i><tmpl_var submission.content></i>\r\n\r\n<tmpl_if __odd__>\r\n</div >\r\n</tmpl_if>\r\n\r\n<p/>\r\n\r\n</tmpl_loop>\r\n\r\n<tmpl_if multiplePages>\r\n <div class=\"pagination\">\r\n <tmpl_var previousPage> · <tmpl_var nextPage>\r\n </div>\r\n</tmpl_if>\r\n','USS');
delete from international where namespace='Article' and internationalId=14;
delete from international where namespace='Article' and internationalId=15;
delete from international where namespace='Article' and internationalId=16;
delete from international where namespace='Article' and internationalId=17;
alter table Article add column templateId int not null default 1;
update Article set templateId=2 where alignImage='center';
update Article set templateId=3 where alignImage='left';
alter table Article drop column alignImage;
INSERT INTO template VALUES (1,'Default Article','<tmpl_if image>\r\n <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"content\">\r\n <img src=\"<tmpl_var image>\" align=\"right\" border=\"0\">\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p/>\r\n</tmpl_if>\r\n\r\n<tmpl_if link.url>\r\n <tmpl_if link.title>\r\n <p><a href=\"<tmpl_var linkUrl>\"><tmpl_var linkTitle></a>\r\n </tmpl_if>\r\n</tmpl_if>\r\n\r\n<tmpl_var attachment.box>\r\n\r\n<tmpl_if image>\r\n </td></tr></table>\r\n</tmpl_if>\r\n\r\n<tmpl_if allowDiscussion>\r\n <p><table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" border=\"0\">\r\n <tr><td align=\"center\" width=\"50%\" class=\"tableMenu\"><a href=\"<tmpl_var replies.URL>\"><tmpl_var replies.label> (<tmpl_var replies.count>)</a></td>\r\n <td align=\"center\" width=\"50%\" class=\"tableMenu\"><a href=\"<tmpl_var post.url>\"><tmpl_var post.label></a></td></tr>\r\n </table>\r\n</tmpl_if>\r\n','Article');
INSERT INTO template VALUES (2,'Center Image','<tmpl_if image>\r\n <div align=\"center\"><img src=\"<tmpl_var image>\" border=\"0\"></div>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p/>\r\n</tmpl_if>\r\n\r\n<tmpl_if link.url>\r\n <tmpl_if link.title>\r\n <p><a href=\"<tmpl_var linkUrl>\"><tmpl_var linkTitle></a>\r\n </tmpl_if>\r\n</tmpl_if>\r\n\r\n<tmpl_var attachment.box>\r\n\r\n\r\n<tmpl_if allowDiscussion>\r\n <p><table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" border=\"0\">\r\n <tr><td align=\"center\" width=\"50%\" class=\"tableMenu\"><a href=\"<tmpl_var replies.URL>\"><tmpl_var replies.label> (<tmpl_var replies.count>)</a></td>\r\n <td align=\"center\" width=\"50%\" class=\"tableMenu\"><a href=\"<tmpl_var post.url>\"><tmpl_var post.label></a></td></tr>\r\n </table>\r\n</tmpl_if>\r\n','Article');
INSERT INTO template VALUES (3,'Left Align Image','<tmpl_if image>\r\n <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"content\">\r\n <img src=\"<tmpl_var image>\" align=\"left\" border=\"0\">\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p/>\r\n</tmpl_if>\r\n\r\n<tmpl_if link.url>\r\n <tmpl_if link.title>\r\n <p><a href=\"<tmpl_var linkUrl>\"><tmpl_var linkTitle></a>\r\n </tmpl_if>\r\n</tmpl_if>\r\n\r\n<tmpl_var attachment.box>\r\n\r\n<tmpl_if image>\r\n </td></tr></table>\r\n</tmpl_if>\r\n\r\n<tmpl_if allowDiscussion>\r\n <p><table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" border=\"0\">\r\n <tr><td align=\"center\" width=\"50%\" class=\"tableMenu\"><a href=\"<tmpl_var replies.URL>\"><tmpl_var replies.label> (<tmpl_var replies.count>)</a></td>\r\n <td align=\"center\" width=\"50%\" class=\"tableMenu\"><a href=\"<tmpl_var post.url>\"><tmpl_var post.label></a></td></tr>\r\n </table>\r\n</tmpl_if>\r\n','Article');

View file

@ -39,51 +39,46 @@ sub duplicate {
$file = WebGUI::Attachment->new($_[0]->get("attachment"),$_[0]->get("wobjectId"));
$file->copy($w->get("wobjectId"));
$w->set({
templateId=>$_[0]->get("templateId"),
image=>$_[0]->get("image"),
linkTitle=>$_[0]->get("linkTitle"),
linkURL=>$_[0]->get("linkURL"),
attachment=>$_[0]->get("attachment"),
convertCarriageReturns=>$_[0]->get("convertCarriageReturns"),
alignImage=>$_[0]->get("alignImage"),
allowDiscussion=>$_[0]->get("allowDiscussion")
});
}
#-------------------------------------------------------------------
sub set {
$_[0]->SUPER::set($_[1],[qw(image linkTitle linkURL attachment convertCarriageReturns alignImage allowDiscussion)]);
$_[0]->SUPER::set($_[1],[qw(image templateId linkTitle linkURL attachment convertCarriageReturns allowDiscussion)]);
}
#-------------------------------------------------------------------
sub www_edit {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
my ($output, $editTimeout, $groupToModerate, %hash, $f);
tie %hash, 'Tie::IxHash';
my ($output, $editTimeout, $groupToModerate, $f, $template);
if ($_[0]->get("wobjectId") eq "new") {
$editTimeout = 1;
} else {
$editTimeout = $_[0]->get("editTimeout");
}
$template = $_[0]->get("templateId") || 1;
$groupToModerate = $_[0]->get("groupToModerate") || 4;
$output = helpIcon(1,$namespace);
$output .= '<h1>'.WebGUI::International::get(12,$namespace).'</h1>';
$f = WebGUI::HTMLForm->new;
$f->template(
-name=>"templateId",
-value=>$template,
-namespace=>$namespace,
-label=>WebGUI::International::get(356),
-afterEdit=>'func=edit&wid='.$_[0]->get("wobjectId")
);
$f->raw(
-value=>$_[0]->fileProperty("image",6),
-uiLevel=>3
);
%hash = (
right => WebGUI::International::get(15,$namespace),
left => WebGUI::International::get(16,$namespace),
center => WebGUI::International::get(17,$namespace)
);
$f->select(
-name=>"alignImage",
-options=>\%hash,
-label=>WebGUI::International::get(14,$namespace),
-value=>[$_[0]->get("alignImage")],
-uiLevel=>3
);
$f->raw(
-value=>$_[0]->fileProperty("attachment",9),
-uiLevel=>1
@ -129,9 +124,9 @@ sub www_editSave {
$attachment->save("attachment");
$property{image} = $image->getFilename if ($image->getFilename ne "");
$property{attachment} = $attachment->getFilename if ($attachment->getFilename ne "");
$property{alignImage} = $session{form}{alignImage};
$property{convertCarriageReturns} = $session{form}{convertCarriageReturns};
$property{linkTitle} = $session{form}{linkTitle};
$property{templateId} = $session{form}{templateId};
$property{linkURL} = $session{form}{linkURL};
$property{allowDiscussion} = $session{form}{allowDiscussion};
$_[0]->SUPER::www_editSave(\%property);
@ -145,52 +140,28 @@ sub www_showMessage {
#-------------------------------------------------------------------
sub www_view {
my ($file, $output, $image, $replies, $body);
if ($_[0]->get("image") ne "") { # Images collide on successive articles if there is little text - prevent this.
$output = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td>';
}
$output .= $_[0]->displayTitle;
my ($file, %var);
if ($_[0]->get("image") ne "") {
$image = WebGUI::Attachment->new($_[0]->get("image"),$_[0]->get("wobjectId"));
$image = '<img src="'.$image->getURL.'"';
if ($_[0]->get("alignImage") ne "center") {
$image .= ' align="'.$_[0]->get("alignImage").'"';
}
$image .= ' border="0">';
if ($_[0]->get("alignImage") eq "center") {
$output .= '<div align="center">'.$image.'</div>';
} else {
$output .= $image;
}
$file = WebGUI::Attachment->new($_[0]->get("image"),$_[0]->get("wobjectId"));
$var{image} = $file->getURL;
$var{thumbnail} = $file->getThumbnail;
}
$body = $_[0]->description;
$var{description} = $_[0]->description;
if ($_[0]->get("convertCarriageReturns")) {
$body =~ s/\n/\<br\>/g;
$var{description} =~ s/\n/\<br\>/g;
}
$output .= $body;
if ($_[0]->get("linkURL") ne "" && $_[0]->get("linkTitle") ne "") {
$output .= '<p><a href="'.$_[0]->get("linkURL").'">'.$_[0]->get("linkTitle").'</a>';
}
if ($_[0]->get("attachment") ne "") {
$file = WebGUI::Attachment->new($_[0]->get("attachment"),$_[0]->get("wobjectId"));
$output .= $file->box;
$var{"attachment.box"} = $file->box;
$var{"attachment.icon"} = $file->getIcon;
$var{"attachment.url"} = $file->getURL;
}
if ($_[0]->get("image") ne "") {
$output .= "</td></tr></table>";
}
$output = $_[0]->processMacros($output);
if ($_[0]->get("allowDiscussion")) {
($replies) = WebGUI::SQL->quickArray("select count(*) from discussion where wobjectId=".$_[0]->get("wobjectId"));
$output .= '<p><table width="100%" cellspacing="2" cellpadding="1" border="0">';
$output .= '<tr><td align="center" width="50%" class="tableMenu"><a href="'.
WebGUI::URL::page('func=showMessage&wid='.$_[0]->get("wobjectId")).'">'.
WebGUI::International::get(28,$namespace).' ('.$replies.')</a></td>';
$output .= '<td align="center" width="50%" class="tableMenu"><a href="'.
WebGUI::URL::page('func=post&mid=new&wid='.$_[0]->get("wobjectId")).'">'.
WebGUI::International::get(24,$namespace).'</a></td></tr>';
$output .= '</table>';
}
return $output;
($var{"replies.count"}) = WebGUI::SQL->quickArray("select count(*) from discussion where wobjectId=".$_[0]->get("wobjectId"));
$var{"replies.URL"} = WebGUI::URL::page('func=showMessage&wid='.$_[0]->get("wobjectId"));
$var{"replies.label"} = WebGUI::International::get(28,$namespace);
$var{"post.URL"} = WebGUI::URL::page('func=post&mid=new&wid='.$_[0]->get("wobjectId"));
$var{"post.label"} = WebGUI::International::get(24,$namespace);
return $_[0]->processMacros($_[0]->displayTitle.$_[0]->processTemplate($_[0]->get("templateId"),\%var));
}
1;