function css_for_nav_parrent($items) { function hasSub($menu_item_id, $items) { foreach ($items as $item) { if ($item->menu_item_parent && $item->menu_item_parent == $menu_item_id) { return true; } } return false; } foreach ($items as $item) { if (hasSub($item->ID, $items)) { $item->test = "dropdown-toggle "; $item->class = "dropdown-toggle"; $item->data_toggle = "dropdown"; $item->role = "button"; $item->aria_haspopup = "true"; $item->aria_expanded = 'false'; /* all elements "classes" in menu, will unions on class HTML teg <li>*/ $item->classes[] = 'dropdown'; $item->dropdown = '<span class="caret"></span>'; } } return $items; }
function mainNavFilter($items) { foreach ($items as $item) { if (hasSub($item->ID, $items)) { $item->classes[] = 'dropdown'; } } return $items; }
function createmenu($array, $imgRootPath, $divIdPrefix = "", $parent_id = 0) { $result = ""; $rs = resetArray($parent_id, $array); $result = '<div class="tree_menu" id="' . $divIdPrefix . '_tree_menu" >'; for ($i = 0; $i < count($rs); $i++) { $result .= "<div width='100%'>"; for ($j = 0; $j < $rs[$i]["flag"]; $j++) { if ($rs[$i]["name"] && $j + 1 == $rs[$i]["flag"]) { if ($rs[$i + 1]["parent_id"] == $rs[$i]["parent_id"]) { $result .= '<img src="' . $imgRootPath . 'style/tree/H.gif">'; } else { if ($rs[$i]["flag"] <= $rs[$i + 1]["flag"] + 1) { $result .= '<img src="' . $imgRootPath . 'style/tree/H.gif">'; } else { $result .= '<img src="' . $imgRootPath . 'style/tree/L.gif">'; } } //echo "<hr />"; } else { $result .= '<img src="' . $imgRootPath . 'style/tree/I.gif">'; } } $rsid = $rs[$i]["id"]; $flag_img = "nfolder.gif"; $onclick = ""; $A_onclick = ""; if (hasSub($rs[$i]["id"], $array)) { $flag_img = "ofolder.gif"; //隱藏 if ($rs[$i]["hide_sub"] == 1) { $flag_img = "folder.gif"; } $onclick = ' onclick="OnClickOutline(\'' . $imgRootPath . '\',' . $rsid . ')" '; $A_onclick = "javascript:OnClickOutline('" . $imgRootPath . "'," . $rsid . ")"; } $result .= '<img class="Outline" id="ID' . $rsid . '" style="CURSOR: pointer" ' . $onclick . ' alt="" src="' . $imgRootPath . 'style/tree/' . $flag_img . '" /> '; if ($rs[$i]["link"]) { $result .= '<a href="' . $rs[$i]["link"] . '">'; } else { if ($A_onclick) { $result .= '<a href=' . $A_onclick; } else { $result .= '<a href="javascript:void(0);"'; } // $result.='<a href="javascript:void(0);"'; // if($onclick) $result.=$onclick; $result .= '>'; } $result .= $rs[$i]["name"]; $result .= '</a>'; $result .= "</div>"; // if($rs[$i]["pid"]==0) $result.= "<br />"; //</div> if ($rs[$i]["flag"] > $rs[$i + 1]["flag"]) { $div_n = $rs[$i]["flag"] - $rs[$i + 1]["flag"]; for ($div_i = 0; $div_i < $div_n; $div_i++) { $result .= "</div>"; } } //end </div> //<div> if (hasSub($rs[$i]["id"], $array)) { $result .= '<div id="ID' . $rsid . 'd"'; if ($rs[$i]["hide_sub"] == 1) { $result .= ' style="display:none" '; } $result .= '>'; } //end <div> } //$result.= ' <div id="infodisplay"><font color="#999999">點擊+展開節點</font></div>'; $result .= '</div>'; $result .= "<script>"; $result .= "\t\$('#" . $divIdPrefix . "_tree_menu a').click(function (){"; $result .= "\t\tif(\$(this).attr('href')!='javascript:void(0);') {"; $result .= "\t\t\tSetCookie('" . $divIdPrefix . "_tree_menu',\$(this).attr('href'));"; $result .= "\t\t\tSetCookie('" . $divIdPrefix . "_menu_name',\$(this).text());"; $result .= "\t}});"; $result .= "\ttree_menu_setNow(GetCookie('" . $divIdPrefix . "_tree_menu'),'" . $divIdPrefix . "_tree_menu');"; $result .= "</script>"; return $result; }
function replace_css_menu($items) { function hasSub($id_item, $items) { foreach ($items as $item) { if ($item->menu_item_parent && $item->menu_item_parent == $id_item) { return true; } } return false; } foreach ($items as $item) { if (hasSub($item->ID, $items)) { $item->classes[] = "dropdown"; } } return $items; }