removed all the old nav macros

This commit is contained in:
JT Smith 2004-02-28 19:27:59 +00:00
parent 2b82d714ea
commit 314d8daacb
22 changed files with 63 additions and 913 deletions

View file

@ -1,51 +0,0 @@
package WebGUI::Macro::C_crumbTrail;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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::Macro;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
#-------------------------------------------------------------------
sub _recurseCrumbTrail {
my ($sth, %data, $output);
tie %data, 'Tie::CPHash';
%data = WebGUI::SQL->quickHash("select pageId,parentId,menuTitle,urlizedTitle from page where pageId=$_[0]");
if ($data{pageId} > 1) {
$output .= _recurseCrumbTrail($data{parentId},$_[1]);
}
if ($data{menuTitle} ne "") {
$output .= '<a class="crumbTrail" href="'.WebGUI::URL::gateway($data{urlizedTitle})
.'">'.$data{menuTitle}.'</a>'.$_[1];
}
return $output;
}
#-------------------------------------------------------------------
sub process {
my (@param, $temp, $delimeter);
@param = WebGUI::Macro::getParams($_[0]);
if ($param[0] eq "") {
$delimeter = " &gt; ";
} else {
$delimeter = " ".$param[0]." ";
}
$temp = '<span class="crumbTrail">'._recurseCrumbTrail($session{page}{parentId},$delimeter).
'<a class="crumbTrail" href="'.WebGUI::URL::page().'">'.$session{page}{menuTitle}.'</a></span>';
return $temp;
}
1;

View file

@ -1,59 +0,0 @@
package WebGUI::Macro::FlexMenu;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::URL;
#-------------------------------------------------------------------
sub process {
my ($temp, @param);
@param = WebGUI::Macro::getParams($_[0]);
$temp = '<span class="verticalMenu">';
$temp .= _reversePageTree($session{page}{pageId});
$temp .= '</span>';
return $temp;
}
#-------------------------------------------------------------------
sub _reversePageTree {
my ($sth, @data, $output, $parentId);
($parentId) = WebGUI::SQL->quickArray("select parentId from page where pageId='$_[0]'");
$sth = WebGUI::SQL->read("select pageId,parentId,menuTitle,urlizedTitle,hideFromNavigation,newWindow from page where parentId=$_[0] order by sequenceNumber");
while (@data = $sth->array) {
if (!($data[4]) && WebGUI::Privilege::canViewPage($data[0])) {
$output .= '<a class="verticalMenu" ';
$output .= ' target="_blank"' if ($data[5]);
$output .= 'href="'.WebGUI::URL::gateway($data[3]).'">';
if ($session{page}{pageId} == $data[0]) {
$output .= '<span class="selectedMenuItem">'.$data[2].'</span>';
} else {
$output .= $data[2];
}
$output .= '</a><br>';
if ($_[1] == $data[0] && $_[2] ne "") {
$output .= '<table cellpadding=0 cellspacing=0 border=0 class="verticalMenu"><tr><td class="verticalMenu">&nbsp;&nbsp;&nbsp;</td><td class="verticalMenu">'.$_[2].'</td></tr></table>';
}
}
}
$sth->finish;
if ($parentId > 0) {
$output = _reversePageTree($parentId,$_[0],$output);
}
return $output;
}
1;

View file

@ -1,35 +0,0 @@
package WebGUI::Macro::M_currentMenuVertical;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my ($tree, $temp, @param);
@param = WebGUI::Macro::getParams($_[0]);
$temp = '<div class="verticalMenu">';
if ($param[0] ne "") {
$tree = WebGUI::Navigation::tree($session{page}{pageId},$param[0]);
} else {
$tree = WebGUI::Navigation::tree($session{page}{pageId},1);
}
$temp .= WebGUI::Navigation::drawVertical($tree);
$temp .= '</div>';
return $temp;
}
1;

View file

@ -1,35 +0,0 @@
package WebGUI::Macro::P_previousMenuVertical;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my ($temp, @param, $tree);
@param = WebGUI::Macro::getParams($_[0]);
$temp = '<span class="verticalMenu">';
if ($param[0] ne "") {
$tree = WebGUI::Navigation::tree($session{page}{parentId},$param[0]);
} else {
$tree = WebGUI::Navigation::tree($session{page}{parentId},1);
}
$temp .= WebGUI::Navigation::drawVertical($tree);
$temp .= '</span>';
return $temp;
}
1;

