当前位置: 首页>>代码示例>>PHP>>正文


PHP list_to_tree函数代码示例

本文整理汇总了PHP中list_to_tree函数的典型用法代码示例。如果您正苦于以下问题:PHP list_to_tree函数的具体用法?PHP list_to_tree怎么用?PHP list_to_tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了list_to_tree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __init

 protected function __init()
 {
     if (!session('member_id')) {
         header("location:" . __ROOT__ . "/Backend");
     }
     if (!session('menu_result')) {
         $Menu = M('menu');
         /*如果是系统管理员拥有所有权限*/
         if (session('username') == 'admin') {
             $menu_result = $Menu->where(array('status' => 1))->order('sort desc')->select();
         } else {
             $rules = session('rules');
             if ($rules != '') {
                 $menu_result = $Menu->where(array('status' => 1, 'id' => array('in', $rules)))->order('sort desc')->select();
             }
         }
         $menu_arr = array();
         foreach ($menu_result as $row) {
             $menu_arr[] = strtolower($row['url']);
         }
         $menu_arr[] = 'backend/base/file/uploadpicture';
         $menu_result = list_to_tree($menu_result);
         session('menu_result', $menu_result);
         session('menu_arr', $menu_arr);
     }
     if (session('username') != 'admin') {
         $url = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME);
         /* $action_name = strtolower(ACTION_NAME); */
         if ($url != 'backend/index/index' && !in_array($url, session('menu_arr'))) {
             $this->error('未授权的访问');
         }
     }
     $data['menu_result'] = session('menu_result');
     $this->assign($data);
 }
开发者ID:976112643,项目名称:manor,代码行数:35,代码来源:AdminController.class.php

示例2: index

 public function index()
 {
     $news = M("news")->select();
     $this->assign('news', $news);
     // $type=M("type")->select();
     // $this->assign('type',Tool::tree($type));
     Load('extend');
     //加载扩展方法
     $type = D('type');
     // $data['type'] = 'type';
     $list = $type->order('id asc')->select();
     //实现同级节点排序
     $list = list_to_tree($list, 'id', 'tid');
     //详细参数见手册
     // dump($list);
     $this->assign('type', $list);
     $data['typeid'] = $_GET["_URL_"][3];
     // dump($data);
     if (is_null($data['typeid'])) {
         # code...
         $this->assign('new', $news[0]);
         //dump($news[0]);
     } else {
         $new = M('news')->where($data)->select();
         $this->assign('new', $new[0]);
         // dump($new);
     }
     $this->display();
 }
开发者ID:xunice,项目名称:jstc,代码行数:29,代码来源:NewsAction.class.php

示例3: __autoload

 public function __autoload()
 {
     parent::__autoload();
     $this->product_type = list_to_tree(get_ability_cache());
     /* 获取缓存的分类属性转换为树状 */
     $this->first_step_view = array('36' => 'step_1_written', '37' => 'step_1_interpret', '56' => 'step_1_audio');
 }
开发者ID:976112643,项目名称:manor,代码行数:7,代码来源:BuyController.class.php

示例4: index

 public function index()
 {
     if (IS_POST) {
         $map = array();
         $_list = $this->Model->where($map)->order('sort asc')->getField('id,pid,name,title,icon,hide,status,sort');
         $option["hide"] = array(1 => '隐藏', 0 => '显示');
         $option["status"] = array(1 => '启用', 0 => '禁用');
         foreach ($_list as $list_key => $list_one) {
             foreach ($list_one as $list_one_key => $list_one_field) {
                 if ($option[$list_one_key] != '') {
                     $_list[$list_key][$list_one_key] = $option[$list_one_key][$list_one_field];
                 }
             }
             $operate_menu = '';
             if (Is_Auth('Admin/AuthRule/add')) {
                 $operate_menu = $operate_menu . "<a href='#' onclick=\"UpdateTabs('AuthRule','" . U('add', array('pid' => $_list[$list_key]['id'])) . "','','iconfont icon-add');\">新增子菜单</a>";
             }
             if (Is_Auth('Admin/AuthRule/edit')) {
                 $operate_menu = $operate_menu . "<a href='#' onclick=\"UpdateTabs('AuthRule','" . U('edit', array('id' => $_list[$list_key]['id'])) . "','','iconfont icon-edit');\">编辑</a>";
             }
             if (Is_Auth('Admin/AuthRule/del')) {
                 $operate_menu = $operate_menu . "<a href='#' onclick=\"Data_Remove('" . U('del', array('id' => $_list[$list_key]['id'])) . "','AuthRule_Data_List');\">删除</a>";
             }
             $_list[$list_key]['operate'] = $operate_menu;
         }
         $data = list_to_tree($_list, 'id', 'pid', 'children');
         $this->ajaxReturn($data);
     } else {
         $this->display();
     }
 }
