示例#1
0
 /**
  * 导航列表
  * @author jry <*****@*****.**>
  */
 public function index($group = 'main')
 {
     //搜索
     $keyword = I('keyword', '', 'string');
     $condition = array('like', '%' . $keyword . '%');
     $map['id|title'] = array($condition, $condition, '_multi' => true);
     // 获取所有导航
     $map['status'] = array('egt', '0');
     $map['group'] = $group;
     $data_list = D('Admin/Nav')->where($map)->order('sort asc, id asc')->select();
     // 给文章列表类型加上链接
     foreach ($data_list as &$val) {
         if ($val['type'] == 'post') {
             $val['title'] = '<a href="' . U('Admin/Post/index', array('cid' => $val['id'])) . '">' . $val['title'] . '</a>';
         }
     }
     // 转换成树状列表
     $tree = new Tree();
     $data_list = $tree->toFormatTree($data_list);
     // 设置Tab导航数据列表
     $nav_group_list = C('NAV_GROUP_LIST');
     // 获取分类分组
     foreach ($nav_group_list as $key => $val) {
         $tab_list[$key]['title'] = $val;
         $tab_list[$key]['href'] = U('index', array('group' => $key));
     }
     // 使用Builder快速建立列表页面。
     $builder = new \Common\Builder\ListBuilder();
     $builder->setMetaTitle('导航列表')->addTopButton('addnew', array('href' => U('add', array('group' => $group))))->addTopButton('resume')->addTopButton('forbid')->addTopButton('delete')->setSearch('请输入ID/导航名称', U('index', array('group' => $group)))->setTabNav($tab_list, $group)->addTableColumn('id', 'ID')->addTableColumn('icon', '图标', 'icon')->addTableColumn('title_show', '标题')->addTableColumn('sort', '排序')->addTableColumn('status', '状态', 'status')->addTableColumn('right_button', '操作', 'btn')->setTableDataList($data_list)->addRightButton('edit', array('href' => U('edit', array('group' => $group, 'id' => '__data_id__'))))->addRightButton('forbid')->addRightButton('delete')->display();
 }
 /**
  * 链接列表
  * @author jry <*****@*****.**>
  */
 public function index()
 {
     //搜索
     $keyword = I('keyword', '', 'string');
     $condition = array('like', '%' . $keyword . '%');
     $map['id|title'] = array($condition, $condition, '_multi' => true);
     // 获取所有链接
     $map['status'] = array('egt', '0');
     // 禁用和正常状态
     $data_list = D('Link')->where($map)->order('sort asc, id asc')->select();
     // 转换成树状列表
     $tree = new Tree();
     $data_list = $tree->toFormatTree($data_list);
     // 使用Builder快速建立列表页面。
     $builder = new \Common\Builder\ListBuilder();
     $builder->setMetaTitle('链接列表')->addTopButton('addnew')->addTopButton('resume')->addTopButton('forbid')->addTopButton('delete')->setSearch('请输入ID/链接名称', U('index'))->addTableColumn('id', 'ID')->addTableColumn('icon', '图标', 'icon')->addTableColumn('title_show', '标题')->addTableColumn('sort', '排序')->addTableColumn('status', '状态', 'status')->addTableColumn('right_button', '操作', 'btn')->setTableDataList($data_list)->addRightButton('edit')->addRightButton('forbid')->addRightButton('delete')->display();
 }
示例#3
0
 /**
  * 获取导航树,指定导航则返回指定导航的子导航树,不指定则返回所有导航树,指定导航若无子导航则返回同级导航
  * @param  integer $id    导航ID
  * @param  boolean $field 查询字段
  * @return array          导航树
  * @author jry <*****@*****.**>
  */
 public function getNavTree($id = 0, $field = true)
 {
     // 获取当前导航信息
     if ((int) $id > 0) {
         $info = $this->find($id);
         $id = $info['id'];
     }
     // 获取所有导航
     $map['status'] = array('eq', 1);
     $tree = new Tree();
     $list = $this->field($field)->where($map)->order('sort asc')->select();
     // 返回当前导航的子导航树
     $list = $tree->list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_child', $root = (int) $id);
     if (!$list) {
         return $this->getSameLevelNavTree($id);
     }
     return $list;
 }
 /**
  * 编辑部门
  * @author jry <*****@*****.**>
  */
 public function edit($id)
 {
     if (IS_POST) {
         $group_object = D('Group');
         $_POST['menu_auth'] = json_encode(I('post.menu_auth'));
         $data = $group_object->create();
         if ($data) {
             if ($group_object->save($data) !== false) {
                 $this->success('更新成功', U('index'));
             } else {
                 $this->error('更新失败');
             }
         } else {
             $this->error($group_object->getError());
         }
     } else {
         // 获取部门信息
         $info = D('Group')->find($id);
         $info['menu_auth'] = json_decode($info['menu_auth'], true);
         // 获取现有部门
         $map['status'] = array('egt', 0);
         $all_group = select_list_as_tree('Group', $map, '顶级部门');
         // 获取所有安装并启用的功能模块
         $moule_list = D('Module')->where(array('status' => 1))->select();
         // 获取功能模块的后台菜单列表
         $tree = new Tree();
         $all_module_menu_list = array();
         foreach ($moule_list as $key => $val) {
             $temp = json_decode($val['admin_menu'], true);
             $menu_list_item = $tree->list_to_tree($temp);
             $all_module_menu_list[$val['name']] = $menu_list_item[0];
         }
         $this->assign('info', $info);
         $this->assign('all_module_menu_list', $all_module_menu_list);
         $this->assign('all_group', $all_group);
         $this->assign('meta_title', '编辑部门');
         $this->display('add_edit');
     }
 }
示例#5
0
 /**
  * 获取导航树,指定导航则返回指定导航的子导航树,不指定则返回所有导航树,指定导航若无子导航则返回同级导航
  * @param  integer $id    导航ID
  * @param  boolean $field 查询字段
  * @return array          导航树
  * @author jry <*****@*****.**>
  */
 public function getNavTree($id = 0, $group = 'main', $field = true)
 {
     if (!in_array(MODULE_NAME, array('Home', 'Admin', 'Common', 'Install')) && is_file(APP_PATH . MODULE_NAME . '/Model/NavModel.class.php')) {
         $module_nav_tree = D(MODULE_NAME . '/Nav')->getNavTree($id, $group, $field);
         if ($module_nav_tree) {
             return $module_nav_tree;
         }
     }
     // 获取当前导航信息
     if ((int) $id > 0) {
         $info = $this->find($id);
         $id = $info['id'];
     }
     // 获取所有导航
     $map['status'] = array('eq', 1);
     $map['group'] = array('eq', $group);
     $tree = new Tree();
     $list = $this->field($field)->where($map)->order('sort asc,id asc')->select();
     // 返回当前导航的子导航树
     $list = $tree->list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_child', $root = (int) $id);
     if (!$list) {
         return $this->getSameLevelNavTree($id);
     }
     return $list;
 }