View file

@ -1,64 +0,0 @@
package WebGUI::Macro::PreviousDropMenu;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub _draw {
my ($output, $i, $padding, $pageId);
my ($tree, $indent, $maxDepth, $currentDepth) = @_;
unless ($currentDepth >= $maxDepth) {
for ($i=1;$i<=$indent;$i++) {
$padding .= "&nbsp;&nbsp;";
}
foreach $pageId (keys %{$tree}) {
$output .= '<option value="'.$tree->{$pageId}{url}.'">';
$output .= $padding."- ".$tree->{$pageId}{title};
$output .= '</option>';
$output .= _draw($tree->{$pageId}{sub}, ($indent+1), $maxDepth, ($currentDepth+1));
}
}
return $output;
}
#-------------------------------------------------------------------
sub process {
my ($temp, @param, $tree);
@param = WebGUI::Macro::getParams($_[0]);
$param[1] = 99 unless ($param[1]);
if ($param[0] ne "") {
$tree = WebGUI::Navigation::tree($session{page}{parentId},$param[0]);
} else {
$tree = WebGUI::Navigation::tree($session{page}{parentId},1);
}
$temp = '<script language="JavaScript" type="text/javascript">
function go(formObj){
if (formObj.chooser.options[formObj.chooser.selectedIndex].value != "none") {
location = formObj.chooser.options[formObj.chooser.selectedIndex].value
}
}
</script>';
$temp .= '<form><select name="chooser" size=1 onChange="go(this.form)">';
$temp .= '<option value=none>Where do you want to go?';
$temp .= _draw($tree,0,$param[1]);
$temp .= '</select></form>';
return $temp;
}
1;

View file

@ -1,61 +0,0 @@
package WebGUI::Macro::RootTab;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2002 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub _draw {
my ($tree, $root) = @_;
#my $output;# = '<table class="rootTab"><tr>';
my $output;# = '<div class="rootTabs">';
foreach my $key (keys %{$tree}) {
$output .= ' <span class="';
if ($root == $key) {
$output .= "rootTabOn";
} else {
$output .= "rootTabOff";
}
$output .= '">';
$output .= '<a href="'.$tree->{$key}{url}.'">'.$tree->{$key}{title}.'</a>';
$output .= '</span> ';
}
#$output .= '</div>';
#$output .= '</tr></table>';
return $output;
}
#-------------------------------------------------------------------
sub _findRoot {
my ($pageId,$parentId) = WebGUI::SQL->quickArray("select pageId,parentId from page where pageId=$_[0]");
if ($parentId == $_[1]) {
return $pageId;
} else {
return _findRoot($parentId);
}
}
#-------------------------------------------------------------------
sub process {
my @param = WebGUI::Macro::getParams($_[0]);
my $root = _findRoot($session{page}{pageId},$param[0]);
my $tree = WebGUI::Navigation::tree($param[0],1);
return _draw($tree,$root);
}
1;

View file

@ -1,39 +0,0 @@
package WebGUI::Macro::S_specificMenuVertical;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub process {
my ($temp, @param, $pageId, $tree);
@param = WebGUI::Macro::getParams($_[0]);
($pageId) = WebGUI::SQL->quickArray("select pageId from page where urlizedTitle='$param[0]'");
if (defined $pageId) {
$temp = '<span class="verticalMenu">';
if ($param[1] ne "") {
$tree = WebGUI::Navigation::tree($pageId,$param[1]);
} else {
$tree = WebGUI::Navigation::tree($pageId,1);
}
$temp .= WebGUI::Navigation::drawVertical($tree);
$temp .= '</span>';
}
return $temp;
}
1;

View file

