本文整理汇总了PHP中tree::list_to_tree方法的典型用法代码示例。如果您正苦于以下问题:PHP tree::list_to_tree方法的具体用法?PHP tree::list_to_tree怎么用?PHP tree::list_to_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::list_to_tree方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAdminMenu
/**
* 获取模块菜单
* @author jry <598821125@qq.com>
*/
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);
}
示例2: index
/**
* 默认方法
* @author jry <598821125@qq.com>
*/
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();
}
示例3: getTree
/**
* 获取所有导航
* @author jry <598821125@qq.com>
*/
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);
}
示例4: getAllMenu
/**
* 获取所有模块菜单
* @param string $addon_dir
* @author jry <598821125@qq.com>
*/
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;
}
示例5: getAllMenu
/**
* 获取所有模块菜单
* @param string $addon_dir
* @author jry <598821125@qq.com>
*/
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;
}