本文整理汇总了PHP中Default_Model_Menu::getTotalMenuArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Default_Model_Menu::getTotalMenuArray方法的具体用法?PHP Default_Model_Menu::getTotalMenuArray怎么用?PHP Default_Model_Menu::getTotalMenuArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Default_Model_Menu
的用法示例。
在下文中一共展示了Default_Model_Menu::getTotalMenuArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMenusWithChilds
public function getMenusWithChilds($menu_id)
{
$menu_model = new Default_Model_Menu();
$res = $menu_model->getTotalMenuArray();
$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["parent"] = $res[$i]['parent'];
$tmp["menuName"] = $res[$i]['menuName'];
$tmpMenuDataArr[$res[$i]['id']] = $tmp;
}
$emptyArr = array();
foreach ($tmpMenuArr as $key => $value) {
if ($value == 0 && !array_key_exists($value, $tmpArr)) {
$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)) {
$tmpArr[$key]['childs'][$c_key]['childs'][$tkey] = $tmpMenuDataArr[$tkey];
}
}
}
}
}
}
$childs_array = array();
if (array_key_exists($menu_id, $tmpArr)) {
$childs_array[] = $menu_id;
if (isset($tmpArr[$menu_id]['childs'])) {
foreach ($tmpArr[$menu_id]['childs'] as $chkey1 => $chvalue1) {
$childs_array[] = $chkey1;
if (isset($chvalue1['childs'])) {
foreach ($chvalue1['childs'] as $chkey2 => $chvalue2) {
$childs_array[] = $chkey2;
}
}
}
}
} else {
foreach ($tmpArr as $menuid => $menu_data) {
if (isset($tmpArr[$menuid]['childs'])) {
foreach ($tmpArr[$menuid]['childs'] as $chkey1 => $chvalue1) {
if ($chkey1 == $menu_id) {
$childs_array[] = $chkey1;
if (isset($chvalue1['childs'])) {
foreach ($chvalue1['childs'] as $chkey2 => $chvalue2) {
$childs_array[] = $chkey2;
}
}
}
}
}
}
}
return $childs_array;
}