LayersMenu(); $this->phpTreeMenuDefaultExpansion = ""; $this->_phpTreeMenu = array(); $this->plainMenuTpl = $this->dirroot . $this->tpldir . "layersmenu-plain_menu.ihtml"; $this->plainMenuSeparator = "|"; $this->_plainMenu = array(); $this->horizontalPlainMenuTpl = $this->dirroot . $this->tpldir . "layersmenu-horizontal_plain_menu.ihtml"; $this->horizontalPlainMenuSeparator = "|"; $this->_horizontalPlainMenu = array(); } /** * The method to set the default value of the expansion string for the PHP Tree Menu * @access public * @return void */ function setPHPTreeMenuDefaultExpansion($phpTreeMenuDefaultExpansion) { $this->phpTreeMenuDefaultExpansion = $phpTreeMenuDefaultExpansion; } /** * Method to prepare a new PHP Tree Menu. * * This method processes items of a menu and parameters submitted * through GET (i.e. nodes to be expanded) to prepare and return * the corresponding Tree Menu code. * * @access public * @param string $menu_name the name of the menu whose items have to be processed * @return string */ function newPHPTreeMenu( $menu_name = "" // non consistent default... ) { $protocol = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? "https://" : "http://"; $this_host = (isset($_SERVER["HTTP_HOST"])) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"]; if (isset($_SERVER["SCRIPT_NAME"])) { $me = $_SERVER["SCRIPT_NAME"]; } else if (isset($_SERVER["REQUEST_URI"])) { $me = $_SERVER["REQUEST_URI"]; } else if (isset($_SERVER["PHP_SELF"])) { $me = $_SERVER["PHP_SELF"]; } else if (isset($_SERVER["PATH_INFO"])) { $me = $_SERVER["PATH_INFO"]; } $url = $protocol . $this_host . $me; $query = ""; reset($_GET); while (list($key, $value) = each($_GET)) { if ($key != "p" && $value != "") { $query .= "&" . $key . "=" . $value; } } if ($query != "") { $query = "?" . substr($query, 5) . "&p="; } else { $query = "?p="; } $p = (isset($_GET["p"])) ? $_GET["p"] : $this->phpTreeMenuDefaultExpansion; /* ********************************************************* */ /* Based on TreeMenu 1.1 by Bjorge Dijkstra (bjorge@gmx.net) */ /* ********************************************************* */ $this->_phpTreeMenu[$menu_name] = ""; $img_space = $this->imgwww . "tree_space." . $this->treeMenuImagesType; $alt_space = " "; $img_vertline = $this->imgwww . "tree_vertline." . $this->treeMenuImagesType; $alt_vertline = "| "; $img_expand = $this->imgwww . "tree_expand." . $this->treeMenuImagesType; $alt_expand = "+-"; $img_expand_first = $this->imgwww . "tree_expand_first." . $this->treeMenuImagesType; $alt_expand_first = "+-"; $img_expand_corner = $this->imgwww . "tree_expand_corner." . $this->treeMenuImagesType; $alt_expand_corner = "+-"; $img_expand_corner_first = $this->imgwww . "tree_expand_corner_first." . $this->treeMenuImagesType; $alt_expand_corner_first = "+-"; $img_collapse = $this->imgwww . "tree_collapse." . $this->treeMenuImagesType; $alt_collapse = "--"; $img_collapse_first = $this->imgwww . "tree_collapse_first." . $this->treeMenuImagesType; $alt_collapse_first = "--"; $img_collapse_corner = $this->imgwww . "tree_collapse_corner." . $this->treeMenuImagesType; $alt_collapse_corner = "--"; $img_collapse_corner_first = $this->imgwww . "tree_collapse_corner_first." . $this->treeMenuImagesType; $alt_collapse_corner_first = "--"; $img_split = $this->imgwww . "tree_split." . $this->treeMenuImagesType; $alt_split = "|-"; $img_split_first = $this->imgwww . "tree_split_first." . $this->treeMenuImagesType; $alt_split_first = "|-"; $img_corner = $this->imgwww . "tree_corner." . $this->treeMenuImagesType; $alt_corner = "`-"; $img_folder_closed = $this->imgwww . "tree_folder_closed." . $this->treeMenuImagesType; $alt_folder_closed = "->"; $img_folder_open = $this->imgwww . "tree_folder_open." . $this->treeMenuImagesType; $alt_folder_open = "->"; $img_leaf = $this->imgwww . "tree_leaf." . $this->treeMenuImagesType; $alt_leaf = "->"; for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) { $expand[$i] = 0; $visible[$i] = 0; $this->tree[$i]["last_item"] = 0; } for ($i=0; $i<=$this->_maxLevel[$menu_name]; $i++) { $levels[$i] = 0; } // Get numbers of nodes to be expanded if ($p != "") { $explevels = explode($this->treeMenuSeparator, $p); $explevels_count = count($explevels); for ($i=0; $i<$explevels_count; $i++) { $expand[$explevels[$i]] = 1; } } // Find last nodes of subtrees $last_level = $this->_maxLevel[$menu_name]; for ($i=$this->_lastItem[$menu_name]; $i>=$this->_firstItem[$menu_name]; $i--) { if ($this->tree[$i]["level"] < $last_level) { for ($j=$this->tree[$i]["level"]+1; $j<=$this->_maxLevel[$menu_name]; $j++) { $levels[$j] = 0; } } if ($levels[$this->tree[$i]["level"]] == 0) { $levels[$this->tree[$i]["level"]] = 1; $this->tree[$i]["last_item"] = 1; } else { $this->tree[$i]["last_item"] = 0; } $last_level = $this->tree[$i]["level"]; } // Determine visible nodes // all root nodes are always visible for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) { if ($this->tree[$i]["level"] == 1) { $visible[$i] = 1; } } if (isset($explevels)) { for ($i=0; $i<$explevels_count; $i++) { $n = $explevels[$i]; if ($n >= $this->_firstItem[$menu_name] && $n <= $this->_lastItem[$menu_name] && $visible[$n] == 1 && $expand[$n] == 1) { $j = $n + 1; while ($j<=$this->_lastItem[$menu_name] && $this->tree[$j]["level"]>$this->tree[$n]["level"]) { if ($this->tree[$j]["level"] == $this->tree[$n]["level"]+1) { $visible[$j] = 1; } $j++; } } } } // Output nicely formatted tree for ($i=0; $i<$this->_maxLevel[$menu_name]; $i++) { $levels[$i] = 1; } $max_visible_level = 0; for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { if ($visible[$cnt]) { $max_visible_level = max($max_visible_level, $this->tree[$cnt]["level"]); } } for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { if ($visible[$cnt]) { $this->_phpTreeMenu[$menu_name] .= "
\n"; } } /* ********************************************************* */ /* // Some (old) browsers do not support the "white-space: nowrap;" CSS property... $this->_phpTreeMenu[$menu_name] = "\n" . $this->_phpTreeMenu[$menu_name] . " | \n" . "