コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: NewsAction.class.php プロジェクト: xunice/jstc
 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();
 }
コード例 #3
0
 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');
 }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
 /**
  * 获取分类树,指定分类则返回指定分类极其子分类,不指定则返回所有分类树
  * @param  integer $id    分类ID
  * @param  boolean $field 查询字段
  * @return array          分类树
  * @author 枫叶 <*****@*****.**>
  */
 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;
 }
コード例 #7
0
ファイル: AdminController.class.php プロジェクト: cwcw/cms
 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;
 }
コード例 #8
0
 public function fetchList()
 {
     $menuList = $this->order('sort')->select();
     $tree = list_to_tree($menuList);
     $list = tree_to_list($tree);
     return $list;
 }
コード例 #9
0
ファイル: NodeAction.class.php プロジェクト: hongweipeng/oa
 function winpop()
 {
     $menu = D("Node")->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('menu', popup_tree_menu($tree));
     $this->display();
 }
コード例 #10
0
 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;
 }
コード例 #11
0
ファイル: TreeModel.class.php プロジェクト: PHPKnife/OneThink
 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;
 }
コード例 #12
0
 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');
 }
コード例 #13
0
ファイル: Menu.php プロジェクト: vzina/blog
 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);
 }
コード例 #14
0
ファイル: RoleAction.class.php プロジェクト: 2ger/trunk
 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();
 }
コード例 #15
0
 /**
  *分类信息频道页
  *@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();
 }
コード例 #16
0
 public function getMenuList()
 {
     $rootId = $this->rootId === null ? 0 : $this->rootId;
     $level = $this->level === null ? 1 : $this->level;
     $menuList = $this->getList($rootId, $level);
     $menuList = list_to_tree($menuList, $pk = 'id', $pid = 'pid', $child = '_child', $rootId);
     return $menuList;
 }
コード例 #17
0
 public function _before_add()
 {
     $Group = D('Mrole');
     //查找满足条件的列表数据
     $classTree = $Group->field('id,name,pid')->select();
     $list = list_to_tree($classTree, 'id', 'pid', '_child', 0);
     $this->assign('list', $list);
 }
コード例 #18
0
 public function getTree($id = 0, $field = true)
 {
     /* 获取所有分类 */
     $map['token'] = $id;
     $list = $this->field($field)->where($map)->order('sort')->select();
     $list = list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_');
     return $list;
 }
コード例 #19
0
ファイル: CompanyModel.class.php プロジェクト: waqt/kdweb
 public function nodeList()
 {
     $nodes = $this->order("sort desc")->select();
     $list = list_to_tree($nodes, 'id', 'pid');
     $nodes = array();
     tree_to_array($list, $nodes);
     return $nodes;
 }
コード例 #20
0
 public function index()
 {
     $widget['date'] = true;
     $this->assign("widget", $widget);
     $this->assign('user_id', get_user_id());
     $auth = $this->config['auth'];
     $this->assign('auth', $auth);
     if ($auth['admin']) {
         $node = D("Dept");
         $dept_id = get_dept_id();
         $dept_name = get_dept_name();
         $menu = array();
         $dept_menu = $node->field('id,pid,name')->where("is_del=0")->order('sort asc')->select();
         $dept_tree = list_to_tree($dept_menu, $dept_id);
         $count = count($dept_tree);
         if (empty($count)) {
             /*获取部门列表*/
             $html = '';
             $html = $html . "<option value='{$dept_id}'>{$dept_name}</option>";
             $this->assign('dept_list', $html);
             /*获取人员列表*/
             $where['dept_id'] = array('eq', $dept_id);
             $emp_list = D("User")->where($where)->getField('id,name');
             $this->assign('emp_list', $emp_list);
         } else {
             /*获取部门列表*/
             $this->assign('dept_list', select_tree_menu($dept_tree));
             $dept_list = tree_to_list($dept_tree);
             $dept_list = rotate($dept_list);
             $dept_list = $dept_list['id'];
             /*获取人员列表*/
             $where['dept_id'] = array('in', $dept_list);
             $emp_list = D("User")->where($where)->getField('id,name');
             $this->assign('emp_list', $emp_list);
         }
     }
     $map = $this->_search();
     if ($auth['admin']) {
         if (empty($map['dept_id'])) {
             if (!empty($dept_list)) {
                 $map['dept_id'] = array('in', array_merge($dept_list, array($dept_id)));
             } else {
                 $map['dept_id'] = array('eq', $dept_id);
             }
         }
     } else {
         $map['user_id'] = get_user_id();
     }
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($map);
     }
     $model = D("WorkLog");
     if (!empty($model)) {
         $this->_list($model, $map);
     }
     $this->display();
 }
