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


PHP gpOutput::MenuReduce_Sub方法代碼示例

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


在下文中一共展示了gpOutput::MenuReduce_Sub方法的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_Sub方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。