@ -1,69 +0,0 @@
package WebGUI::Macro::SpecificDropMenu;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub _draw {
my ($output, $i, $padding, $pageId);
my ($tree, $indent, $maxDepth, $currentDepth) = @_;
unless ($currentDepth >= $maxDepth) {
for ($i=1;$i<=$indent;$i++) {
$padding .= "&nbsp;&nbsp;";
}
foreach $pageId (keys %{$tree}) {
$output .= '<option value="'.$tree->{$pageId}{url}.'">';
$output .= $padding."- ".$tree->{$pageId}{title};
$output .= '</option>';
$output .= _draw($tree->{$pageId}{sub}, ($indent+1), $maxDepth, ($currentDepth+1));
}
}
return $output;
}
#-------------------------------------------------------------------
sub process {
my ($temp, @param, $pageId, $tree);
@param = WebGUI::Macro::getParams($_[0]);
($pageId) = WebGUI::SQL->quickArray("select pageId from page where urlizedTitle='$param[0]'");
if (defined $pageId) {
$param[2] = 99 unless ($param[2]);
if ($param[1] ne "") {
$tree = WebGUI::Navigation::tree($pageId,$param[1]);
} else {
$tree = WebGUI::Navigation::tree($pageId,1);
}
$temp = '<script language="JavaScript" type="text/javascript">
function go(formObj){
if (formObj.chooser.options[formObj.chooser.selectedIndex].value != "none") {
location = formObj.chooser.options[formObj.chooser.selectedIndex].value
}
}
</script>';
$temp .= '<form><select name="chooser" size=1 onChange="go(this.form)">';
$temp .= '<option value=none>Where do you want to go?';
$temp .= _draw($tree,0,$param[2]);
$temp .= '</select></form>';
} else {
$temp = "No page specified.";
}
return $temp;
}
1;

View file

@ -1,64 +0,0 @@
package WebGUI::Macro::Synopsis;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
#-------------------------------------------------------------------
sub traversePageTreeSynopsis {
my ($sth, $output, $parent_id, $current_level, $max_level);
($parent_id, $current_level, $max_level) = @_;
$max_level = 99 unless ($max_level);
if ($max_level && ($current_level >= $max_level)) {
return;
}
$sth = WebGUI::SQL->read("select urlizedTitle, menuTitle, pageId, synopsis from page where parentId='$parent_id' order by sequenceNumber");
while (my ($urltitle, $menutitle, $pageid, $synopsis) = $sth->array) {
if (!WebGUI::Privilege::canViewPage($pageid)) {
next;
}
$urltitle = WebGUI::URL::gateway($urltitle);
my $subsynopsis = traversePageTreeSynopsis($pageid,$current_level+1,$max_level);
$output .= qq{
<div class="synopsis">
<div class="synopsis_title">
<a href="$urltitle">$menutitle</a>
</div>
<div class="synopsis_summary">
$synopsis
</div>
<div class="synopsis_sub">
$subsynopsis
</div>
</div>
};
}
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
sub process {
if ($_[0]) {
return traversePageTreeSynopsis($session{page}{pageId},0,$_[0]);
} else {
return $session{page}{synopsis};
}
}
1;

View file

@ -1,34 +0,0 @@
package WebGUI::Macro::T_topMenuVertical;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
#-------------------------------------------------------------------
sub process {
my ($temp, @param, $tree);
@param = WebGUI::Macro::getParams($_[0]);
$temp = '<span class="verticalMenu">';
if ($param[0] ne "") {
$tree = WebGUI::Navigation::tree(1,$param[0]);
} else {
$tree = WebGUI::Navigation::tree(1,1);
}
$temp .= WebGUI::Navigation::drawVertical($tree);
$temp .= '</span>';
return $temp;
}
1;

View file

@ -1,40 +0,0 @@
package WebGUI::Macro::TopDropMenu;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Navigation;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my ($temp, $tree, $pageId);
$tree = WebGUI::Navigation::tree(1,1);
$temp = '<script language="JavaScript" type="text/javascript">
function go(formObj){
if (formObj.chooser.options[formObj.chooser.selectedIndex].value != "none") {
location = formObj.chooser.options[formObj.chooser.selectedIndex].value
}
}
</script>';
$temp .= '<form><select name="chooser" size=1 onChange="go(this.form)">';
$temp .= '<option value=none>Where do you want to go?';
foreach $pageId (keys %{$tree}) {
$temp .= '<option value="'.$tree->{$pageId}{url}.'">'.$tree->{$pageId}{title};
}
$temp .= '</select></form>';
return $temp;
}
1;

View file

@ -1,31 +0,0 @@
package WebGUI::Macro::m_currentMenuHorizontal;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my ($temp, @param, $tree);
@param = WebGUI::Macro::getParams($_[0]);
$tree = WebGUI::Navigation::tree($session{page}{pageId},1);
$temp = '<span class="horizontalMenu">';
$temp .= WebGUI::Navigation::drawHorizontal($tree,$param[0]);
$temp .= '</span>';
return $temp;
}
1;

View file

@ -1,32 +0,0 @@
package WebGUI::Macro::p_previousMenuHorizontal;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub process {
my ($temp, $tree, @param);
@param = WebGUI::Macro::getParams($_[0]);
$tree = WebGUI::Navigation::tree($session{page}{parentId},1);
$temp = '<span class="horizontalMenu">';
$temp .= WebGUI::Navigation::drawHorizontal($tree,$param[0]);
$temp .= '</span>';
return $temp;
}
1;

View file

@ -1,30 +0,0 @@
package WebGUI::Macro::rootmenuHorizontal;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my @param = WebGUI::Macro::getParams($_[0]);
my $tree = WebGUI::Navigation::tree(0,1);
my $temp = '<span class="horizontalMenu">';
$temp .= WebGUI::Navigation::drawHorizontal($tree,$param[0]);
$temp .= '</span>';
return $temp;
}
1;

View file

@ -1,32 +0,0 @@
package WebGUI::Macro::s_specificMenuHorizontal;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my ($temp, $tree, $parentId, @param);
@param = WebGUI::Macro::getParams($_[0]);
$temp = '<span class="horizontalMenu">';
($parentId) = WebGUI::SQL->quickArray("select pageId from page where urlizedTitle='$param[0]'");
$tree = WebGUI::Navigation::tree($parentId,1);
$temp .= WebGUI::Navigation::drawHorizontal($tree,$param[1]);
$temp .= '</span>';
return $temp;
}
1;

View file

@ -1,41 +0,0 @@
package WebGUI::Macro::t_topMenuHorizontal;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# 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 WebGUI::Macro;
use WebGUI::Navigation;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my ($temp, $tree, @param);
@param = WebGUI::Macro::getParams($_[0]);
my $root = _findRoot($session{page}{pageId});
$tree = WebGUI::Navigation::tree($root,1);
$temp = '<span class="horizontalMenu">';
$temp .= WebGUI::Navigation::drawHorizontal($tree,$param[0]);
$temp .= '</span>';
return $temp;
}
sub _findRoot {
my ($pageId,$parentId) = WebGUI::SQL->quickArray("select pageId,parentId from page where pageId=$_[0]");
if ($parentId == $_[1]) {
return $pageId;
} else {
return _findRoot($parentId);
}
}
1;

View file

