本文整理汇总了PHP中sapp_Global::mobile_child_menus方法的典型用法代码示例。如果您正苦于以下问题:PHP sapp_Global::mobile_child_menus方法的具体用法?PHP sapp_Global::mobile_child_menus怎么用?PHP sapp_Global::mobile_child_menus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sapp_Global
的用法示例。
在下文中一共展示了sapp_Global::mobile_child_menus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getgroupmenu_service
/**
* This function is used as helper function for services to build menu.
* @param Integer $role_id = id of role
* @param Integer $group_id = id of group
* @return Array Array of menu items,privileges etc.
*/
public function getgroupmenu_service($group_id, $role_id)
{
$default_parent_menu = sapp_Global::mobile_parent_menus();
$default_child_menu = sapp_Global::mobile_child_menus();
$res = $this->getMenuArray($role_id, $group_id);
$tmpArr = array();
$tmpMenuArr = array();
$tmpMenuDataArr = array();
for ($i = 0; $i < sizeof($res); $i++) {
$tmpMenuArr[$res[$i]['id']] = $res[$i]['parent'];
$tmp = array();
$tmp['id'] = $res[$i]['id'];
$tmp["menuName"] = $res[$i]['menuName'];
$tmpMenuDataArr[$res[$i]['id']] = $tmp;
}
/**
** prepare an array with parent and second level menus - $tmpArr
**/
$emptyArr = array();
foreach ($tmpMenuArr as $key => $value) {
if ($value == 0 && !array_key_exists($value, $tmpArr) && in_array($key, $default_parent_menu)) {
$tmpArr[$key] = $emptyArr;
$tmpArr[$key] = $tmpMenuDataArr[$key];
} else {
if (array_key_exists($value, $tmpArr) && !array_key_exists($key, $tmpArr[$value])) {
$tmpArr[$value]['childs'][$key] = $tmpMenuDataArr[$key];
}
}
}
foreach ($tmpArr as $key => $value_arr) {
if (is_array($value_arr)) {
if (isset($value_arr['childs']) && is_array($value_arr['childs'])) {
foreach ($value_arr['childs'] as $c_key => $ch_value) {
foreach ($tmpMenuArr as $tkey => $tvalue) {
if ($tvalue == $c_key && !array_key_exists($tkey, $tmpArr) && in_array($tkey, $default_child_menu)) {
$tmpArr[$key]['childs'][$tkey] = $tmpMenuDataArr[$tkey];
}
}
}
}
}
}
//end of foreach.
foreach ($tmpArr as $key => $value_arr) {
if (is_array($value_arr)) {
if (isset($value_arr['childs']) && is_array($value_arr['childs'])) {
$new_childs = array();
foreach ($value_arr['childs'] as $c_key => $ch_value) {
if (in_array($c_key, $default_child_menu)) {
$new_childs[$c_key] = $ch_value;
}
}
$tmpArr[$key]['childs'] = $new_childs;
}
}
}
//end of foreach.
return $tmpArr;
}