當前位置: 首頁>>代碼示例>>PHP>>正文


PHP gpOutput::ResetMenuGlobals方法代碼示例

本文整理匯總了PHP中gpOutput::ResetMenuGlobals方法的典型用法代碼示例。如果您正苦於以下問題:PHP gpOutput::ResetMenuGlobals方法的具體用法?PHP gpOutput::ResetMenuGlobals怎麽用?PHP gpOutput::ResetMenuGlobals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gpOutput的用法示例。


在下文中一共展示了gpOutput::ResetMenuGlobals方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: OutputMenu

 /**
  * Output a navigation menu
  * @static
  */
 function OutputMenu($menu, $start_level, $source_menu = false)
 {
     global $page, $GP_MENU_LINKS, $GP_MENU_CLASS, $gp_menu, $gp_titles;
     if ($source_menu === false) {
         $source_menu =& $gp_menu;
     }
     $search = array('{$href_text}', '{$attr}', '{$label}', '{$title}');
     $replace = array();
     if (count($menu) == 0) {
         echo '<div class="emtpy_menu"></div>';
         //an empty <ul> is not valid xhtml
         gpOutput::ResetMenuGlobals();
         return;
     }
     //$GP_MENU_LINKS = '<a href="{$href_text}" {$attr}><span class="sub-t">{$label}</span></a>';
     //<a href="/rocky/index.php/Misson_&amp;_Principles" title="Misson &amp; Principles" >Misson &amp; Principles</a>
     $link_format = '<a href="{$href_text}" title="{$title}"{$attr}>{$label}</a>';
     if (!empty($GP_MENU_LINKS)) {
         $link_format = $GP_MENU_LINKS;
     }
     $result = array();
     $prev_level = $start_level;
     $page_title_full = common::GetUrl($page->title);
     $source_keys = array_keys($source_menu);
     $source_values = array_values($source_menu);
     $open = false;
     $li_count = array();
     //get parent page
     $parent_page = false;
     $parents = common::Parents($page->gp_index, $source_menu);
     if (count($parents)) {
         $parent_page = $parents[0];
     }
     $class = 'menu_top';
     if (!empty($GP_MENU_CLASS)) {
         $class = $GP_MENU_CLASS;
     }
     $result[] = '<ul class="' . $class . '">';
     foreach ($source_keys as $source_index => $menu_key) {
         $attr = $class = $attr_li = $class_li = '';
         $menu_info = $source_values[$source_index];
         $this_level = $menu_info['level'];
         //the next entry
         $next_info = false;
         if (isset($source_values[$source_index + 1])) {
             $next_info = $source_values[$source_index + 1];
         }
         //create link if in $menu
         if (isset($menu[$menu_key])) {
             //ordered or "indexed" classes
             if ($page->menu_css_ordered) {
                 for ($i = $prev_level; $i > $this_level; $i--) {
                     unset($li_count[$i]);
                 }
                 if (!isset($li_count[$this_level])) {
                     $li_count[$this_level] = 0;
                 } else {
                     $li_count[$this_level]++;
                 }
                 $class_li = 'li_' . $li_count[$this_level];
             }
             if ($page->menu_css_indexed) {
                 $class_li .= ' li_title_' . $menu_key;
             }
             //selected classes
             if ($this_level < $next_info['level']) {
                 $class .= ' haschildren';
             }
             if (isset($menu_info['url']) && ($menu_info['url'] == $page->title || $menu_info['url'] == $page_title_full)) {
                 $class .= ' selected';
                 $class_li .= ' selected_li';
             } elseif ($menu_key == $page->gp_index) {
                 $class .= ' selected';
                 $class_li .= ' selected_li';
             } elseif (in_array($menu_key, $parents)) {
                 $class .= ' childselected';
                 $class_li .= ' childselected_li';
             }
             if (!empty($class)) {
                 $attr = ' class="' . trim($class) . '"';
             }
             if (!empty($class_li)) {
                 $attr_li = ' class="' . trim($class_li) . '"';
             }
             //current is a child of the previous
             if ($this_level > $prev_level) {
                 if (!$open) {
                     $result[] = '<li' . $attr_li . '>';
                     //only needed if the menu starts below the start_level
                 }
                 while ($this_level > $prev_level) {
                     $result[] = '<ul>';
                     $result[] = '<li>';
                     $prev_level++;
                 }
                 array_pop($result);
//.........這裏部分代碼省略.........
開發者ID:rizub4u,項目名稱:gpEasy-CMS,代碼行數:101,代碼來源:gpOutput.php


注:本文中的gpOutput::ResetMenuGlobals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。