コード例 #1
0
 /**
  * 后台菜单首页
  * @return none
  */
 public function index()
 {
     $tree = new \Org\Util\Tree();
     $tree->icon = array('   │ ', '   ├─ ', '   └─ ');
     $result = M('menu')->order(array("sort" => "asc"))->select();
     foreach ($result as $r) {
         $r['str_manage'] = '<a href="' . U("menu/edit", array("id" => $r['id'])) . '">修改</a> | <a class="J_ajax_get confirm" href="' . U("menu/del", array("id" => $r['id'])) . '">删除</a> ';
         $r['id'] = $r['id'];
         $r['parentid'] = $r['pid'];
         $r['name'] = $r['title'];
         $r['listorder'] = $r['sort'];
         $r['hide'] = $r['hide'] != 0 ? '是' : '否';
         $array[] = $r;
     }
     $tree->init($array);
     $str = "<tr data-parentid='\$parentid' data-id='\$id'>\n                    <td><input name='ids[\$id]' type='text' value='\$listorder' class='input input-xsmall'></td>\n                    <td>\$id</td>\n                    <td>\$spacer\$name</td>\n                    <td>\$module</td>\n                    <td>\$url</td>\n                    <td>\$hide</td>\n                    <td>\$str_manage</td>\n                </tr>";
     $taxonomys = $tree->get_tree(0, $str);
     Cookie('__forward__', U('Menu/index'));
     $this->assign("taxonomys", $taxonomys);
     $this->display();
 }
コード例 #2
0
 /**
  * 按照自定义规律获取分类树
  * @param  integer $id    分类ID
  * @param  boolean $field 查询字段
  * @return array          分类树
  * @author Jroy
  */
 public function get_level_tree()
 {
     $tree = new \Org\Util\Tree();
     $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
     $result = $this->order(array("sort" => "asc"))->select();
     foreach ($result as $r) {
         $r['str_manage'] = '<a href="' . U("ShopProduct/index", array("cate_id" => $r['id'])) . '">产品</a> | <a href="' . U("shopCatalog/add", array("pid" => $r['id'])) . '">添加子分类</a> | <a href="' . U("shopCatalog/edit", array("id" => $r['id'])) . '">修改</a> | <a class="confirm J_ajax_get" href="' . U("shopCatalog/remove", array("id" => $r['id'])) . '">删除</a> | <a href="' . U("ShopCategory/operate", array("type" => "move", "from" => $r['id'])) . '">移动</a> | <a href="' . U("ShopCategory/operate", array("type" => "merge", "from" => $r['id'])) . '">合并</a>';
         $r['id'] = $r['id'];
         $r['parentid'] = $r['pid'];
         $r['name'] = $r['title'];
         $r['listorder'] = $r['sort'];
         $r['display'] = $r['display'] != 0 ? '显示' : '<span class=grey>隐藏</span>';
         $array[] = $r;
     }
     $tree->init($array);
     $str = "<tr data-parentid='\$parentid' data-id='\$id'>\n                    <td><input name='listorders[\$id]' type='text' value='\$listorder' class='input input-xsmall'></td>\n                    <td>\$id</td>\n                    <td>\$spacer <a href='\$content_url' title='点击添加内容'>\$name</a></td>\n                    <td>\$display</td>\n                    <td>\$str_manage</td>\n                </tr>";
     return $tree->get_tree(0, $str);
 }
コード例 #3
0
 /**
  * 获取option分类
  * @param  integer $id    分类ID
  * @param  boolean $field 查询字段
  * @return array          分类树
  * @author Jroy
  */
 public function getCategory()
 {
     $tree = new \Org\Util\Tree();
     $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
     $result = $this->order(array("sort" => "asc"))->select();
     $cid = $_GET['pid'] ? $_GET['pid'] : session('admin_category_id');
     foreach ($result as $r) {
         $r['id'] = $r['id'];
         $r['parentid'] = $r['pid'];
         $r['name'] = $r['title'];
         $r['listorder'] = $r['sort'];
         $r['selected'] = strcmp($r['id'], $cid) == 0 ? "selected=selected" : "";
         $array[] = $r;
     }
     $tree->init($array);
     $str = "<option value='\$id' \$selected>\$spacer\$name</option>";
     return $tree->get_tree(0, $str);
 }
コード例 #4
0
 /**
  * @introduction: 修改权限规则
  * @author: 杨陈鹏
  * @date: 2016/3/30 16:04
  * @email: yangchenpeng@cdlinglu.com
  */
 public function update()
 {
     //获取模型
     $logic = D('AuthRule', 'Logic');
     //获取数据
     $data = I('post.data');
     $this->pid = $pid = $data['pid'];
     $id = $data['id'];
     unset($data['pid']);
     unset($data['id']);
     if ($data) {
         if (!$data['ismenu']) {
             $data['ismenu'] = 0;
         }
         if (!$data['type']) {
             $data['type'] = 0;
         }
         if ($result = $logic::update(['id' => $id], $data)) {
             $result['data']['pid'] = $pid;
             $this->ajaxReturn($result);
         } else {
             $this->ajaxReturn(['code' => 300, 'msg' => '保存失败']);
         }
     } else {
         if (!$id) {
             $this->ajaxReturn(['code' => 300, 'msg' => '参数错误']);
         }
         $this->info = $info = $logic::getOneData(['id' => $id], 'id,pid,title,name,type,ismenu,condition,status,icon');
         $rules = $logic::getData('', '0,100000', 'id,title,pid');
         $tree = new \Org\Util\Tree();
         $tree->init($rules);
         $this->rules = $tree->create(0, '<option \\$selected value=\'$id\'>$spacer $title</option>', $info['pid']);
         $this->display();
     }
 }