开发者ID:hacklx,项目名称:koala-frame,代码行数:31,代码来源:AuthRuleController.class.php

示例5: index

 public function index()
 {
     if (IS_POST) {
         $map = array();
         $_list = $this->Model->where($map)->order('sort asc')->getField('id,title,status,sort');
         $op_status = R("Admin/Function/get_config", array("USERGROUP_STATUS_TYPE|status|title"));
         foreach ($op_status as $op_status_key => $op_status_one) {
             $option["status"][$op_status_one["status"]] = $op_status_one["title"];
         }
         foreach ($_list as $list_key => $list_one) {
             foreach ($list_one as $list_one_key => $list_one_field) {
                 if ($option[$list_one_key] != '') {
                     $_list[$list_key][$list_one_key] = $option[$list_one_key][$list_one_field];
                 }
             }
             $operate_menu = '';
             if (Is_Auth('Admin/AuthGroup/edit')) {
                 $operate_menu = $operate_menu . "<a href='#' onclick=\"Submit_Form('AuthGroup_Form','AuthGroup_Data_List','" . U('edit', array('id' => $_list[$list_key]['id'])) . "','','编辑数据','');\">编辑</a>";
             }
             if (Is_Auth('Admin/AuthGroup/del')) {
                 $operate_menu = $operate_menu . "<a href='#' onclick=\"Data_Remove('" . U('del', array('id' => $_list[$list_key]['id'])) . "','AuthGroup_Data_List');\">删除</a>";
             }
             $_list[$list_key]['operate'] = $operate_menu;
         }
         $data = list_to_tree($_list, 'id', 'pid', 'children');
         $this->ajaxReturn($data);
     } else {
         $this->display();
     }
 }
开发者ID:hacklx,项目名称:koala-frame,代码行数:30,代码来源:AuthGroupController.class.php

示例6: getTree

 /**
  * 获取分类树,指定分类则返回指定分类极其子分类,不指定则返回所有分类树
  * @param  integer $id    分类ID
  * @param  boolean $field 查询字段
  * @return array          分类树
  * @author 枫叶 <735579768@qq.com>
  */
 public function getTree($id = 0, $field = true)
 {
     /* 获取当前分类信息 */
     if ($id) {
         $info = $this->info($id);
         $id = $info['id'];
     }
     /* 获取所有分类 */
     $map = array('status' => array('gt', -1));
     $category_type = I('category_type');
     if (!empty($category_type)) {
         $map['category_type'] = $category_type;
     }
     $list = $this->field($field)->where($map)->order('status desc,sort asc,category_id asc')->select();
     $list = list_to_tree($list, $pk = 'category_id', $pid = 'pid', $child = '_', $root = $id);
     /* 获取返回数据 */
     if (isset($info)) {
         //指定分类则返回当前分类极其子分类
         $info['_'] = $list;
     } else {
         //否则返回所有分类
         $info = $list;
     }
     return $info;
 }
开发者ID:735579768,项目名称:Ainiku,代码行数:32,代码来源:CategoryModel.class.php

示例7: GetMenu

 public function GetMenu()
 {
     $menus = session('ADMIN_MENU_LIST');
     if (count($menus) != 999) {
         if (in_array(session(C('AUTH_KEY')), C('AUTH_ADMIN'))) {
             $map = array('is_hide' => 0, 'status' => 1);
         } else {
             $Auth = new Auth();
             $groups = $Auth->getGroups(session(C('AUTH_KEY')));
             $ids = array();
             foreach ($groups as $g) {
                 $ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
             }
             $ids = array_unique($ids);
             $map = array('id' => array('in', $ids), 'is_hide' => 0, 'status' => 1);
         }
         // 读取用户组所有权限规则
         $rules = M('AuthRule')->where($map)->field('id,pid,name,title,icon as iconCls')->order('sort asc')->select();
         // $rules = M('AuthRule')->where($map)->order('sort asc')->getField('id,pid,name,title as text');
         foreach ($rules as $rid => $rules_one) {
             $rules[$rid]['attributes'] = array("url" => U($rules_one['name']), "rule" => $rules_one['name']);
             $rules[$rid]['text'] = $rules_one['title'];
         }
         $menus = list_to_tree($rules, $pk = 'id', $pid = 'pid', 'children');
         session('ADMIN_MENU_LIST', '');
         session('ADMIN_MENU_LIST', $menus);
     }
     return $menus;
 }
