author = "Matt Larrabee"; $this->created_date = "7/24/09"; $this->content_icon = "cms_mod_menu_icon.gif"; } function form() { $api = new API(); //load menu content $item = $api->get_page_item_instance($this->instance, true, $this->content_date); //load page specific content $page_instance = $api->get_page_item_instance_id($item["item_id"]); $menu = $api->get_item_instance($page_instance, true, $this->content_date); //*** GET menu pages *** $pages = array(); array_push($pages, new Option(" Full Menu","xfullx")); array_push($pages, new Option(" Current Section","xSectionx")); array_push($pages, new Option(" Current Page","x1x")); array_push($pages, new Option(" Parent Page","x2x")); array_push($pages, new Option(" Grandparent Page","x3x")); array_push($pages, new Option(" Great Grandparent Page","x4x")); $level = 0; $list_items = explode("<>",html_entity_decode($menu['menu_html'], ENT_QUOTES)); for($i=0;$i 1) { $depth = $vars[0]; $link = $vars[1]; $page = str_replace("'","",$vars[2]); array_push($pages,new Option($page,$link)); } } echo "

"; usort($pages, array($api, "option_sort")); $this->form->createSelect("cnt_menu_base_page_".$this->instance, $item["base_page"], "Base Page", false, "", $pages); echo "

"; echo "

"; echo ""; echo ""; echo ""; echo ""; echo "

"; } function update() { $children = "no"; $inp = $this->form->get("cnt_menu_children_".$this->instance); if($inp->checked) { $children = "yes"; } $grandchildren = "no"; $inp = $this->form->get("cnt_menu_grandchildren_".$this->instance); if($inp->checked) { $grandchildren = "yes"; } $siblings = "no"; $inp = $this->form->get("cnt_menu_siblings_".$this->instance); if($inp->checked) { $siblings = "yes"; } $expand_current = "no"; $inp = $this->form->get("cnt_menu_expand_current_".$this->instance); if($inp->checked) { $expand_current = "yes"; } $args = array(); $args["base_page"] = $this->form->getValue("cnt_menu_base_page_".$this->instance); $args["show_children"] = $children; $args["show_grandchildren"] = $grandchildren; $args["show_siblings"] = $siblings; $args["expand_current"] = $expand_current; $api = new API(); $api->update_page_item_values($this->instance, $args); } function display($c_item=false) { $api = new API(); //get menu id $page = $api->get_item_instance($this->pageID, $this->preview, $this->content_date); if($page) { $current_page = $page['permalink']; } //load menu content $item = $api->get_page_item_instance($this->instance, $this->preview, $this->content_date); if($c_item) { $item = $c_item; } //load page specific content $page_instance = $api->get_page_item_instance_id($item["item_id"]); $menu = $api->get_item_instance($page_instance, $this->preview, $this->content_date); //print_r($item); $depth_arr = array(); //Display Menu $level = 0; $startShowing = false; $baseDepth = -1; $part = false; $current_parent = "-1"; $base_parent = "-1"; $last_parent = ""; $last_depth = -1; $runner = 0; $list_items = explode("<>",html_entity_decode($menu['menu_html'], ENT_QUOTES)); $depth_arr = new treeItem("base","", -1,"","",""); if($item["base_page"] == "xSectionx") { $section = ""; $sec_split = explode("/", htmlentities($_SERVER["REQUEST_URI"], ENT_QUOTES)); if(count($sec_split) > 1) { $section = "/".htmlentities($sec_split[1], ENT_QUOTES)."/"; } $item["base_page"] = $section; } if($item["base_page"] == "x1x") { $section = ""; $sec_split = explode("/", htmlentities($_SERVER["REQUEST_URI"], ENT_QUOTES)); if(count($sec_split) > 1) { for($i=1;$i 2) { for($i=1;$i 3) { for($i=1;$i 4) { for($i=1;$i 1) { $depth = $vars[0]; $link = $vars[1]; $pagel = $vars[2]; $window = ""; if(isset($vars[3])) { if(trim($vars[3]) == "blank") { $window = "target='_blank'"; } } $depth_arr->addChildAt(new treeItem($pagel,$link,$depth,$window, str_replace(array(" "),array("_"),$this->content_name), $runner),$depth); $runner++; } } //echo "SECTION: ".$section; echo ""; } } class treeItem { var $children; var $page; var $link; var $depth; var $window; var $menu; var $spot; var $section; function treeItem($page,$link, $depth, $window, $menu, $spot) { $this->children = array(); $this->page = $page; $this->link = $link; $this->depth = $depth; $this->window = $window; $this->menu = $menu; $this->spot = $spot; } function addChild($child) { array_push($this->children,$child); } function addChildAt($child, $depth) { $this->getChild($depth)->addChild($child); } function &getChild($depth) { if($this->depth == ($depth-1) || count($this->children) == 0) { return $this; } else { return $this->children[count($this->children) - 1]->getChild($depth); } } function showTree() { } function lastChild() { return $this->children[count($this->children)-1]; } function currentNode($currentPage) { $nd = explode("/",$this->link); $cpage = $nd[count($nd)-1]; if($nd[count($nd)-1] == "") { $cpage = $nd[count($nd)-2]; } //echo "TEST: ".htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES)." - ".$this->link; if($cpage == $currentPage && strstr(htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES), $this->link)) { return true; } else if(count($this->children) == 0) { return false; } else { foreach($this->children as $child) { if($child->currentNode($currentPage)) { return true; } } return false; } } function printTree($base,$show_children,$show_grandchildren,$show_siblings,$current_page, $expand_current ,$print=false, $page_path="") { //echo "PP: ".$page_path.":"; $print_children = false; if($this->link == $base) { $print_children = true; } if($show_siblings) { foreach($this->children as $child) { if($child->link == $base) { $print_children = true; } } } if($print) { if($expand_current) { if(count($this->children) > 0) { if($this->currentNode($current_page)) { $base = $this->link; $show_children = true; } else if($this->link == "/".$current_page || $this->link == "/".$current_page."/") { $show_children = true; } } } echo "
  • spot." "; $link_test = explode("/",$this->link); $mlink = $link_test[count($link_test)-1]; if($mlink == "") { $mlink = $link_test[count($link_test)-2]; } if($mlink == $current_page) { $cls .= "current "; } if($show_children) { $cls .= "expanded "; } else if(count($this->children) > 0) { $cls .= "has_children "; } if(strstr(htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES),"/".$mlink."/") && $mlink != $current_page) { $cls .= "is_parent "; if($expand_current) { $cls .= "expanded "; $show_children=true; } } if($cls != "") { echo "class='".$cls."'"; } echo ">window.">".$this->page.""; if(count($this->children) > 0 && $show_children) { echo "
      "; for($t=0;$tchildren);$t++) { $tr = $this->children[$t]; $tr->printTree($base,$show_grandchildren,$show_grandchildren,$show_siblings, $current_page, $expand_current, $print, $page_path); } echo "
    "; } echo "
  • "; } else if($print_children) { for($t=0;$tchildren);$t++) { $tr = $this->children[$t]; $tr->printTree($base,$show_grandchildren,$show_grandchildren,$show_siblings, $current_page, $expand_current, true, $page_path); } } else { for($t=0;$tchildren);$t++) { $tr = $this->children[$t]; $tr->printTree($base,$show_grandchildren,$show_grandchildren,$show_siblings, $current_page, $expand_current, $print, $page_path); } } } } ?> Online Services | Reliance Bank