? ?? ??? ?? ?? ??, ??? ? ???? ?? ??? ?? ?? ?? ??? ? ???? ??? ???? ??? ????, ???? ???? ???? ???? ?? ??? ????, ?? ??? ??? ??? ? ????. ???? ? ??? ?? ??? ? ??? ???? ?? ??? ?????. ? ?? ??? ???? ??? ? ????. ??? ??? ???? ?????...
- ?? ???
- ??? ??? ??
- widget('ext.tree.widgets.TreeWidget',array(
- ' dataProvider' => $dataProvider, // ??? ??
- 'pid' => 'pid', // ?? ID ??
- 'tableClass' => ', // ??? ???
- 'formatParam' => 'name', // ???? ?? ??
- 'formatTime' => array( // ???? ?? ???? ??
- 'created'
- ),
- 'action' => array(
- array(
- 'label' => 'Edit', // ?? ??
- 'url' => array(
- 'edit') => 'Yii::app()->controller->createUrl("/manage/taosearch/createProduct")', // ?? ??
- ),
- 'urlParams' => 'id','name'), // URL ??? ????? ?? ???? ??? ?????.
- ),
- array(
- 'label' => 'Add', // ?? ??
- 'url' => array(
- 'add' => 'Yii::app()->controller->createUrl("/manage/taosearch/createProduct")', // ?? ??
- ??> ),
- 'urlParams' => array('id','name'), // URL ?? ????? ?? ???? ??? ?????
- ),
- ),
- 'tableHead' => array( // ??? ?? ?? ?? ??
- 'Category ID',
- 'Channel',
- '??? ??',
- '?? ??',
- '??? ??',
- '??',
- '????',
- '??ID',
- '????',
- '??',
- ),
- ) ); ?>
-
- ???? ?? ??
- widget('ext.tree.widgets.TreeWidget',array(
- 'dataProvider' => ; $cate, // ??? ??
- 'pid' => 'pid', // ?? ID ??
- 'formatParam' => 'name', // ?? ?? ??
- 'treeType' => ; false, // ?? ?? ??
- 'selectClass' => 'class="span11"', // ???? ?? ??? ??
- 'defaultSelectValue' => box
- ? ???? ??? 0, '1? ?? ?'
- ),
- )) ?>
?? ??
???? ?? ? ????. |
-
?? ??
- /*
- * ? ???? ????? ?? | ???
- * ????? ???? ???.
- */
- /**
- * ?? ??
- *
- * @author Wang Jiacheng
- * @email 819434425@qq.com
- *
- * ??? ?? ??, ?? ???
- ? ? ????. * * ??
- (
- 0 => ??
- (
- 'id' => '7'
- 'zone' => '??'
- '??' = > '??'
- 'ename' => '??'
- '? ??' => 'l'
- 'sort_order' => 1'
- 'pid' => '6'
- 'created' => '0'
- )
- )
- *
- * ??? ?? ??
- < ?php $this->widget('ext.tree.widgets.TreeWidget',array(
- 'dataProvider' => $dataProvider, // ??? ??
- 'pid' => 'pid', // ?? ID ??
- 'tableClass' => 'items table table-striped table-bordered table-densed', // ??? ???
- 'formatParam' => 'name', // ?? ?? ??
- ' formatTime' => array( // ???? ?? ???? ??
- 'created'
- ),
- 'action' => array(
- array(
- 'label' => 'Edit' , // ?? ??
- 'url' => array(
- 'edit' => 'Yii::app()->controller->createUrl( "/manage/taosearch/createProduct") ', // ?? ??
- ),
- 'urlParams' => array('id','name'), // URL ??? ????? ?? ???? ??? ?????
- ),
- array(
- 'label' => '??', // ?? ??
- 'url' => array(
- 'add' => 'Yii: :app()-> ;controller->createUrl("/manage/taosearch/createProduct")', // ?? ??
- ),
- 'urlParams' => array('id','name '), // url
- ),
- ),
- 'tableHead' => array( // ??? ? ?? ?? ??
- 'Category ID',
- ' ?? ????? ?? ???? ?? ??',
- '????',
- '????',
- '???',
- '??',
- '????',
- '??ID',
- '?? ??',
- '??',
- ),
- )) ?>
- *
- * ???? ?? ???? ??
- * < ?php $this->widget('ext.tree.widgets.TreeWidget',array(
- 'dataProvider' => $cate, // ??? ??
- 'pid' => 'pid', // ?? ID ??
- 'formatParam' => 'name', // ?? ?? ??
- 'treeType' => false, // ?? ?? ??
- 'selectClass' => ' class="span11 "', // ???? ??? ??? ??
- 'defaultSelectValue' => array( // ???? ??? ???? ?? ??
- 0, 1?? 'EMA ? ?'
- ),
- )) ?>
- */
- class TreeWidget ?? ?? {
- /**
- * CArrayDataProvider ??? ?? ?? ?? ???
- * ????? ???? ???? ???(?? ??)
- * @var ?? ??
- * /
- ?? $dataProvider;
-
- /**
- * ??? ?? ??
- * @var type
- */
- ?? $arrAll = array();
-
- /**
- * ? ??? _ID? ??? ??
- * @var ??
- */
- public $arrIdRelation = array();
-
- /**
- * _ID? ? ???? ???? ??? ?? ???, ?? ????? ??? ??
- * @var ??
- */
- public $arrIdRelationSimple = array();
-
- /**
- * ?? ???? ? ??? _ID? ??? ?????.
- * @var type
- */
- public $arrIdAll = array();
-
- /**
- * ?? ??-?? ??
- * @var ??
- */
- public $arrIdSon = array();
-
- /**
- * ?? ??? _ID
- * @var ??
- */
- ?? $arrIdLeaf = array();
-
- /**
- *?? ??? _ID
- * @var ??
- */
- ?? $arrIdRoot = array();
-
- /**
- * 每個(gè)節(jié)點(diǎn)下的子孫后代_ID
- * @var type
- */
- public $arrIdChildren = array();
-
- /**
- * 每個(gè)節(jié)點(diǎn)回逆到根
- * @var type
- */
- public $arrIdBackPath = array();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- > /**
- * 輸出樹的結(jié)構(gòu)
- * @var type
- */
- public $strItem = '
gt;{$strSep}{$name}';
-
- /**
- * 設(shè)定表格樣式
- * @var type
- */
- public $tableClass = 'items table table-striped table-bordered table-condensed';
-
- /**
- * 資料欄位參數(shù)陣列
- * @var type
- */
- public $dataKey = array();
-
- / **
- * 指定需要格式化的欄位
- * @var type
- */
- public $formatParam = 'name';
-
- /**
- * 表格列名稱
- * @var type
- */
- public $tableHead = array();
-
- / **
- * 父 ID
- * @var 型態(tài)
- */
- public $pid = 'pid';
-
- /**
- * 指定樹的類型
- * true 表格類型樹
- * false 下拉框類型樹
- * @var type
- */
- public $treeType = true;
-
- /**
- * 綁定下拉框value值
- * @var type
- */
- public $optionValue = 'id';
-
- /**
- * 格式化時(shí)間
- * @var type
- */
- public $formatTime = array();
-
- /**
- * 下拉框樣式
- * @var type
- */
- public $selectClass = 'class="span3"';
-
- /**
- * 設(shè)定下拉框的預(yù)設(shè)值和選項(xiàng)
- * @var type
- */
- public $defaultSelectValue = array(
- 0,'≡作為一級(jí)欄目≡',
- );
-
- /**
- * 設(shè)定下拉框是否多選
- * true 多選
- * false 單選
- * @var type
- */
- public $isMultiple = false;
- * 綁定到下拉框的預(yù)設(shè)值
- * @var type
- */
- public $isMultiple = false;
-
-
- /**
- * 操作列
- * @var type
- */
- public $bindSelectValue = 0;
-
- /**
- * 運(yùn)行
- */
- public $action = array();
-
-
- /**
- * 運(yùn)行
- * @param 型態(tài) $datas
- * @return 型別
- */
- public function run() {
- if (is_array($this->dataProvider) && count($this->dataProvider) > 0 )
- $data = $this->_run($this->dataProvider);
- else if (is_object($this->dataProvider) && count($this->dataProvider->rawData) > 0)
- $data = $this->_run($this->dataProvider->rawData);
-
-
- $this->render('tree' , array('data'=>$data));
- }
-
- /**
- * 取得html
- * @return type
- * @param type $datas
- * @return 類型
- */
- private function _run($datas){
- foreach ($datas as $data) {
- if (!empty($this ->動(dòng)作) && count($this->action) > 0) {
- foreach ($this->action as $key => $action) {
- $k = array_keys($ action['url']) ;
- $data[$k[0]] = '';
- }
- }
- $this->arrAll[] = $data;
- $this->dataKey = array_keys( $數(shù)據(jù));
- }
-
-
- $this->processData();
- if ($this->treeType === true)
- $data = $this->getTable ();
- else
- $data = $this->getSelect($this->pid, $this->bindSelectValue, $this->isMultiple, $this->selectClass, $this ->defaultSelectValue);
-
- return $data;
- }
-
- /**
- * 設(shè)定分層欄位
- * 表格類型
- * @return string
- */
- public function getHtml() { return $this->genHtml(); /***/ public function getItemName(){ $html = '
'; foreach ($this->dataKey as $v) { if ($this->formatParam == $v) $str = '{$strSep}'; else $str = ''; $html 。 = ''.$str.'{$'.$v.'} | '; } $html .= ' '; 回傳$html ; }
-
- /**
- * ??? ? ?? ????
- * @return ???
- */
- ?? ?? getTableHead(){
- $html = '
';
- foreach($this->tableHead as $v )
- $html .= '
'.$v.' | ';
-
- $html .= '
';
- $html ?? ;
- }
-
- /**
- * ??? ???? ?? ????
- * @return ???
- */
- ?? ?? getTable() {
- $this->strItem = $this->getItemName();
- $strRe = '
';
- $strRe .= ''.$this->getTableHead().'< ;/thead>';
- $strRe .= $this->genHtml();
- $strRe .= '
';
- return $strRe;
- }
-
- /**
- * ???? ?? ??? ?? ????
- * @param type $strName
- * @param array $arrValue
- * @param type $blmMulti
- * @param type $ strExt
- * @param ?? $arrFirst
- * @return ???
- */
- ?? ?? getSelect($strName = 'tree', $arrValue = array(), $blmMulti = false, $strExt = '', $arrFirst = null) {
- !is_array($arrValue) && $arrValue = array($arrValue);
- foreach ($this->arrIdAll as $strTemp => $arrTemp) {
- $this->arrIdAll[$strTemp]['selected'] = '';
-
- if (in_array($arrTemp['id'], $arrValue)) {
- $this->arrIdAll[$strTemp]['selected'] = ' selected="selected"';
- }
- }
- $this->strItem = '? ?= "{$'.$this->optionValue.'}"{$selected} title="{$'.$this->formatParam.'}">{$strSep}{$'.$this-> ;formatParam.'}';
- $strRe = '
-
- if (is_array($arrFirst) && count($arrFirst) == 2) {
- $strRe .= '
- ??($arrTemp) > 0 && $strRe .= $this->genHtml($arrTemp, ($intSep 1));
- }
- }
- return $strRe;
- }
- }
- ? >
???碼
|