当前位置: 首页>>代码示例>>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;未经允许,请勿转载。