本文整理汇总了PHP中gpOutput::MenuReduce_Expand方法的典型用法代码示例。如果您正苦于以下问题:PHP gpOutput::MenuReduce_Expand方法的具体用法?PHP gpOutput::MenuReduce_Expand怎么用?PHP gpOutput::MenuReduce_Expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpOutput
的用法示例。
在下文中一共展示了gpOutput::MenuReduce_Expand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CustomMenu
/**
* @param string $arg comma seperated argument list: $top_level, $bottom_level, $options
* $top_level (int) The upper level of the menu to show, if deeper (in this case > ) than 0, only the submenu is shown
* $bottom_level (int) The lower level of menu to show
* $expand_level (int) The upper level from where to start expanding sublinks, if -1 no expansion
* $expand_all (int) Whether or not to expand all levels below $expand_level (defaults to 0)
* $source_menu (string) Which menu to use
*
*/
static function CustomMenu($arg, $title = false)
{
global $page, $gp_index;
//from output functions
if (is_array($title)) {
$title = $page->title;
}
$title_index = false;
if (isset($gp_index[$title])) {
$title_index = $gp_index[$title];
}
$args = explode(',', $arg);
$args += array(0 => 0, 1 => 3, 2 => -1, 3 => 1, 4 => '');
//defaults
list($top_level, $bottom_level, $expand_level, $expand_all, $source_menu) = $args;
//get menu array
$source_menu_array = gpOutput::GetMenuArray($source_menu);
//reduce array to $title => $level
$menu = array();
foreach ($source_menu_array as $temp_key => $titleInfo) {
if (!isset($titleInfo['level'])) {
break;
}
$menu[$temp_key] = $titleInfo['level'];
}
//Reduce for expansion
//first reduction
//message('expand level: '.$expand_level);
if ((int) $expand_level >= 1) {
if ($expand_all) {
$menu = gpOutput::MenuReduce_ExpandAll($menu, $expand_level, $title_index, $top_level);
} else {
$menu = gpOutput::MenuReduce_Expand($menu, $expand_level, $title_index, $top_level);
}
}
//Reduce if $top_level >= 0
//second reduction
if ((int) $top_level > 0) {
//echo 'top level: '.$top_level;
//message('top: '.$top_level);
$menu = gpOutput::MenuReduce_Top($menu, $top_level, $title_index);
} else {
$top_level = 0;
}
//Reduce by trimming off titles below $bottom_level
// last reduction : in case the selected link is below $bottom_level
if ($bottom_level > 0) {
//message('bottom: '.$bottom_level);
$menu = gpOutput::MenuReduce_Bottom($menu, $bottom_level);
}
gpOutput::OutputMenu($menu, $top_level, $source_menu_array);
}