block-Treemenu.php0100644000000000000000000000723007606620062013150 0ustar rootroot */ /* http://karakas-online.de */ /* */ /* This program is free software. You can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License. */ /* */ /* This PHPNuke 6.0 block will display a dynamic tree menu according */ /* to the entries found in the plain text file */ /* blocks/treemenu/sitemap.txt */ /* Edit this file to reflect your tree. As far as the syntax of it */ /* is concerned, you practically have to remember that a "." means */ /* "1st level entry", a ".." "2nd level" etc. The rest is just the */ /* text, the link and an optional window name for the link to */ /* appear in. See the file blocks/treemenu/treemenu.inc for more */ /* information and http://www.karakas-online.de/myTreemenu/t1.html */ /* for more documentation. */ /* */ /* Please mail me if you find any bugs and/or improvements. */ /* In the meantime, enjoy! */ /* */ /* Chris */ /* */ /************************************************************************/ if (eregi("block-Treemenu.php",$PHP_SELF)) { Header("Location: index.php"); die(); } ob_start(); include("blocks/treemenu/treemenu.inc"); $tree = new TreeMenu("a", "blocks/treemenu/sitemap.txt"); $tree->show(); /************************************************************************ This is the "alternative method" to fill the tree: $tree2 = new TreeMenu("b"); $tree2->addNode(1, "grandpa"); $tree2->addNode(2, "pa"); $tree2->addNode(3, "son"); $tree2->addNode(2, "uncle"); $tree2->show(); and here is a way to load different Treemenus based on, say, category id: global $catid; switch ($catid) { case 1: $tree = new TreeMenu("a", "blocks/treemenu/category1.txt"); $tree->show(); break; case 2: $tree = new TreeMenu("a", "blocks/treemenu/category2.txt"); $tree->show(); break; case 3: $tree = new TreeMenu("a", "blocks/treemenu/category3.txt"); $tree->show(); break; } ************************************************************************/ $output = ob_get_contents(); ob_end_clean(); $content = $output; $content .= "

Block created for PHPNuke 6.0 by Chris Karakas

