/** * Method to prepare a new Tree Menu. * * This method processes items of a menu to prepare and return * the corresponding Tree Menu code. * * @param string $menu_name the name of the menu whose items have to be processed * @return string */ function newTreeMenu($menu_name = "") { $this->_treeMenu[$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_corner = $this->imgwww . "tree_expand_corner." . $this->treeMenuImagesType; $alt_expand_corner = "+-"; $img_collapse = $this->imgwww . "tree_collapse." . $this->treeMenuImagesType; $alt_collapse = "--"; $img_collapse_corner = $this->imgwww . "tree_collapse_corner." . $this->treeMenuImagesType; $alt_collapse_corner = "--"; $img_split = $this->imgwww . "tree_split." . $this->treeMenuImagesType; $alt_split = "|-"; $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 = 0; $i <= $this->_maxLevel[$menu_name]; $i++) { $levels[$i] = 0; } // Find last nodes of subtrees $last_level = $this->_maxLevel; 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"]; } $toggle = ""; $toggle_function_name = "toggle" . $menu_name; for ($cnt = $this->_firstItem[$menu_name]; $cnt <= $this->_lastItem[$menu_name]; $cnt++) { if ($this->tree[$cnt]["parsed_link"] == "" || $this->tree[$cnt]["parsed_link"] == "#") { $this->_treeMenu[$menu_name] .= "<div id=\"jt" . $cnt . "\" style=\"display: block; white-space: nowrap;\" class=\"phplmnormal\">\n"; } else { $this->_treeMenu[$menu_name] .= "<div id=\"jt" . $cnt . "\" style=\"display: block; white-space: nowrap;\">\n"; } // vertical lines from higher levels for ($i = 0; $i < $this->tree[$cnt]["level"] - 1; $i++) { if ($levels[$i] == 1) { $img = $img_vertline; $alt = $alt_vertline; } else { $img = $img_space; $alt = $alt_space; } $this->_treeMenu[$menu_name] .= "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img . "\" alt=\"" . $alt . "\" />"; } $not_a_leaf = $cnt < $this->_lastItem[$menu_name] && $this->tree[$cnt + 1]["level"] > $this->tree[$cnt]["level"]; if ($this->tree[$cnt]["last_item"] == 1) { // corner at end of subtree or t-split if ($not_a_leaf) { $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "')\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img_collapse_corner . "\" alt=\"" . $alt_collapse_corner . "\" /></a>"; } else { $this->_treeMenu[$menu_name] .= "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img_corner . "\" alt=\"" . $alt_corner . "\" />"; } $levels[$this->tree[$cnt]["level"] - 1] = 0; } else { if ($not_a_leaf) { $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "');\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img_collapse . "\" alt=\"" . $alt_collapse . "\" /></a>"; } else { $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "');\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img_split . "\" alt=\"" . $alt_split . "\" /></a>"; } $levels[$this->tree[$cnt]["level"] - 1] = 1; } if ($this->tree[$cnt]["parsed_link"] == "" || $this->tree[$cnt]["parsed_link"] == "#") { $a_href_open = ""; $a_href_close = ""; } else { $a_href_open = "<a class=\"phplm\" href=\"" . $this->tree[$cnt]["parsed_link"] . "\"" . $this->tree[$cnt]["parsed_title"] . $this->tree[$cnt]["parsed_target"] . ">"; $a_href_close = "</a>"; } if ($not_a_leaf) { $this->_treeMenu[$menu_name] .= $a_href_open . "<img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "folder\" src=\"" . $img_folder_open . "\" alt=\"" . $alt_folder_open . "\" />" . $a_href_close; } else { if ($this->tree[$cnt]["parsed_icon"] != "") { $this->_treeMenu[$menu_name] .= $a_href_open . "<img align=\"top\" border=\"0\" src=\"" . $this->imgwww . $this->tree[$cnt]["parsed_icon"] . "\" width=\"" . $this->tree[$cnt]["iconwidth"] . "\" height=\"" . $this->tree[$cnt]["iconheight"] . "\" alt=\"" . $alt_leaf . "\" />" . $a_href_close; } else { $this->_treeMenu[$menu_name] .= $a_href_open . "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img_leaf . "\" alt=\"" . $alt_leaf . "\" />" . $a_href_close; } } $this->_treeMenu[$menu_name] .= " " . $a_href_open . $this->tree[$cnt]["text"] . $a_href_close . "\n"; $this->_treeMenu[$menu_name] .= "</div>\n"; if ($cnt < $this->_lastItem[$menu_name] && $this->tree[$cnt]["level"] < $this->tree[$cnt + 1]["level"]) { $this->_treeMenu[$menu_name] .= "<div id=\"jt" . $cnt . "son\" style=\"display: block; white-space: nowrap;\">\n"; if ($this->tree[$cnt]["expanded"] != 1) { $toggle .= "if (expand[" . $cnt . "] != 1) " . $toggle_function_name . "('" . $cnt . "');\n"; } else { $toggle .= "if (collapse[" . $cnt . "] == 1) " . $toggle_function_name . "('" . $cnt . "');\n"; } } if ($cnt > $this->_firstItem[$menu_name] && $this->tree[$cnt]["level"] > $this->tree[$cnt + 1]["level"]) { for ($i = max(1, $this->tree[$cnt + 1]["level"]); $i < $this->tree[$cnt]["level"]; $i++) { $this->_treeMenu[$menu_name] .= "</div>\n"; } } } /* // Some (old) browsers do not support the "white-space: nowrap;" CSS property... $this->_treeMenu[$menu_name] = "<table>\n" . "<tr>\n" . "<td class=\"phplmnormal\" nowrap=\"nowrap\">\n" . $this->_treeMenu[$menu_name] . "</td>\n" . "</tr>\n" . "</table>\n"; */ $t = new LayersTemplate(); $t->setFile("tplfile", $this->tpldir . "layerstreemenu.ijs"); // :PATCH: Alex Pagnoni 031007: Innomatic patch $t->setVar(array("toggle_function_name" => $toggle_function_name, "img_expand" => $img_expand, "img_collapse" => $img_collapse, "img_collapse_corner" => $img_collapse_corner, "img_folder_open" => $img_folder_open, "img_expand_corner" => $img_expand_corner, "img_folder_closed" => $img_folder_closed)); $toggle_function = $t->parse("out", "tplfile"); $toggle_function = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . $toggle_function . "// -->\n" . "</script>\n"; $toggle = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . "if ((DOM && !Opera56 && !Konqueror2) || IE4) {\n" . $toggle . "}\n" . "if (NS4) alert('Only the accessibility is provided to Netscape 4 on the JavaScript Tree Menu.\\nWe *strongly* suggest you to upgrade your browser.');\n" . "// -->\n" . "</script>\n"; $this->_treeMenu[$menu_name] = $toggle_function . "\n" . $this->_treeMenu[$menu_name] . "\n" . $toggle; return $this->_treeMenu[$menu_name]; }
/** * Method to prepare a new Horizontal Plain Menu. * * This method processes items of a menu to prepare and return * the corresponding Horizontal Plain Menu code. * * @param string $menu_name the name of the menu whose items have to be processed * @return string */ function newHorizontalPlainMenu($menu_name = "") { $horizontal_plain_menu_blck = ""; $t = new LayersTemplate(); $t->setFile("tplfile", $this->horizontalPlainMenuTpl); $t->setBlock("tplfile", "template", "template_blck"); $t->setBlock("template", "horizontal_plain_menu_cell", "horizontal_plain_menu_cell_blck"); $t->setVar("horizontal_plain_menu_cell_blck", ""); $t->setBlock("horizontal_plain_menu_cell", "plain_menu_cell", "plain_menu_cell_blck"); $t->setVar("plain_menu_cell_blck", ""); for ($cnt = $this->_firstItem[$menu_name]; $cnt <= $this->_lastItem[$menu_name]; $cnt++) { if ($this->tree[$cnt]["level"] == 1 && $cnt > $this->_firstItem[$menu_name]) { $t->parse("horizontal_plain_menu_cell_blck", "horizontal_plain_menu_cell", true); $t->setVar("plain_menu_cell_blck", ""); } $nbsp = ""; for ($i = 1; $i < $this->tree[$cnt]["level"]; $i++) { $nbsp .= " "; } $t->setVar(array("nbsp" => $nbsp, "link" => $this->tree[$cnt]["parsed_link"], "title" => $this->tree[$cnt]["parsed_title"], "target" => $this->tree[$cnt]["parsed_target"], "text" => $this->tree[$cnt]["parsed_text"])); $t->parse("plain_menu_cell_blck", "plain_menu_cell", true); } $t->parse("horizontal_plain_menu_cell_blck", "horizontal_plain_menu_cell", true); $this->_horizontalPlainMenu[$menu_name] = $t->parse("template_blck", "template"); return $this->_horizontalPlainMenu[$menu_name]; }