cvs: php4 /pear/Experimental/HTML Menu.php

From: Date: Mon, 12 Mar 2001 23:26:16 +0000
Subject: cvs: php4 /pear/Experimental/HTML Menu.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4523@lists.php.net to get a copy of this message
uw Mon Mar 12 15:26:16 2001 EDT Modified files: /php4/pear/Experimental/HTML Menu.php Log: - extended "prevnext" mode to show the previous, up and next item (up is new) Index: php4/pear/Experimental/HTML/Menu.php diff -u php4/pear/Experimental/HTML/Menu.php:1.4 php4/pear/Experimental/HTML/Menu.php:1.5 --- php4/pear/Experimental/HTML/Menu.php:1.4 Mon Mar 12 14:03:51 2001 +++ php4/pear/Experimental/HTML/Menu.php Mon Mar 12 15:26:15 2001 @@ -264,7 +264,7 @@ * @param integer prevnext flag */ function buildMenu($menu, $level = 0, $flag_stop_level = -1) { - static $last_node = array(); + static $last_node = array(), $up_node = array(); // the recursion goes slightly different for every menu type switch ($this->menu_type) { @@ -377,6 +377,7 @@ } else if ($this->current_url == $node["url"]) { // menu item that fits to this url - "active" menu item $type = 1; + $flag_stop_level = $level; if (0 != count($last_node)) { @@ -392,7 +393,18 @@ } - $flag_stop_level = $level; + if (0 != count($up_node)) { + + $this->html .= $this->getEntry($up_node, $level, 5); + + } else { + + // WARNING: if there's no up take the first menu entry - you might not like this rule! + reset($this->menu); + list($node_id, $first_node) = each($this->menu); + $this->html .= $this->getEntry($first_node, $level, 5); + + } } else if (isset($this->path[$level]) && $this->path[$level] == $node_id) { // processed menu item is part of the path to the active menu item @@ -408,8 +420,10 @@ $last_node = $node; // follow the subtree if the active menu item is in it - if ($type && isset($node["sub"])) + if ($type && isset($node["sub"])) { + $up_node = $node; $flag_stop_level = $this->buildMenu($node["sub"], $level + 1, (-1 != $flag_stop_level) ? $flag_stop_level + 1 : -1); + } } break; @@ -523,6 +537,15 @@ $node["title"] ); break; + + case 5: + // up url ^^ + $html .= sprintf('<td>%s<a href="%s">^ %s ^</a></td>', + $indent, + $node["url"], + $node["title"] + ); + break; }

« previous php.cvs (#4523) next »