当前位置: 首页>>代码示例>>PHP>>正文


PHP gpOutput::MenuReduce_Group方法代码示例

本文整理汇总了PHP中gpOutput::MenuReduce_Group方法的典型用法代码示例。如果您正苦于以下问题:PHP gpOutput::MenuReduce_Group方法的具体用法?PHP gpOutput::MenuReduce_Group怎么用?PHP gpOutput::MenuReduce_Group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gpOutput的用法示例。


在下文中一共展示了gpOutput::MenuReduce_Group方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: MenuReduce_Expand

 static function MenuReduce_Expand($menu, $expand_level, $curr_title_key, $top_level)
 {
     $result_menu = array();
     $submenu = array();
     //if $top_level is set, we need to take it into consideration
     $expand_level = max($expand_level, $top_level);
     //titles higher than the $expand_level
     $good_titles = array();
     foreach ($menu as $title_key => $level) {
         if ($level < $expand_level) {
             $good_titles[$title_key] = $level;
         }
     }
     if (isset($menu[$curr_title_key])) {
         $curr_level = $menu[$curr_title_key];
         $good_titles[$curr_title_key] = $menu[$curr_title_key];
         //titles below selected
         // cannot use $submenu because $foundTitle may require titles above the $submenu threshold
         $foundTitle = false;
         foreach ($menu as $title_key => $level) {
             if ($title_key == $curr_title_key) {
                 $foundTitle = true;
                 continue;
             }
             if (!$foundTitle) {
                 continue;
             }
             if ($curr_level + 1 == $level) {
                 $good_titles[$title_key] = $level;
             } elseif ($curr_level < $level) {
                 continue;
             } else {
                 break;
             }
         }
         //reduce the menu to the current group
         $submenu = gpOutput::MenuReduce_Group($menu, $curr_title_key, $expand_level, $curr_level);
         //message('group: ('.count($submenu).') '.showArray($submenu));
         // titles even-with selected title within group
         $even_temp = array();
         $even_group = false;
         foreach ($submenu as $title_key => $level) {
             if ($title_key == $curr_title_key) {
                 $even_group = true;
                 $good_titles = $good_titles + $even_temp;
                 continue;
             }
             if ($level < $curr_level) {
                 if ($even_group) {
                     $even_group = false;
                     //done
                 } else {
                     $even_temp = array();
                     //reset
                 }
             }
             if ($level == $curr_level) {
                 if ($even_group) {
                     $good_titles[$title_key] = $level;
                 } else {
                     $even_temp[$title_key] = $level;
                 }
             }
         }
         // titles above selected title, deeper than $expand_level, and within the group
         gpOutput::MenuReduce_Sub($good_titles, $submenu, $curr_title_key, $expand_level, $curr_level);
         gpOutput::MenuReduce_Sub($good_titles, array_reverse($submenu), $curr_title_key, $expand_level, $curr_level);
     }
     //rebuild $good_titles in order
     // array_intersect_assoc() would be useful here, it's php4.3+ and there's no indication if the order of the first argument is preserved
     foreach ($menu as $title => $level) {
         if (isset($good_titles[$title])) {
             $result_menu[$title] = $level;
         }
     }
     return $result_menu;
 }
开发者ID:Bomberus,项目名称:gpEasy-CMS,代码行数:77,代码来源:gpOutput.php


注:本文中的gpOutput::MenuReduce_Group方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。