"; ?> treemenu/0040755000000000000000000000000007606620131011405 5ustar rootroottreemenu/treemenu.inc0100644000000000000000000002672507606563474013755 0ustar rootrootshow(); ?> A global variable $e was used to pass expanded nodes from one invocation of the script to the next in Bjorge's version. Now you must specify the variable name when you create your TreeMenu object: $tree = new TreeMenu("a"); When the object is created, this variable name gets the letters "tmv" prepended to it. This allows the constructor to loop through the global variables and pick out those that it needs when writing certain URLs. This came about as a modification to some code sent to me by Enrico Stahn [enrico.stahn@gmx.net] on 11/29/2001 that added multimenu functionality to the script. Much thanks to him. I have archived his version at the following URL: http://www.bitbuddha.com/php/treemenu/stahn.112901.treemenu.inc I got rid of the overloaded constructor that would accept a file name or an array and act accordingly. This required programmers to know too much about the implementation of the class. I left the ability to pass a file name and supplied an addNode() method. You can use it like this: addNode(1, "grandpa"); $tree->addNode(2, "pa"); $tree->addNode(3, "son"); $tree->addNode(2, "uncle"); $tree->show(); ?> Look at the addNode method signature to see the two optional parameters (ok, so they are $link and $target). Your tree will look like this: + grandpa | |----+ pa | | | |---o son | |---o uncle If you have some hierarchical data in a database then it would be pretty easy to write a recursive function to build your tree dynamically using the addNode() method. The loadTreeFromFile() method allows you to add as many node files to a tree as you want. You can mix it up with other sources (database, etc) using the addNode() method, too. An example: addNode(1, "grandpa"); $tree->addNode(2, "pa"); $tree->addNode(3, "son"); $tree->addNode(2, "uncle"); $tree->loadTreeFromFile("demomenu.txt"); $tree->show(); ?> There is an additional getHTMLTable() method if you ever need that for some reason. It returns the table instead of echoing it. Denny Shimkoski 2001 dhscompguy@yahoo.com I have only fixed two bugs in this release, everything else is in its original form. You can see my comments in place - just search for the string "Changed by Chris". See more documentation on my Treemenu Block for PHPNuke at my homepage: http://www.karakas-online.de/myTreemenu/t1.html As far as I am concerned, we can release this under the GPL. Chris Karakas 2003 chris@karakas-online.de ************************************************************/ var $tree = array(); var $expand = array(); var $visible = array(); var $levels = array(); var $explevels = array(); var $urlparams = array(); var $maxlevel = 0; var $i = 0; var $urlparam; var $script; var $img_expand = "blocks/treemenu/tree_expand.png"; var $img_collapse = "blocks/treemenu/tree_collapse.png"; var $img_line = "blocks/treemenu/tree_vertline.png"; var $img_split = "blocks/treemenu/tree_split.png"; var $img_end = "blocks/treemenu/tree_end.png"; var $img_leaf = "blocks/treemenu/tree_leaf.png"; var $img_spc = "blocks/treemenu/tree_space.png"; function treemenu($urlparam, $nodefile = ""){ $this->script = isset($GLOBALS["PATH_INFO"]) ? $GLOBALS["PATH_INFO"] : $GLOBALS["SCRIPT_NAME"]; $this->urlparam = "tmv".$urlparam; reset($GLOBALS["HTTP_GET_VARS"]); while (list($key,) = each ($GLOBALS["HTTP_GET_VARS"])){ /********************************************* Changed by Chris. Commented the if statement. If you don't comment it, this "if" will "eat up" the "other parameters" you may have in your URL (these are stored in the $otherparams variable, which thus will be empty). The result will be that, instead of, for example http://yourhost/html/modules.php?name=Your_Account&tmva=1|#1 you will get http://yourhost/html/modules.php?tmva=1|#1 which is deadly for your PHPNuke. if (substr($key, 0, 3) == "tmv"){ *********************************************/ $this->urlparams[] = $key; /********************************************* } *********************************************/ } if (!empty($nodefile)) $this->loadTreeFromFile($nodefile); } function addNode($level, $text, $link = "", $target = ""){ $this->tree[$this->i][0] = $level; $this->tree[$this->i][1] = "".$text.""; $this->tree[$this->i][2] = $link; $this->tree[$this->i][3] = $target; $this->tree[$this->i][4] = 0; if ($this->tree[$this->i][0] > $this->maxlevel) $this->maxlevel = $this->tree[$this->i][0]; $this->expand[$this->i]=0; $this->visible[$this->i]=0; $this->levels[$this->i]=0; $this->i++; } function loadTreeFromFile($nodefile){ $fd = fopen($nodefile, "r"); if ($fd == 0) die($this->script." : Unable to open file ".$nodefile); while ($buffer = fgets($fd, 4096)){ $level = strspn($buffer,"."); $node = explode("|", rtrim(substr($buffer,$level))); $text = $node[0]; $link = $node[1]; $target = $node[2]; $this->addNode($level, $text, $link, $target); } fclose($fd); } function setExpandedNodesFromURL(){ if (!empty($GLOBALS[$this->urlparam])) $this->explevels = explode("|",$GLOBALS[$this->urlparam]); $this->setExpandedNodes(); } function setExpandedNodes(){ $i=0; while($iexplevels)){ $this->expand[$this->explevels[$i]]=1; $i++; } } function setEndNodes(){ $lastlevel=$this->maxlevel; for ($i=count($this->tree)-1; $i>=0; $i--){ if ( $this->tree[$i][0] < $lastlevel ){ for ($j=$this->tree[$i][0]+1; $j <= $this->maxlevel; $j++){ $this->levels[$j]=0; } } if ( $this->levels[$this->tree[$i][0]]==0 ){ $this->levels[$this->tree[$i][0]]=1; $this->tree[$i][4]=1; } else { $this->tree[$i][4]=0; } $lastlevel=$this->tree[$i][0]; } } function setVisibleNodes(){ // all root nodes are always visible for ($i=0; $i < count($this->tree); $i++){ if ($this->tree[$i][0]==1){ $this->visible[$i]=1; } } for ($i=0; $i < count($this->explevels); $i++){ $n = $this->explevels[$i]; if ( ($this->visible[$n]==1) && ($this->expand[$n]==1) ){ $j=$n+1; while ( $this->tree[$j][0] > $this->tree[$n][0] ){ if ($this->tree[$j][0]==$this->tree[$n][0]+1) $this->visible[$j]=1; $j++; } } } } function show(){ echo $this->getHTMLTable(); } function getHTMLTable(){ $this->setExpandedNodesFromURL(); $this->setEndNodes(); $this->setVisibleNodes(); /********************************************* * Output nicely formatted tree * *********************************************/ for ($i=0; $i<$this->maxlevel; $i++) $this->levels[$i]=1; $this->maxlevel++; $html = "\n"; $html .= ""; /********************************************* * Changed by Chris. * * Changed $this->maxlevel to * * ($this->maxlevel+3) in the condition. * * Just as the table created just above * * has ($this->maxlevel+3) columns, * * we have to output that many * * * * or an ugly scrollbar will appear at * * the bottom. * *********************************************/ for ($i=0; $i<($this->maxlevel+3); $i++) $html .= ""; $html .= "\n"; $cnt=0; while ($cnttree)){ if ($this->visible[$cnt]){ /**************************************** * start new row * ****************************************/ $html .= ""; /**************************************** * vertical lines from higher levels * ****************************************/ $i=0; while ($i<$this->tree[$cnt][0]-1){ if ($this->levels[$i]==1){ $html .= ""; } else { $html .= ""; } $i++; } /**************************************** * corner at end of subtree or t-split * ****************************************/ if ($this->tree[$cnt][4]==1){ $html .= ""; $this->levels[$this->tree[$cnt][0]-1]=0; } else { $html .= ""; $this->levels[$this->tree[$cnt][0]-1]=1; } /******************************************** * Node (with subtree) or Leaf (no subtree) * ********************************************/ if ($this->tree[$cnt+1][0]>$this->tree[$cnt][0]){ /**************************************** * Create expand/collapse parameters * ****************************************/ reset($this->urlparams); while (list(,$value) = each ($this->urlparams)){ if (!empty($GLOBALS[$value]) && $value <> $this->urlparam) { $otherparams .= $value."=".$GLOBALS[$value]."&"; } } $params="?".$otherparams.$this->urlparam."="; $i=0; while($iexpand)){ if ( ($this->expand[$i]==1) && ($cnt!=$i) || ($this->expand[$i]==0 && $cnt==$i)){ $params=$params.$i; $params=$params."|"; } $i++; } $otherparams = ""; if ($this->expand[$cnt]==0){ $html .= ""; } else { $html .= ""; } } else { /************************* * Tree Leaf * *************************/ $html .= ""; } /**************************************** * output item text * ****************************************/ if ($this->tree[$cnt][2]==""){ $html .= ""; } else { $html .= ""; } /**************************************** * end row * ****************************************/ $html .= "\n"; } $cnt++; } $html .= "
 
img_line."\">img_spc."\">img_end."\">img_split."\">script.$params."#$cnt\">img_expand."\" border=no>script.$params."#$cnt\">img_collapse."\" border=no>img_leaf."\">".$this->tree[$cnt][1]."tree[$cnt][2]."\" target=\"".$this->tree[$cnt][3]."\">".$this->tree[$cnt][1]."
\n"; return $html; } } ?> treemenu/tree_collapse.png0100644000000000000000000000032007606137602014732 0ustar rootrootPNG  IHDR%=m"gAMA aPLTE8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).IIDATxc3E/l8\\'tIME (&GIENDB`treemenu/tree_end.png0100644000000000000000000000030707606137602013703 0ustar rootrootPNG  IHDR%=m"gAMA aPLTE8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).IIDATxctrĆu@a/tIME (ߗuIENDB`treemenu/tree_expand.png0100644000000000000000000000032407606137602014413 0ustar rootrootPNG  IHDR%=m"gAMA aPLTE8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).I"IDATxc3^C@8\CtIME ?IENDB`treemenu/tree_leaf.png0100644000000000000000000000033207606137602014042 0ustar rootrootPNG  IHDR%=m"gAMA aPLTE8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).I(IDATxc3> ߃H (rc`ژtIME ;B2(IENDB`treemenu/tree_space.png0100644000000000000000000000027207606137602014231 0ustar rootrootPNG  IHDRgAMA aPLTE8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).I IDATxc``:ctIME =IENDB`treemenu/tree_split.png0100644000000000000000000000031007606137602014262 0ustar rootrootPNG  IHDR%=m"gAMA aPLTE8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).IIDATxctrItIME #zsνIENDB`treemenu/tree_vertline.png0100644000000000000000000000030307606137602014761 0ustar rootrootPNG  IHDR%=m"gAMA aPLTE8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).IIDATxcIٚ,tIME 3gIENDB`treemenu/sitemap.txt0100644000000000000000000000371007606466161013621 0ustar rootroot.Start|http://www.karakas-online.de|_top|; .Links ..My work ...Overview|http://www.karakas-online.de/myWork/t1.html|_top|; ...SAP|http://www.karakas-online.de/myWork/sap.html|_top|; ....Projects...|http://www.karakas-online.de/myProfile/book1.html|_top|; ...Linux|http://www.karakas-online.de/myWork/linux.html|_top|; ....AMANDA...|http://www.karakas-online.de/myAMANDA/t1.html|_top|; ....PHPNuke...|http://www.karakas-online.de/EN-Book/book1.html|_top|; ....UserFriendly...|http://www.karakas-online.de/phpnuke/block-User_Friendly.tar|_top|; ....Meteosat...|http://www.karakas-online.de/phpnuke/block-Meteosat.tar|_top|; ....Web Radio...|http://www.karakas-online.de/phpnuke/block-Web_Radio.tar|_top|; ....Linux Tips...|http://www.karakas-online.de/myLinuxTips/book1.html|_top|; ...Mathematics|http://www.karakas-online.de/myWork/mathematics.html|_top|; ...Comp. Graphics|http://www.karakas-online.de/myWork/computer_graphics.html|_top|; ..My hobbies ...Overview|http://www.karakas-online.de/myHobbies/t1.html|_top|; ..My online services ...Overview|http://www.karakas-online.de/myServices/index.html|_top|; ...Postcard service|http://www.karakas-online.de/cards/card.html|_top|; ...Hot links|http://www.karakas-online.de/link-o-matik.html|_blank|; ...HTML Validator|http://www.karakas-online.de/myServices/validator.html|_top|; ...Mortgage Calculator|http://www.karakas-online.de/myServices/mortgage_calculator.php|_top|; ...Web Radio|http://www.karakas-online.de/myServices/webradio.php|_top|; ...Meteosat|http://www.karakas-online.de/myServices/meteosat.php|_top|; ...User Friendly|http://www.karakas-online.de/myServices/userfriendly.php|_top|; .Forum|http://www.karakas-online.de/cgi3/index.html|_top|; .Guestbook|http://www.karakas-online.de/cgi1/index.html|_top|; .My wishlist|http://www.amazon.de/exec/obidos/wishlist/7IEDDLYYBJ3X/ref=wl_em_to|_top|; .Email me|mailto:chris@karakas-online.de?subject=Homepage%20Comments