コード例 #21
0
ファイル: DutyAction.class.php プロジェクト: yunsite/smeoa
 public function index()
 {
     $node = M("Duty");
     $menu = array();
     $menu = $node->field('id,name')->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('menu', sub_tree_menu($tree));
     $this->display();
 }
コード例 #22
0
 public function winpop()
 {
     $node = M("MaterialFolder");
     $menu = array();
     $menu = $node->where($where)->field('id,pid,name')->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('menu', popup_tree_menu($tree));
     $this->display();
 }
コード例 #23
0
ファイル: _Init.php プロジェクト: cjango/cwms
 /**
  * 可以分权限展示的菜单返回
  * @return array
  */
 private final function _getMenus()
 {
     $menus = session('system_menu_list');
     if (empty($menus)) {
         $where = ['hide' => 0, 'status' => 1];
         // 当前用户不是超级用户,要做权限验证
         $adminUsers = Config::get('administrator');
         if (!in_array(UID, $adminUsers)) {
             $where['id'] = ['in', Auth::getMenuIds(UID)];
         }
         // 找到有权限的菜单的ID
         $menus = Db::name('menu')->where($where)->order('sort asc,id asc')->field('id,pid,title,icon,url,divider')->select();
         $menus = list_to_tree($menus);
         session('system_menu_list', $menus);
     }
     $menu = [];
     // 当进入二级菜单的时候,主菜单高亮
     foreach ($menus as $key => $item) {
         $menu['MAIN_MENU'][$key]["id"] = $item['id'];
         $menu['MAIN_MENU'][$key]["title"] = $item['title'];
         $menu['MAIN_MENU'][$key]["icon"] = $item['icon'];
         $menu['MAIN_MENU'][$key]["url"] = $item['url'];
         $menu['MAIN_MENU'][$key]["divider"] = $item['divider'];
         if (strtolower(CONTROLLER_NAME . '/' . ACTION_NAME) == strtolower($item['url'])) {
             $menu['MAIN_MENU'][$key]['class'] = 'active';
             $mKey = $key;
         }
     }
     $map['pid'] = ['neq', 0];
     $map['url'] = CONTROLLER_NAME . '/' . ACTION_NAME;
     $map['status'] = 1;
     $parent_menu = Db::name('menu')->where($map)->field('id,pid')->find();
     if ($parent_menu) {
         $nav = Db::name('menu')->find($parent_menu['pid']);
         if ($nav['pid']) {
             $nav = Db::name('menu')->find($nav['pid']);
         }
         foreach ($menu['MAIN_MENU'] as $key => $item) {
             if ($item['id'] == $nav['id']) {
                 $menu['MAIN_MENU'][$key]['class'] = 'active';
                 $mKey = $key;
             }
         }
         $menu['SUB_TITLE'] = $menus[$mKey]['title'];
         if (isset($menus[$mKey]['_child'])) {
             $menu['SUB_MENU'] = $menus[$mKey]['_child'];
             // 二级菜单高亮
             foreach ($menu['SUB_MENU'] as $key => $item) {
                 unset($menu['SUB_MENU'][$key]['_child']);
                 if ($item['id'] == $parent_menu['id'] || $item['id'] == $parent_menu['pid']) {
                     $menu['SUB_MENU'][$key]['class'] = 'active';
                 }
             }
         }
     }
     return $menu;
 }
コード例 #24
0
 /**
  *获取栏目列表
  *@date 2010-6-14
  *@time 上午09:29:47
  */
 function arctype()
 {
     //获取栏目列表
     $old = M("Arctype");
     $list = $old->where("topid=1000")->field('id,reid,typename')->order("id asc")->findAll();
     $news = list_to_tree($list, 'id', 'reid', '_son', '1000');
     //dump($news);
     $this->assign('news', $news);
     $this->display();
 }
