Templatized the Site Map.
This commit is contained in:
parent
31f5de82b6
commit
937f9aa4ea
5 changed files with 59 additions and 48 deletions
|
|
@ -16,6 +16,8 @@ save you many hours of grief.
|
|||
|
||||
* All Link Lists have been reset to the default template.
|
||||
|
||||
* All Site Maps have been reset to the default template.
|
||||
|
||||
|
||||
4.8.0
|
||||
--------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -965,6 +965,17 @@ insert into international (internationalId,languageId,namespace,message,lastUpda
|
|||
alter table MessageBoard add column templateId int not null default 1;
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (72,1,'MessageBoard','Main Template', 1038678090);
|
||||
INSERT INTO template VALUES (1,'Default Message Board','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\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<table width=\"100%\" cellpadding=2 cellspacing=1 border=0>\r\n<tr>\r\n <td align=\"right\" valign=\"bottom\" class=\"tableMenu\">\r\n <tmpl_if canPost>\r\n <a href=\"<tmpl_var post.url>\"><tmpl_var post.label></a> ·\r\n </tmpl_if>\r\n <a href=\"<tmpl_var search.url>\"><tmpl_var search.label></a>\r\n </td></tr></table>\r\n\r\n <table border=0 cellpadding=2 cellspacing=1 width=\"100%\">\r\n <tr>\r\n <td class=\"tableHeader\"><tmpl_var subject.label></td>\r\n <td class=\"tableHeader\"><tmpl_var user.label></td>\r\n <td class=\"tableHeader\"><tmpl_var date.label></td>\r\n <td class=\"tableHeader\"><tmpl_var views.label></td>\r\n <td class=\"tableHeader\"><tmpl_var replies.label></td>\r\n <td class=\"tableHeader\"><tmpl_var last.label></td>\r\n </tr>\r\n\r\n<tmpl_loop messages_loop>\r\n <tr><td class=\"tableData\">\r\n <a href=\"<tmpl_var message.url>\"><tmpl_var message.subject></a>\r\n <tmpl_if message.currentUser>\r\n (<tmpl_var message.status>)\r\n </tmpl_if> \r\n </td>\r\n <td class=\"tableData\"><a href=\"<tmpl_var message.userProfile>\"><tmpl_var message.username></a></td>\r\n <td class=\"tableData\"><tmpl_var message.date></td>\r\n <td class=\"tableData\"><tmpl_var message.views></td>\r\n <td class=\"tableData\"><tmpl_var message.replies></td>\r\n <td class=\"tableData\">\r\n <span style=\"font-size: 8pt;\">\r\n <a href=\"<tmpl_var last.url\"><tmpl_var last.subject></a>\r\n @ <tmpl_var last.date> \r\n by <a href=\"<tmpl_var last.userProfile>\"><tmpl_var last.username></a>\r\n </span>\r\n </td>\r\n </tr>\r\n</tmpl_loop>\r\n</table>\r\n\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\r\n','MessageBoard');
|
||||
delete from international where namespace='SiteMap' and internationalId=7;
|
||||
delete from international where namespace='SiteMap' and internationalId=8;
|
||||
delete from international where namespace='SiteMap' and internationalId=9;
|
||||
alter table SiteMap add column templateId int not null default 1;
|
||||
update SiteMap set templateId=2 where displaySynopsis=1;
|
||||
alter table SiteMap drop column displaySynopsis;
|
||||
alter table SiteMap drop column bullet;
|
||||
alter table SiteMap drop column lineSpacing;
|
||||
INSERT INTO template VALUES (1,'Default Site Map','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\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_loop page_loop>\r\n <tmpl_var page.indent>·<a href=\"<tmpl_var page.url>\"><tmpl_var page.title></a><br/>\r\n</tmpl_loop>','SiteMap');
|
||||
INSERT INTO template VALUES (2,'Descriptive Site Map','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\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_loop page_loop>\r\n <tmpl_var page.indent><a href=\"<tmpl_var page.url>\"><tmpl_var page.title></a> \r\n <tmpl_if page.synopsis>\r\n - <tmpl_var page.synopsis>\r\n </tmpl_if>\r\n <p/>\r\n</tmpl_loop>','SiteMap');
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1527,6 +1527,7 @@ sub template {
|
|||
my ($name, $value, $label, $namespace, $afterEdit, $extras, $uiLevel) =
|
||||
rearrange([qw(name value label namespace afterEdit extras uiLevel)], @p);
|
||||
if (_uiLevelChecksOut($uiLevel)) {
|
||||
$label = $_[0]->{label} || WebGUI::International::get(356);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{templateManagersGroup})) {
|
||||
if ($afterEdit) {
|
||||
$subtext = '<a href="'.WebGUI::URL::page("op=editTemplate&tid=".$value."&namespace=".$namespace
|
||||
|
|
|
|||
|
|
@ -664,7 +664,8 @@ sub set {
|
|||
".$_[0]->{_property}{sequenceNumber}.",
|
||||
".$_[0]->{_property}{pageId}."
|
||||
)");
|
||||
WebGUI::SQL->write("insert into ".$_[0]->{_property}{namespace}." (wobjectId) values (".$_[0]->{_property}{wobjectId}.")");
|
||||
WebGUI::SQL->write("insert into ".$_[0]->{_property}{namespace}." (wobjectId)
|
||||
values (".$_[0]->{_property}{wobjectId}.")");
|
||||
}
|
||||
$_[0]->{_property}{lastEdited} = time();
|
||||
$_[0]->{_property}{editedBy} = $session{user}{userId};
|
||||
|
|
@ -684,9 +685,10 @@ sub set {
|
|||
where wobjectId=".$_[0]->{_property}{wobjectId};
|
||||
WebGUI::SQL->write($sql);
|
||||
if (@update) {
|
||||
WebGUI::SQL->write("update ".$_[0]->{_property}{namespace}." set ".join(",",@update)." where wobjectId=".$_[0]->{_property}{wobjectId});
|
||||
WebGUI::SQL->write("update ".$_[0]->{_property}{namespace}." set ".join(",",@update)."
|
||||
where wobjectId=".$_[0]->{_property}{wobjectId});
|
||||
}
|
||||
WebGUI::ErrorHandler::audit("edited Wobject ".$_[0]->{_property}{wobjectId});
|
||||
WebGUI::ErrorHandler::audit("edited Wobject ".$_[0]->{_property}{wobjectId});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,33 +27,33 @@ our $name = WebGUI::International::get(2,$namespace);
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub _traversePageTree {
|
||||
my ($lineSpacing, $sth, @data, $output, $depth, $i, $toLevel);
|
||||
if ($_[2] > 0) {
|
||||
$toLevel = $_[2];
|
||||
} else {
|
||||
$toLevel = 99;
|
||||
my ($parent, $sth, $data, $indent, @pages, $i, $currentDepth, $depth, $indentString);
|
||||
$parent = $_[0];
|
||||
$currentDepth = $_[1];
|
||||
$depth = $_[2] || 99;
|
||||
$indent = $_[3];
|
||||
for ($i=1;$i<=($indent*$currentDepth);$i++) {
|
||||
$indentString .= " ";
|
||||
}
|
||||
for ($i=1;$i<=($_[1]*$_[3]);$i++) {
|
||||
$depth .= " ";
|
||||
}
|
||||
for ($i=1;$i<=$_[5];$i++) {
|
||||
$lineSpacing .= "<br>";
|
||||
}
|
||||
if ($_[1] < $toLevel) {
|
||||
$sth = WebGUI::SQL->read("select urlizedTitle, title, pageId, synopsis from page where parentId='$_[0]' order by sequenceNumber");
|
||||
while (@data = $sth->array) {
|
||||
if (WebGUI::Privilege::canViewPage($data[2])) {
|
||||
$output .= $depth.$_[4].' <a href="'.WebGUI::URL::gateway($data[0]).'">'.$data[1].'</a>';
|
||||
if ($data[3] ne "" && $_[6]) {
|
||||
$output .= ' - '.$data[3];
|
||||
}
|
||||
$output .= $lineSpacing;
|
||||
$output .= _traversePageTree($data[2],($_[1]+1),$_[2],$_[3],$_[4],$_[5],$_[6]);
|
||||
if ($currentDepth < $depth) {
|
||||
$sth = WebGUI::SQL->read("select urlizedTitle, title, pageId, synopsis from page
|
||||
where parentId='$parent' order by sequenceNumber");
|
||||
while ($data = $sth->hashRef) {
|
||||
if (WebGUI::Privilege::canViewPage($data->{pageId})) {
|
||||
push(@pages,{
|
||||
"page.indent" => $indentString,
|
||||
"page.url" => WebGUI::URL::gateway($data->{urlizedTitle}),
|
||||
"page.id" => $data->{pageId},
|
||||
"page.title" => $data->{title},
|
||||
"page.menuTitle" => $data->{menuTitle},
|
||||
"page.synopsis" => $data->{synopsis}
|
||||
});
|
||||
push(@pages,@{_traversePageTree($data->{pageId},($currentDepth+1),$depth,$indent)});
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
return $output;
|
||||
return \@pages;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -63,35 +63,34 @@ sub duplicate {
|
|||
$w = WebGUI::Wobject::SiteMap->new({wobjectId=>$w,namespace=>$namespace});
|
||||
$w->set({
|
||||
startAtThisLevel=>$_[0]->get("startAtThisLevel"),
|
||||
templateId=>$_[0]->get("templateId"),
|
||||
indent=>$_[0]->get("indent"),
|
||||
bullet=>$_[0]->get("bullet"),
|
||||
lineSpacing=>$_[0]->get("lineSpacing"),
|
||||
displaySynopsis=>$_[0]->get("displaySynopsis"),
|
||||
depth=>$_[0]->get("depth")
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub set {
|
||||
$_[0]->SUPER::set($_[1],[qw(startAtThisLevel displaySynopsis indent bullet lineSpacing depth)]);
|
||||
$_[0]->SUPER::set($_[1],[qw(startAtThisLevel indent templateId depth)]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
my ($output, $f, $indent, $bullet, $lineSpacing);
|
||||
my ($output, $f, $indent);
|
||||
$indent = $_[0]->get("indent") || 5;
|
||||
$bullet = $_[0]->get("bullet") || '·';
|
||||
$lineSpacing = $_[0]->get("lineSpacing") || 1;
|
||||
$output = helpIcon(1,$_[0]->get("namespace"));
|
||||
$output .= '<h1>'.WebGUI::International::get(5,$namespace).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->yesNo("displaySynopsis",WebGUI::International::get(9,$namespace),$_[0]->get("displaySynopsis"));
|
||||
$f->template(
|
||||
-name=>"templateId",
|
||||
-value=>$_[0]->get("templateId"),
|
||||
-namespace=>$namespace,
|
||||
-afterEdit=>'func=edit&wid='.$_[0]->get("wobjectId")
|
||||
);
|
||||
$f->yesNo("startAtThisLevel",WebGUI::International::get(3,$namespace),$_[0]->get("startAtThisLevel"));
|
||||
$f->integer("depth",WebGUI::International::get(4,$namespace),$_[0]->get("depth"));
|
||||
$f->integer("indent",WebGUI::International::get(6,$namespace),$indent);
|
||||
$f->text("bullet",WebGUI::International::get(7,$namespace),$bullet);
|
||||
$f->integer("lineSpacing",WebGUI::International::get(8,$namespace),$lineSpacing);
|
||||
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly);
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -99,29 +98,25 @@ sub www_edit {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
my ($property);
|
||||
$property->{indent} = $session{form}{indent};
|
||||
$property->{displaySynopsis} = $session{form}{displaySynopsis};
|
||||
$property->{bullet} = $session{form}{bullet};
|
||||
$property->{startAtThisLevel} = $session{form}{startAtThisLevel};
|
||||
$property->{depth} = $session{form}{depth};
|
||||
$property->{lineSpacing} = $session{form}{lineSpacing};
|
||||
$_[0]->SUPER::www_editSave($property);
|
||||
$_[0]->SUPER::www_editSave({
|
||||
indent=>$session{form}{indent},
|
||||
startAtThisLevel=>$session{form}{startAtThisLevel},
|
||||
depth=>$session{form}{depth},
|
||||
templateId=>$session{form}{templateId}
|
||||
});
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (@question, $output, $parent);
|
||||
$output = $_[0]->displayTitle;
|
||||
$output .= $_[0]->description;
|
||||
my (%var, $parent);
|
||||
if ($_[0]->get("startAtThisLevel")) {
|
||||
$parent = $session{page}{pageId};
|
||||
} else {
|
||||
$parent = 1;
|
||||
}
|
||||
$output .= _traversePageTree($parent,0,$_[0]->get("depth"),$_[0]->get("indent"),$_[0]->get("bullet"),$_[0]->get("lineSpacing"),$_[0]->get("displaySynopsis"));
|
||||
return $_[0]->processMacros($output);
|
||||
$var{page_loop} = _traversePageTree($parent,0,$_[0]->get("depth"),$_[0]->get("indent"));
|
||||
return $_[0]->processMacros($_[0]->processTemplate($_[0]->get("templateId"),\%var));
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue