Ejemplo n.º 1
0
 public function edit()
 {
     if (IS_POST) {
         if ($this->_db->edit_node()) {
             $this->_ajax(1, '修改节点成功');
         }
     } else {
         $nid = Q('nid');
         $this->field = $this->_node[$nid];
         foreach ($this->_node as $id => $node) {
             $this->_node[$id]['disabled'] = Data::isChild($this->_node, $id, $nid, 'nid') ? ' disabled="disabled" ' : '';
         }
         $this->node = $this->_node;
         $this->display();
     }
 }
Ejemplo n.º 2
0
 /**
  * 获取树状栏目
  * 指定cid时过滤掉cid及其子栏目
  *
  * @param int $cid
  *
  * @return mixed
  */
 public function getLevelCategory($cid = 0)
 {
     $category = Db::table('web_category')->where('siteid', SITEID)->get();
     if ($category) {
         $category = Data::tree($category, 'title', 'cid', 'pid');
         if ($cid) {
             //编辑时在栏目选择中不显示自身与子级栏目
             foreach ($category as $k => $v) {
                 if ($v['cid'] == $cid || Data::isChild($category, $v['cid'], $cid)) {
                     unset($category[$k]);
                 }
             }
         }
         return $category;
     }
 }
Ejemplo n.º 3
0
 public function edit()
 {
     if (IS_POST) {
         if ($this->db->editNode()) {
             $this->success('修改节点成功');
         }
     } else {
         $nid = Q('nid');
         $this->field = $this->node[$nid];
         foreach ($this->node as $id => $node) {
             $this->node[$id]['disabled'] = Data::isChild($this->node, $id, $nid, 'nid') ? ' disabled="disabled" ' : '';
         }
         $this->assign('node', $this->node);
         $this->display();
     }
 }
Ejemplo n.º 4
0
 public function getEdit($id, $pid)
 {
     $data = $this->getAll();
     foreach ($data as $key => $value) {
         $data[$key]["_disabled"] = $data[$key]['_selected'] = '';
         if ($id == $value['id']) {
             $data[$key]['_disabled'] = 'disabled=""';
         }
         if (Data::isChild($data, $value['id'], $id, 'id')) {
             $data[$key]['_disabled'] = 'disabled=""';
         }
         if ($value['id'] == $pid) {
             $data[$key]['_selected'] = "selected=''";
         }
     }
     return $data;
 }
Ejemplo n.º 5
0
 public function getEditData($id, $pid)
 {
     $data = $this->getAll();
     foreach ($data as $k => $d) {
         $data[$k]['_selected'] = $data[$k]['_disabled'] = '';
         if ($d['id'] == $id) {
             $data[$k]['_disabled'] = ' disabled=""';
         }
         if (Data::isChild($data, $d['id'], $id, 'id')) {
             $data[$k]['_disabled'] = ' disabled=""';
         }
         if ($pid == $d['id']) {
             $data[$k]['_selected'] = " selected=''";
         }
     }
     return $data;
 }
Ejemplo n.º 6
0
 public function edit()
 {
     //打印用户自定义常量
     //print_const();
     if (IS_POST) {
         if ($this->_db->edit_category()) {
             $this->ajax(array('state' => 1, 'message' => '栏目修改成功'));
         } else {
             $this->ajax(array('state' => 0, 'message' => $this->_db->error));
         }
     } else {
         //分配编辑栏目旧的数据
         $field = $this->_db->find(Q("cid"));
         //分配所有栏目
         $category = $this->_db->all();
         $category = Data::tree($category, 'cname');
         foreach ($category as $n => $v) {
             //将父级栏目添加selected(选中状态)
             $v['selected'] = '';
             if ($field['pid'] == $v['cid']) {
                 $v['selected'] = ' selected="selected" ';
             }
             //将子栏目与自身添加disabled(禁止选择)
             $v['disabled'] = '';
             if ($field['cid'] == $v['cid'] || Data::isChild($category, $v['cid'], $field['cid'])) {
                 $v['disabled'] = ' disabled="disabled" class="disabled" ';
             }
             $category[$n] = $v;
         }
         //分配当前栏目数据
         $this->field = $field;
         //分配栏目数据
         $this->category = $category;
         $this->display();
     }
 }
Ejemplo n.º 7
0
 public function edit()
 {
     if (IS_POST) {
         if ($this->db->editCategory()) {
             $this->success('修改栏目成功');
         } else {
             $this->error($this->db->error);
         }
     } else {
         if (!$this->cid || !isset($this->category[$this->cid])) {
             $this->error('栏目不存在');
         }
         $cache = $this->category;
         $category = $cache[$this->cid];
         foreach ($cache as $n => $cat) {
             //父栏目select状态
             $selected = $category['pid'] == $cat['cid'] ? 'selected=""' : '';
             //子栏目disabled
             $disabled = Data::isChild($this->category, $cat['cid'], $this->cid) || $this->cid == $cat['cid'] ? 'disabled=""' : '';
             $cache[$n]['selected'] = $selected;
             $cache[$n]['disabled'] = $disabled;
         }
         /**
          * 获得栏目权限
          */
         $categoryAccess = $this->db->getCategoryAccess($this->cid);
         /**
          * 如果当前栏目有文章时不允许更改模型
          */
         $map['cid'] = $this->cid;
         $contentTable = $this->model[$this->category[$this->cid]['mid']]['table_name'];
         if (M($contentTable)->where($map)->count()) {
             $disabledChangeModel = true;
         } else {
             $disabledChangeModel = false;
         }
         $this->assign('disabledChangeModel', $disabledChangeModel);
         $this->assign('access', $categoryAccess);
         $this->assign('field', $category);
         $this->assign('model', $this->model);
         $this->assign('category', $cache);
         $this->display();
     }
 }
Ejemplo n.º 8
0
 public function edit()
 {
     $CategoryModel = K("Category");
     $cid = Q('cid', 0, 'intval');
     if (IS_POST) {
         $post = $_POST;
         if (empty($post)) {
             $this->error('参数错误');
         }
         if ($CategoryModel->editCategory($post)) {
             $this->success('修改栏目成功');
         } else {
             $this->error($CategoryModel->error);
         }
     } else {
         $categoryCache = cache('category');
         $categoryData = $categoryCache[$cid];
         foreach ($categoryCache as $n => $cat) {
             $selected = $disabled = "";
             //父栏目select状态
             $selected = $categoryData['pid'] == $cat['cid'] ? 'selected=""' : '';
             //子栏目disabled
             $disabled = Data::isChild($categoryCache, $cat['cid'], $cid) ? 'disabled=""' : '';
             //当前栏目不可选
             if ($cid == $cat['cid']) {
                 $disabled = 'disabled="disabled"';
             }
             $categoryCache[$n]['selected'] = $selected;
             $categoryCache[$n]['disabled'] = $disabled;
         }
         $categoryAccess = $CategoryModel->getCategoryAccess($cid);
         //分配角色权限
         $this->assign('access', $categoryAccess);
         $this->assign('field', $categoryData);
         $this->assign('category', $categoryCache);
         $this->display();
     }
 }
 public function edit()
 {
     if (IS_POST) {
         if ($this->db->editCategory()) {
             $this->success('修改栏目成功');
         } else {
             $this->error($this->db->error);
         }
     } else {
         if (!$this->cid || !isset($this->category[$this->cid])) {
             $this->error('cid不存在');
         }
         $cache = $this->category;
         $category = $cache[$this->cid];
         foreach ($cache as $n => $cat) {
             $selected = $disabled = "";
             //父栏目select状态
             $selected = $category['pid'] == $cat['cid'] ? 'selected=""' : '';
             //子栏目disabled
             $disabled = Data::isChild($this->category, $cat['cid'], $this->cid) || $this->cid == $cat['cid'] ? 'disabled=""' : '';
             $cache[$n]['selected'] = $selected;
             $cache[$n]['disabled'] = $disabled;
         }
         $categoryAccess = $this->db->getCategoryAccess($this->cid);
         //分配角色权限
         $this->assign('access', $categoryAccess);
         $this->assign('field', $category);
         $this->assign('model', $this->model);
         $this->assign('category', $cache);
         $this->display();
     }
 }