/** * 获取模块菜单 * @author jry <*****@*****.**> */ public function getAdminMenu($module_name = MODULE_NAME) { // 获取模块左侧导航 $where['name'] = $module_name; $module_info = $this->where($where)->find(); $_side_menu_list = json_decode($module_info['admin_menu'], true); // 转换成树结构 $tree = new tree(); return $tree->list_to_tree($_side_menu_list); }
/** * 默认方法 * @author jry <*****@*****.**> */ public function index() { // 获取所有模块信息及后台菜单 $con['status'] = 1; $system_module_list = D('Module')->where($con)->order('sort asc, id asc')->select(); $tree = new tree(); $menu_list = array(); foreach ($system_module_list as $key => &$module) { $temp = $tree->list_to_tree(json_decode($module['admin_menu'], true)); $menu_list[$module['name']] = $temp[0]; $menu_list[$module['name']]['id'] = $module['id']; $menu_list[$module['name']]['name'] = $module['name']; } // 如果模块顶级菜单配置了top字段则移动菜单至top所指的模块下边 foreach ($menu_list as $key => &$value) { if ($value['top']) { if ($menu_list[$value['top']]) { $menu_list[$value['top']]['_child'] = array_merge($menu_list[$value['top']]['_child'], $value['_child']); unset($menu_list[$key]); } } } // 获取快捷链接 $con = array(); $con['status'] = 1; $link_list = D('Link')->where($con)->order('sort asc, id asc')->select(); foreach ($link_list as $key => &$value) { if (!stristr($value['url'], 'http://') && !stristr($value['url'], 'https://')) { $value['url'] = U($value['url']); } } $link_list = $tree->list_to_tree($link_list); // 模板变量赋值 $this->assign('_link_list', $link_list); // 后台快捷链接 $this->assign('_menu_list', $menu_list); // 后台左侧菜单 $this->assign('meta_title', "首页"); $this->display(); }
/** * 获取所有导航 * @author jry <*****@*****.**> */ public function getTree() { $con = array(); $con['status'] = 1; $link_list = $this->where($con)->order('sort asc, id asc')->select(); foreach ($link_list as $key => &$value) { if (!stristr($value['url'], 'http://') && !stristr($value['url'], 'https://')) { $value['url'] = U($value['url']); } } $tree = new tree(); return $tree->list_to_tree($link_list); }
/** * 获取所有模块菜单 * @param string $addon_dir * @author jry <*****@*****.**> */ public function getAllMenu() { $menu_list = S('MENU_LIST'); if (!$menu_list) { $con['status'] = 1; $system_module_list = $this->where($con)->order('sort asc, id asc')->select(); $tree = new tree(); $menu_list = array(); foreach ($system_module_list as $key => &$module) { $temp = $tree->list_to_tree(json_decode($module['admin_menu'], true)); $menu_list[$module['name']] = $temp[0]; $menu_list[$module['name']]['id'] = $module['id']; $menu_list[$module['name']]['name'] = $module['name']; } // 如果模块顶级菜单配置了top字段则移动菜单至top所指的模块下边 foreach ($menu_list as $key => &$value) { if ($value['top']) { if ($menu_list[$value['top']]) { $menu_list[$value['top']]['_child'] = array_merge($menu_list[$value['top']]['_child'], $value['_child']); unset($menu_list[$key]); } } } S('MENU_LIST', $menu_list, 3600); // 缓存配置 } return $menu_list; }
/** * 获取所有模块菜单 * @param string $addon_dir * @author jry <*****@*****.**> */ public function getAllMenu() { $uid = is_login(); $user_group = D('Admin/Access')->getFieldByUid($uid, 'group'); // 获得当前登录用户信息 $group_info = D('Admin/Group')->find($user_group); $group_auth = json_decode($group_info['menu_auth'], true); // 获得当前登录用户所属部门的权限列表 // 获取所有菜单 $menu_list = S('MENU_LIST_' . $uid); if (!$menu_list || APP_DEBUG === true) { $con['status'] = 1; $system_module_list = $this->where($con)->order('sort asc, id asc')->select(); $tree = new tree(); $menu_list = array(); foreach ($system_module_list as $key => &$module) { $menu = json_decode($module['admin_menu'], true); $temp = $tree->list_to_tree($menu); $menu_list[$module['name']] = $temp[0]; $menu_list[$module['name']]['id'] = $module['id']; $menu_list[$module['name']]['name'] = $module['name']; } S('MENU_LIST_' . $uid, $menu_list, 3600); // 缓存配置 } return $menu_list; }