本文整理匯總了PHP中sapp_Global::mobile_parent_menus方法的典型用法代碼示例。如果您正苦於以下問題:PHP sapp_Global::mobile_parent_menus方法的具體用法?PHP sapp_Global::mobile_parent_menus怎麽用?PHP sapp_Global::mobile_parent_menus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sapp_Global
的用法示例。
在下文中一共展示了sapp_Global::mobile_parent_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;
}