コード例 #1
0
ファイル: TypeAction.class.php プロジェクト: google2013/pppon
 private function selecttree($method = 'add', $_arr = array())
 {
     $model = M('arctype');
     $list = $model->field("*,concat(path,'-',id) as bpath")->order('bpath')->select();
     if ($method == 'add') {
         foreach ($list as $key => $value) {
             $list[$key]['count'] = count(explode('-', $value['bpath']));
             if ($_arr['id'] == $list[$key]['id']) {
                 $list[$key]['selected'] = " selected='selected'";
             }
         }
     } elseif ($method == 'edit') {
         //屏蔽当前栏目和当前栏目子栏目选择
         $ids = array();
         array_push($ids, $_arr['id']);
         $pathlist = $model->field('id,path')->select();
         foreach ($pathlist as $k => $v) {
             //file_put_contents('1.txt',substr($v['path'],0,strlen($_arr['path'].'-'.$_arr['id'])));
             if (substr($v['path'] . '-', 0, strlen($_arr['path'] . '-' . $_arr['id'] . '-')) == $_arr['path'] . '-' . $_arr['id'] . '-') {
                 array_push($ids, $v['id']);
             }
         }
         foreach ($list as $key => $value) {
             if ($list[$key]['id'] == $_arr['fid']) {
                 $list[$key]['selected'] = " selected='selected'";
             } elseif (in_array($list[$key]['id'], $ids)) {
                 $list[$key]['selected'] = " disabled='disabled'";
             } else {
                 $list[$key]['selected'] = '';
             }
             $list[$key]['count'] = count(explode('-', $value['bpath']));
         }
     }
     return sorttree($list);
 }
コード例 #2
0
 protected function selecttree($_arr = array())
 {
     $model = M('arctype');
     $list = $model->field("id,modelid,sortrank,modeltype,typename,concat(path,'-',id) as bpath")->order('bpath asc')->select();
     foreach ($list as $key => $value) {
         $list[$key]['count'] = count(explode('-', $value['bpath']));
         if ($_arr['id'] == $list[$key]['id']) {
             $list[$key]['selected'] = " selected='selected'";
         }
         //不显示非当前模型的栏目
         if ($_arr['modelid'] != $list[$key]['modelid']) {
             unset($list[$key]);
         }
         //屏蔽所有封面类型栏目,跳转类型栏目,并标注封面
         if ($list[$key]['modeltype'] == 1) {
             $list[$key]['typename'] .= '[封面]';
             $list[$key]['selected'] = " disabled='disabled'";
         }
         if ($list[$key]['modeltype'] == 2) {
             $list[$key]['typename'] .= '[跳转]';
             $list[$key]['selected'] = " disabled='disabled'";
         }
     }
     return sorttree($list);
 }