Templatized the Site Map.
This commit is contained in:
parent
31f5de82b6
commit
937f9aa4ea
5 changed files with 59 additions and 48 deletions
|
|
@ -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