uw Mon Mar 12 12:22:13 2001 EDT
Modified files:
/php4/pear/Experimental/HTML Menu.php
Log:
- made the URL check independend from $PHP_SELF
- removed homepage specific code
Index: php4/pear/Experimental/HTML/Menu.php
diff -u php4/pear/Experimental/HTML/Menu.php:1.1
php4/pear/Experimental/HTML/Menu.php:1.2
--- php4/pear/Experimental/HTML/Menu.php:1.1 Fri Mar 9 00:54:01 2001
+++ php4/pear/Experimental/HTML/Menu.php Mon Mar 12 12:22:13 2001
@@ -251,13 +251,9 @@
*/
function buildMenu($menu, $level = 0, $flag_stop_level = -1) {
static $last_node = array();
- global $PHP_SELF;
+
+ $current_url = $this->getCurrentURL();
- // WARNING: dirty redsys.de Hack
- if ("" != HOME && "/" . HOME == substr($PHP_SELF, 0, strlen(HOME) + 1))
- $PHP_SELF = substr($PHP_SELF, strlen(HOME) + 1);
-
-
// the recursion goes slightly different for every menu type
switch ($this->menu_type) {
@@ -266,7 +262,7 @@
// loop through the (sub)menu
foreach ($menu as $node_id => $node) {
- if ($PHP_SELF == $node["url"]) {
+ if ($current_url == $node["url"]) {
// menu item that fits to this url - "active" menu item
$type = 1;
} else if (isset($this->path[$level]) && $this->path[$level] ==
$node_id) {
@@ -294,7 +290,7 @@
// loop through the (sub)menu
foreach ($menu as $node_id => $node) {
- if ($PHP_SELF == $node["url"]) {
+ if ($current_url == $node["url"]) {
// menu item that fits to this url - "active" menu item
$type = 1;
} else if (isset($this->path[$level]) && $this->path[$level] ==
$node_id) {
@@ -327,7 +323,7 @@
// loop through the (sub)menu
foreach ($menu as $node_id => $node) {
- if ($PHP_SELF == $node["url"]) {
+ if ($current_url == $node["url"]) {
// menu item that fits to this url - "active" menu item
$type = 1;
} else if (isset($this->path[$level]) && $this->path[$level] ==
$node_id) {
@@ -366,7 +362,7 @@
break;
- } else if ($PHP_SELF == $node["url"]) {
+ } else if ($current_url == $node["url"]) {
// menu item that fits to this url - "active" menu item
$type = 1;
@@ -419,12 +415,13 @@
* @param int level of recursion, current depth in the tree structure
*/
function buildSitemap($menu, $level = 0) {
- global $PHP_SELF;
-
+
+ $current_url = $this->getCurrentURL();
+
// loop through the (sub)menu
foreach ($menu as $node_id => $node) {
- if ($PHP_SELF == $node["url"]) {
+ if ($current_url == $node["url"]) {
// menu item that fits to this url - "active" menu item
$type = 1;
} else if (isset($this->path[$level]) && $this->path[$level] == $node_id)
{
@@ -530,15 +527,13 @@
* Returns the path of the current page in the menu "tree".
*
* @return array path to the selected menu item
- * @global $PHP_SELF
* @see buildPath(), $urlmap
*/
function getPath() {
- global $PHP_SELF;
$this->buildPath($this->menu, array());
- return $this->urlmap[$PHP_SELF];
+ return $this->urlmap[$this->currentURL()];
} // end func getPath
@@ -553,8 +548,9 @@
* @see getPath(), $urlmap
*/
function buildPath($menu, $path) {
- global $PHP_SELF;
-
+
+ $current_url = $this->getCurrentURL();
+
// loop through the (sub)menu
foreach ($menu as $node_id => $node) {
@@ -562,7 +558,7 @@
$this->urlmap[$node["url"]] = $path;
// we got'em - stop the search by returning true
- if ($node["url"] == $PHP_SELF)
+ if ($node["url"] == $current_url)
return true;
// current node has a submenu
@@ -573,7 +569,7 @@
$subpath[] = $node_id;
// continue search recursivly - return is the inner loop finds the
- // node that belongs to $PHP_SELF
+ // node that belongs to the current url
if ($this->buildPath($node["sub"], $subpath))
return true;
}
@@ -583,6 +579,19 @@
// not found
return false;
} // end func buildPath
+
+
+ /**
+ * Returns the URL of the currently selected page.
+ *
+ * The returned string is used for all test against the URL's
+ * in the menu structure hash.
+ *
+ * @return string
+ */
+ function getCurrentURL() {
+ return $GLOBALS["PHP_SELF"];
+ } // end func getCurrentURL
} // end class menu
?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]