예제 #1
0
 /**
  * 栏目选择
  * @param string $file 栏目缓存文件名
  * @param intval/array $catid 别选中的ID,多选是可以是数组
  * @param string $str 属性
  * @param string $default_option 默认选项
  * @param intval $modelid 按所属模型筛选
  * @param intval $type 栏目类型
  * @param intval $onlysub 只可选择子栏目
  * @param intval $siteid 如果设置了siteid 那么则按照siteid取
  */
 public static function select_category($file = '', $catid = 0, $str = '', $default_option = '', $modelid = 0, $type = -1, $onlysub = 0, $siteid = 0, $is_push = 0)
 {
     $tree = new \Lain\Phpcms\tree();
     if (!$file) {
         $file = 'category_content';
     }
     $result = F($file);
     $string = '<select ' . $str . '>';
     if ($default_option) {
         $string .= "<option value='0'>{$default_option}</option>";
     }
     //加载权限表模型 ,获取会员组ID值,以备下面投入判断用
     /* if($is_push=='1'){
     			$priv = pc_base::load_model('category_priv_model');
     			$user_groupid = param::get_cookie('_groupid') ? param::get_cookie('_groupid') : 8;
     		} */
     if (is_array($result)) {
         foreach ($result as $r) {
             //检查当前会员组,在该栏目处是否允许投稿?
             /* if($is_push=='1' and $r['child']=='0'){
             				$sql = array('catid'=>$r['catid'],'roleid'=>$user_groupid,'action'=>'add');
             				$array = $priv->get_one($sql);
             				if(!$array){
             					continue;	
             				}
             			} */
             //if($siteid != $r['siteid'] || ($type >= 0 && $r['type'] != $type)) continue;
             $r['selected'] = '';
             if (is_array($catid)) {
                 $r['selected'] = in_array($r['catid'], $catid) ? 'selected' : '';
             } elseif (is_numeric($catid)) {
                 $r['selected'] = $catid == $r['catid'] ? 'selected' : '';
             }
             $r['html_disabled'] = "0";
             if (!empty($onlysub) && $r['child'] != 0) {
                 $r['html_disabled'] = "1";
             }
             $categorys[$r['catid']] = $r;
             //if($modelid && $r['modelid']!= $modelid ) unset($categorys[$r['catid']]);
         }
     }
     $str = "<option value='\$catid' \$selected>\$spacer \$catname</option>;";
     $str2 = "<optgroup label='\$spacer \$catname'></optgroup>";
     $tree->init($categorys);
     $string .= $tree->get_tree_category(0, $str, $str2);
     $string .= '</select>';
     return $string;
 }
 /**
  * 系统设置-节点设置-编辑节点 已经修改
  */
 public function adminNodeEdit()
 {
     $DB = M('admin_menu');
     $id = I('get.id', '', 'intval');
     if (IS_POST) {
         $info = I('post.info');
         //新增图标
         if (I('post.icon')) {
             $info['icon'] = I('post.icon');
         }
         if (!$DB->create($info)) {
             $this->ajaxReturn(array('statusCode' => 300, 'message' => $DB->getError()));
         } else {
             $DB->where('id=' . $id)->save($info);
             $this->ajaxReturn(array('statusCode' => 200, 'closeCurrent' => 'true', 'tabid' => 'System_adminNodeLists'));
         }
     } else {
         $this->Detail = $DB->where('id=' . $id)->find();
         $tree = new \Lain\Phpcms\tree();
         $result = $DB->select();
         foreach ($result as $r) {
             $r['cname'] = $r['name'];
             $r['selected'] = $r['id'] == $this->Detail['parentid'] ? 'selected' : '';
             $array[] = $r;
         }
         $str = "<option value='\$id' \$selected>\$spacer \$cname</option>";
         $tree->init($array);
         $this->select_categorys = $tree->get_tree(0, $str);
         $this->display();
     }
 }
 public function category()
 {
     $tree = new \Lain\Phpcms\tree();
     $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
     $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
     $result = $this->categorys;
     if (!empty($result)) {
         foreach ($result as $r) {
             $categoryList[$r['catid']] = $r;
             $categoryList[$r['catid']]['typename'] = $r['type'] == 1 ? '单网页' : '内部栏目';
             $categoryList[$r['catid']]['str_manage'] = '<a class="btn btn-green" href="' . U('Article/categoryEdit?catid=' . $r['catid']) . '" data-toggle="dialog" data-width="520" data-height="290" data-id="dialog-mask" data-mask="true">修改</a> <a class="btn btn-green" href="' . U('Article/categoryTemplate?catid=' . $r['catid']) . '" data-toggle="dialog" data-width="900" data-height="500" data-id="dialog-mask" data-mask="true">设置</a> <a href="' . U('Article/categoryDelete?catid=' . $r['catid']) . '" class="btn btn-red" data-toggle="doajax" data-confirm-msg="确定要删除该栏目吗?">删</a> ';
         }
     }
     $str = "<tr target='rid' rel='\$catid'>\n    \t\t\t\t<td>\$catid</td>\n    \t\t\t\t<td>\$spacer\$catname</td>\n    \t\t\t\t<td>\$typename</td>\n    \t\t\t\t<td>\$listorder</td>\n    \t\t\t\t<td align='center'>\$str_manage</td>\n\t\t\t\t</tr>";
     $tree->init($categoryList);
     $this->categoryList = $tree->get_tree(0, $str);
     /* foreach ( $this->categorys as $key => $category ) {
     			$data [$key] = $category;
     			$data [$key] ['name'] = $category ['catname'];
     			$data [$key] ['name'] = $category ['catname'];
     			// 如果有子分类的父级, 去掉url
     			if ($category ['parentid'] == 0 && $category ['child'] != 0) {
     				unset ( $data [$key] ['url'] );
     			}
     		}
     		$nodes = list_to_tree ( $data, 'catid', 'parentid', 'children' );
     		$this->assign ( 'json_nodes', json_encode ( $nodes ) ); */
     $this->display();
 }