开发者ID:cwcw,项目名称:cms,代码行数:29,代码来源:AdminController.class.php

示例8: fetchList

 public function fetchList()
 {
     $menuList = $this->order('sort')->select();
     $tree = list_to_tree($menuList);
     $list = tree_to_list($tree);
     return $list;
 }
开发者ID:yunzhiclub,项目名称:wemall,代码行数:7,代码来源:CustomMenuModel.class.php

示例9: winpop

 function winpop()
 {
     $menu = D("Node")->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('menu', popup_tree_menu($tree));
     $this->display();
 }
开发者ID:hongweipeng,项目名称:oa,代码行数:7,代码来源:NodeAction.class.php

示例10: getTree

 public function getTree($id = 0, $field = true, $condition = false, $is_tree = true)
 {
     $cache_key = 'category_tree_' . $id . serialize($field) . serialize($condition);
     if ($x = S($cache_key)) {
         return $x;
     }
     /* 获取当前分类信息 */
     if ($id) {
         $info = $this->info($id);
         $id = $info['id'];
     }
     /* 获取所有分类 */
     $map = array('status' => 1);
     if ($condition) {
         $map = array_merge($map, $condition);
     }
     $list = $this->field($field)->where($map)->order('sort, id')->select();
     if ($is_tree) {
         $list = list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_', $root = $id);
     } else {
         $list = $this->getRichInfo($list);
     }
     /* 获取返回数据 */
     if (isset($info)) {
         //指定分类则返回当前分类极其子分类
         $info['_'] = $list;
     } else {
         //否则返回所有分类
         $info = $list;
     }
     S($cache_key, $info);
     return $info;
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:33,代码来源:CategoryModel.class.php

示例11: toFormatTree

 public function toFormatTree($list, $title = 'title', $pk = 'id', $pid = 'pid', $root = 0)
 {
     $list = list_to_tree($list, $pk, $pid, '_child', $root);
     $this->formatTree = array();
     $this->_toFormatTree($list, 0, $title);
     return $this->formatTree;
 }
开发者ID:PHPKnife,项目名称:OneThink,代码行数:7,代码来源:TreeModel.class.php

示例12: index

 public function index()
 {
     $city_info = session('user_city');
     $city = $city_info['city_id'];
     $cbd = I('cbd', 0, 'intval');
     $price = I('price', 0, 'intval');
     $area = I('area', 0, 'intval');
     $shi = I('shi', 0, 'intval');
     $cbd_table_orignal = D('cbd')->get_cbd_table($city);
     $cbd_table = list_to_tree($cbd_table_orignal, 'id', 'pid', '_', $city);
     $price_table = C('HOUSE_PRICE_TABLE');
     $area_table = C('HOUSE_AREA_TABLE');
     $shi_table = C('HOUSE_HUXING_TABLE');
     $filter_menu = array('cbd' => $cbd == 0 ? $city_info['city_name'] : $cbd_table_orignal[abs($cbd)]['name'], 'price' => $price_table[$price], 'area' => $area_table[$area], 'shi' => $shi_table[$shi]);
     $common_url = array('cbd' => $cbd, 'price' => $price, 'area' => $area, 'shi' => $shi);
     $tree = array();
     foreach ($cbd_table as $k => $v) {
         $tree[$v['id']] = $v;
     }
     $this->assign('tree', $tree);
     $this->assign('price_table', $price_table);
     $this->assign('area_table', $area_table);
     $this->assign('shi_table', $shi_table);
     $this->assign('cbd_table', $tree);
     $this->assign('cbd_table_json', json_encode($tree));
     $this->assign('filter_menu', $filter_menu);
     $this->assign('common_url', $common_url);
     $this->display('Widget/filter');
 }
开发者ID:smartymoon,项目名称:e-anjia,代码行数:29,代码来源:FilterWidget.class.php

示例13: getMenu

 public function getMenu()
 {
     $top_menu = $result = array();
     $data = $this->all()->toArray();
     $data = list_to_tree($data);
     foreach ($data as $key => $value) {
         $top_menu[$key]['id'] = $value['id'];
         $top_menu[$key]['title'] = $value['title'];
         $top_menu[$key]['name'] = $value['name'];
         $top_menu[$key]['icon'] = $value['icon'];
         $result[$key]['id'] = $value['name'];
         if (!empty($value['_child'])) {
             foreach ($value['_child'] as $_key => $_value) {
                 $result[$key]['menu'][$_key]['text'] = $_value['title'];
                 if (!empty($_value['_child'])) {
                     foreach ($_value['_child'] as $k => $v) {
                         if (0 === $_key && 0 === $k) {
                             $result[$key]['homePage'] = $v['name'];
                             $top_menu[$key]['homePage'] = true;
                             $result[$key]['menu'][$_key]['items'][$k]['closeable'] = false;
                         }
                         $result[$key]['menu'][$_key]['items'][$k]['id'] = $v['name'];
                         $result[$key]['menu'][$_key]['items'][$k]['text'] = $v['title'];
                         $result[$key]['menu'][$_key]['items'][$k]['href'] = url($v['href']);
                     }
                 }
             }
         }
     }
     return array('top_menu' => $top_menu, 'left_menu' => $result);
 }
开发者ID:vzina,项目名称:blog,代码行数:31,代码来源:Menu.php

示例14: node

 public function node()
 {
     $node_model = M("Node");
     if (!empty($_POST['eq_pid'])) {
         $eq_pid = $_POST['eq_pid'];
     } else {
         $eq_pid = $node_model->where('pid=0')->order('sort asc')->getField('id');
     }
     //dump($node_model -> select());
     $node_list = $node_model->order('sort asc')->select();
     $node_list = tree_to_list(list_to_tree($node_list, $eq_pid));
     $node_list = rotate($node_list);
     //dump($node_list);
     $node_list = implode(",", $node_list['id']) . ",{$eq_pid}";
     $where['id'] = array('in', $node_list);
     $menu = $node_model->field('id,pid,name,url')->where($where)->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('eq_pid', $eq_pid);
     $list = tree_to_list($tree);
     $this->assign('node_list', $list);
     //$this->assign('menu',sub_tree_menu($list));
     $role = M("Role")->order('sort asc')->select();
     $this->assign('list', $role);
     $list = $node_model->where('pid=0')->order('sort asc')->getField('id,name');
     $this->assign('groupList', $list);
     $this->display();
 }
开发者ID:2ger,项目名称:trunk,代码行数:27,代码来源:RoleAction.class.php

示例15: index

 /**
  *分类信息频道页
  *@date 2010-4-29
  *@time 上午09:58:27
  */
 function index()
 {
     //分类信息频道页
     $this->chk_cid();
     $this->ads('3', 'channel', '1');
     $arctype = D("Arctype");
     $kinfo = '';
     //标题后面附加的城市后缀
     if ($this->pcid) {
         if ($this->pcid > 1000) {
             $kinfo = $this->cgroup[$this->pcid]['name'];
             $this->assign('city_group', $this->cgroup[$this->pcid]['name']);
         } else {
             $kinfo = get_cityname($this->pcid);
         }
         $this->assign("cityname", $kinfo);
     }
     $data = $arctype->where("topid=1 AND ishidden=0")->order("id asc")->findAll();
     $list = list_to_tree($data, 'id', 'reid', '_son', 1);
     $this->assign('list', $list);
     //dump($list);
     $info = $arctype->where('id=1')->find();
     $this->assign('info', $info);
     $group = $this->_get_group('hot', "0,5");
     $this->assign('group', $group);
     $page = array();
     $page['title'] = empty($info['seotitle']) ? $kinfo . ' ' . $info['typename'] . ' - BeingfunChina 缤纷中国' : $kinfo . ' ' . $info['seotitle'] . ' - BeingfunChina 缤纷中国';
     $page['keywords'] = empty($info['keywords']) ? $info['typename'] : $info['keywords'];
     $page['description'] = empty($info['description']) ? $info['typename'] : $info['description'];
     $this->assign('page', $page);
     $this->assign('city_type', $this->_get_tree(1000));
     $this->assign('classifieds_type', $this->_get_tree(1));
     $this->display();
 }
开发者ID:putera99,项目名称:iic-classified,代码行数:39,代码来源:ClassifiedsAction.class.php


注:本文中的list_to_tree函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。