コード例 #25
0
ファイル: UserTagModel.class.php プロジェクト: hongweipeng/oa
 function del_tag($tag_id)
 {
     $model = M("UserTag");
     $tag_list = tree_to_list(list_to_tree($this->get_tag_list("id,pid,name"), $tag_id));
     $tag_list = rotate($tag_list);
     $tag_list = implode(",", $tag_list['id']) . ",{$tag_id}";
     $where['id'] = array('in', $tag_list);
     $this->where($where)->delete();
     $this->_del_data_by_tag($tag_list);
 }
コード例 #26
0
 protected function getThisNavMenu($navName)
 {
     $x = M('AdminNavigation')->where(['name' => $navName])->find();
     $this->navId = $x['id'];
     $this->menus = M('AdminMenu')->where(['nav_id' => $this->navId])->select();
     $this->menusTree = get_tree_node_sort(list_to_tree($this->menus));
     $this->assign('navId', $this->navId);
     $this->assign('menus', $this->menus);
     $this->assign('menusTree', $this->menusTree);
 }
コード例 #27
0
 public function winpop()
 {
     $node = M("Dept");
     $menu = array();
     $menu = $node->where('is_del=0')->field('id,pid,name')->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('menu', popup_tree_menu($tree));
     $this->assign('pid', $pid);
     $this->display();
 }
コード例 #28
0
 private function get_emp_list_by_dept_id($id)
 {
     $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
     $dept = rotate($dept);
     $dept = implode(",", $dept['id']) . ",{$id}";
     $model = M("User");
     $where['dept_id'] = array('in', $dept);
     $data = $model->where($where)->select();
     return $data;
 }
コード例 #29
0
 public function type()
 {
     $list = D('Forum/ForumType')->getTree();
     $map = array('status' => array('GT', -1), 'type_id' => array('gt', 0));
     $forums = M('Forum')->where($map)->order('sort asc')->field('id as forum_id,title,sort,type_id as pid,status')->select();
     $list = array_merge($list, $forums);
     $list = list_to_tree($list, 'id', 'pid', 'child', 0);
     $this->assign('list', $list);
     $this->display(T('Application://Forum@Forum/type'));
 }
コード例 #30
0
 /**
  * 显示左边菜单,进行权限控制
  * @author huajie <*****@*****.**>
  */
 protected function getMenu()
 {
     $cate = M('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select();
     $cate = list_to_tree($cate);
     //生成分类树
     //获取分类id
     $cate_id = I('param.cate_id');
     $this->cate_id = $cate_id;
     //是否展开分类
     $hide_cate = false;
     if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') {
         $hide_cate = true;
     }
     //生成每个分类的url
     foreach ($cate as $key => &$value) {
         $value['url'] = 'Article/index?cate_id=' . $value['id'];
         if ($cate_id == $value['id'] && $hide_cate) {
             $value['current'] = true;
         } else {
             $value['current'] = false;
         }
         if (!empty($value['_child'])) {
             $is_child = false;
             foreach ($value['_child'] as $ka => &$va) {
                 $va['url'] = 'Article/index?cate_id=' . $va['id'];
                 if (!empty($va['_child'])) {
                     foreach ($va['_child'] as $k => &$v) {
                         $v['url'] = 'Article/index?cate_id=' . $v['id'];
                         $v['pid'] = $va['id'];
                         $is_child = $v['id'] == $cate_id ? true : false;
                     }
                 }
                 //展开子分类的父分类
                 if ($va['id'] == $cate_id || $is_child) {
                     $is_child = false;
                     if ($hide_cate) {
                         $value['current'] = true;
                         $va['current'] = true;
                     } else {
                         $value['current'] = false;
                         $va['current'] = false;
                     }
                 } else {
                     $va['current'] = false;
                 }
             }
         }
     }
     //dump($cate);
     $this->assign('nodes', $cate);
     $this->assign('cate_id', $this->cate_id);
     //获取面包屑信息
     $nav = get_parent_category($cate_id);
     $this->assign('rightNav', $nav);
 }