@ -51,15 +51,6 @@ A package used to generate navigation.
template=>'<tmpl_loop page_loop><tmpl_var page.title><br></tmpl_loop>'
);
$html = $custom->build;
=head1 OBSOLETE FUNCTIONS
use WebGUI::Navigation;
$pageTree = WebGUI::Navigation::tree($pageParentId,$depthToTraverse);
$html = WebGUI::Navigation::drawHorizontal($tree);
$html = WebGUI::Navigation::drawVertical($tree);
=head1 METHODS
@ -234,112 +225,6 @@ sub _toKeyValueHashRef {
return \%keyValues;
}
#-------------------------------------------------------------------
=head2 drawHorizontal ( tree [ , seperator, class ] )
Draws a horizontal navigation system. Returns HTML.
=over
=item tree
The hash reference created by the tree method in this package.
=item seperator
A string containing HTML to seperate each navigation item. Defaults to "&middot;".
=item class
A stylesheet class for each link in the navigation. Defaults to "horizontalMenu".
=back
=cut
sub drawHorizontal {
my ($output, $i, $pageId, $first);
my ($tree, $seperator, $class) = @_;
$class = "horizontalMenu" unless ($class);
$seperator = $seperator || '&middot;';
$first = 1;
foreach $pageId (keys %{$tree}) {
if ($first) {
$first = 0;
} else {
$output .= ' '.$seperator.' ';
}
$output .= '<a class="'.$class.'"';
$output .= ' target="_blank"' if ($tree->{$pageId}{newWindow});
$output .= ' href="'.$tree->{$pageId}{url}.'">';
if ($pageId == $session{page}{pageId}) {
$output .= '<span class="selectedMenuItem">'.$tree->{$pageId}{title}.'</span>';
} else {
$output .= $tree->{$pageId}{title};
}
$output .= '</a>';
}
return $output;
}
#-------------------------------------------------------------------
=head2 drawVertical ( tree [, bullet, class, spacing, indent ] )
Draws a vertical navigation system. Returns HTML.
=over
=item tree
The hash reference created by the tree method in this package.
=item bullet
A string containing HTML to generate a bullet that will be placed in front of each tree item. Defaults to none.
=item class
A stylesheet class for each link in the navigation. Defaults to "verticalMenu".
=item spacing
An integer with the linespacing for the navigation. Defaults to 1.
=item indent
An integer with the about of indenting to start with. Defaults to 0.
=back
=cut
sub drawVertical {
my ($output, $i, $padding, $leading, $pageId);
my ($tree, $bullet, $class, $spacing, $indent) = @_;
$class = "verticalMenu" unless ($class);
$spacing = 1 unless ($spacing);
for ($i=1;$i<=$indent;$i++) {
$padding .= "&nbsp;&nbsp;&nbsp;";
}
for ($i=1;$i<=$spacing;$i++) {
$leading .= "<br />";
}
foreach $pageId (keys %{$tree}) {
$output .= $padding.$bullet.'<a class="'.$class.'"';
$output .= ' target="_blank"' if ($tree->{$pageId}{newWindow});
$output .= ' href="'.$tree->{$pageId}{url}.'">';
if ($pageId == $session{page}{pageId}) {
$output .= '<span class="selectedMenuItem">'.$tree->{$pageId}{title}.'</span>';
} else {
$output .= $tree->{$pageId}{title};
}
$output .= '</a>'.$leading;
$output .= drawVertical($tree->{$pageId}{sub}, $bullet, $class, $spacing, ($indent+1));
}
return $output;
}
#-------------------------------------------------------------------
@ -582,68 +467,6 @@ sub view {
}
}
#-------------------------------------------------------------------
=head2 tree ( parentId [, toLevel ] )
Generates and returns a hash reference containing a page tree with keys of "url", "title", "fullTitle", "synopsis", "newWindow" and "sub" with orignating keys of page ids. The tree looks like this:
root
|-pageId
| |-url
| |-title
| |-fullTitle
| |-synopsis
| |-newWindow
| `-sub (pageId)
| |-url
| |-title
| |-fullTitle
| |-synopsis
| |-newWindow
| `-sub (pageId)
| `-etc
`-pageId
`-etc
=over
=item parentId
The page id of where you'd like to start the tree.
=item toLevel
The depth the tree should be traversed. Defaults to "0". If set to "0" the entire tree will be traversed.
=back
=cut
sub tree {
my ($sth, %data, %tree);
my ($parentId, $toLevel, $depth) = @_;
$toLevel = 99 if ($toLevel > 100 || $toLevel < 1);
tie %tree, 'Tie::IxHash';
tie %data, 'Tie::CPHash';
if ($depth < $toLevel) {
$sth = WebGUI::SQL->read("select urlizedTitle, menuTitle, pageId, synopsis, hideFromNavigation,
newWindow, title from page
where parentId='$parentId' order by sequenceNumber");
while (%data = $sth->hash) {
if (!($data{hideFromNavigation}) && WebGUI::Privilege::canViewPage($data{pageId})) {
$tree{$data{pageId}}{url} = WebGUI::URL::gateway($data{urlizedTitle});
$tree{$data{pageId}}{title} = $data{menuTitle};
$tree{$data{pageId}}{synopsis} = $data{synopsis};
$tree{$data{pageId}}{fullTitle} = $data{title};
$tree{$data{pageId}}{newWindow} = $data{newWindow};
$tree{$data{pageId}}{sub} = tree($data{pageId},$toLevel,($depth+1));
}
}
$sth->finish;
}
return \%tree;
}