package WebGUI::Widget::SiteMap;
our $namespace = "SiteMap";
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _traversePageTree {
my ($lineSpacing, $sth, @data, $output, $depth, $i, $toLevel);
if ($_[2] > 0) {
$toLevel = $_[2];
} else {
$toLevel = 99;
}
for ($i=1;$i<=$_[1]*$_[3];$i++) {
$depth .= " ";
}
for ($i=1;$i<=$_[5];$i++) {
$lineSpacing .= "
";
}
if ($_[1] < $toLevel) {
$sth = WebGUI::SQL->read("select urlizedTitle, title, pageId from page where parentId='$_[0]' order by sequenceNumber",$session{dbh});
while (@data = $sth->array) {
if (WebGUI::Privilege::canViewPage($data[2])) {
$output .= $depth.$_[4].' '.$data[1].'';
$output .= $lineSpacing;
$output .= _traversePageTree($data[2],$_[1]+1,$_[2],$_[3],$_[4],$_[5]);
}
}
$sth->finish;
}
return $output;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from SiteMap where widgetId=$_[0]",$_[1]);
purgeWidget($_[0],$_[1]);
}
#-------------------------------------------------------------------
sub widgetName {
return WebGUI::International::get(2,$namespace);
}
#-------------------------------------------------------------------
sub www_add {
my ($output, %hash);
tie %hash, 'Tie::IxHash';
if (WebGUI::Privilege::canEditPage()) {
$output = '
';
$output .= '
';
$output .= ''; if ($data{startAtThisLevel} eq 1) { $parent = $session{page}{pageId}; } else { $parent = 1; } $output .= _traversePageTree($parent,0,$data{depth},$data{indent},$data{bullet},$data{lineSpacing}); if ($data{processMacros}) { $output = WebGUI::Macro::process($output); } } return $output; } 1;