国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院

首頁 > 系統 > iOS > 正文

yii框架分類樹擴展示例

2020-02-19 15:58:28
字體:
來源:轉載
供稿:網友

提供兩種方式的分類樹格式,表格和下拉框形式的樹形結構
可以自定義表格和下拉框的樣式,自定義以哪一列的參數為格式化數據,自定義層級關系參數,自定義表格列名稱,也可以設置時間的格式化。



調用方式

表格方式:


widget('ext.tree.widgets.TreeWidget',array(
??????? 'dataProvider'? => $dataProvider,?????????? // 傳遞數據
??????? 'pid'?????????? => 'pid',?????????????????? // 設置層級關系id
??????? 'tableClass'??? => 'items table table-striped table-bordered table-condensed',? // 表格樣式
??????? 'formatParam'?? => 'name',????????????????? // 設置格式化字段???
??????? 'formatTime'??? => array(?????????????????? // 設置格式化的時間參數
??????????? 'created'
??????? ),??????????????
??????? 'tableHead'???? => array(?????????????????? // 設置表格列頭信息
??????????????? '分類ID',
??????????????? '頻道',
??????????????? '中文名',
??????????????? '英文名',
??????????????? '首字母',
??????????????? '排序',
??????????????? '分類級別',
??????????????? '父ID',
??????????????? '創建時間',
??????? ),???
??? )); ?>

下拉框方式


widget('ext.tree.widgets.TreeWidget',array(
??????????? 'dataProvider'? => $cate,?????????? // 傳遞數據
??????????? 'pid'?????????? => 'pid',?????????????????? // 設置父ID???????????
??????????? 'formatParam'?? => 'name',????????????????? // 設置格式化字段
??????????? 'treeType'????? => false,?????????????????? // 輸出樹格式
??????????? 'selectClass'? => 'class="span11"',???????? // 設置下拉框樣式
???????????? 'defaultSelectValue' => array(???????????? // 設置下拉框的默認值和選項
??????????????????? 0 , '≡ 作為一級欄目 ≡'
???????????? ),
??????? )); ?>

TreeWidget.php


/*
?* To change this template, choose Tools | Templates
?* and open the template in the editor.
?*/

/**
?* Description of Tree
?*
?* @author 汪嘉誠
?* @email 819434425@qq.com
?*?
?* 表格方式調用
??? widget('ext.tree.widgets.TreeWidget',array(
??????? 'dataProvider'? => $dataProvider,?????????? // 傳遞數據
??????? 'pid'?????????? => 'pid',?????????????????? // 設置層級關系id
??????? 'tableClass'??? => 'items table table-striped table-bordered table-condensed',? // 表格樣式
??????? 'formatParam'?? => 'name',????????????????? // 設置格式化字段???
??????? 'formatTime'??? => array(?????????????????? // 設置格式化的時間參數
??????????? 'created'
??????? ),??????????????
??????? 'tableHead'???? => array(?????????????????? // 設置表格列頭信息
??????????????? '分類ID',
??????????????? '頻道',
??????????????? '中文名',
??????????????? '英文名',
??????????????? '首字母',
??????????????? '排序',
??????????????? '分類級別',
??????????????? '父ID',
??????????????? '創建時間',
??????? ),???
??? )); ?>
?*
?* 下拉框方式調用
?* widget('ext.tree.widgets.TreeWidget',array(
??????????? 'dataProvider'? => $cate,?????????? // 傳遞數據
??????????? 'pid'?????????? => 'pid',?????????????????? // 設置父ID???????????
??????????? 'formatParam'?? => 'name',????????????????? // 設置格式化字段
??????????? 'treeType'????? => false,?????????????????? // 輸出樹格式
??????????? 'selectClass'? => 'class="span11"',???????? // 設置下拉框樣式
???????????? 'defaultSelectValue' => array(???????????? // 設置下拉框的默認值和選項
??????????????????? 0 , '≡ 作為一級欄目 ≡'
???????????? ),
??????? )); ?>
?*/
class TreeWidget extends Widget {
??? /**
???? * CArrayDataProvider 數據對象或數組數據
???? * 組件數據接收參數
???? * @var Object || array
???? */
??? public $dataProvider;

??? /**
???? * 賦值接收數據
???? * @var type
???? */
??? public $arrAll = array();

??? /**
???? * 按_ID作鍵名的多維關系
???? * @var type
???? */
??? public $arrIdRelation = array();

??? /**
???? * 按_ID作鍵名的多維關系的簡化,用來輸出樹狀圖
???? * @var type
???? */
??? public $arrIdRelationSimple = array();

??? /**
???? * 將原始數據轉化成的_ID作鍵名的數組
???? * @var type
???? */
??? public $arrIdAll = array();

??? /**
???? * 所有的父子關系
???? * @var type
???? */
??? public $arrIdSon = array();

??? /**
???? * 葉子節點的_ID
???? * @var type
???? */
??? public $arrIdLeaf = array();

??? /**
???? * 根節點的_ID
???? * @var type
???? */
??? public $arrIdRoot = array();

??? /**
???? * 每個節點下的子孫后代_ID
???? * @var type
???? */
??? public $arrIdChildren = array();

??? /**
???? * 每個節點回逆到根
???? * @var type
???? */
??? public $arrIdBackPath = array();

??? /**
???? * 輸出樹的結構
???? * @var type
???? */
??? public $strItem = '
{$strSep}{$name}';

??? /**
???? * 設置表格樣式
???? * @var type
???? */
??? public $tableClass? = 'items table table-striped table-bordered table-condensed';

??? /**
???? * 數據字段參數數組
???? * @var type
???? */
??? public $dataKey?? = array();

??? /**
???? * 指定需要格式化的字段
???? * @var type
???? */
??? public $formatParam = 'name';

??? /**
???? * 表格列名稱
???? * @var type
???? */
??? public $tableHead?? = array();

??? /**
???? * 父ID
???? * @var type
???? */
??? public $pid = 'pid';

??? /**
???? * 指定樹的類型
???? * true 表格類型樹
???? * false 下拉框類型樹
???? * @var type
???? */
??? public $treeType = true;???????

??? /**
???? * 綁定下拉框value值
???? * @var type
???? */
??? public $optionValue = 'id';

??? /**
???? * 格式化時間
???? * @var type
???? */
??? public $formatTime = array();

??? /**
???? * 下拉框樣式
???? * @var type
???? */
??? public $selectClass = 'class="span3"';

??? /**
???? * 設置下拉框的默認值和選項
???? * @var type
???? */
??? public $defaultSelectValue = array(
??????? 0,'≡ 作為一級欄目 ≡',
??? );

??? /**
???? * 設置下拉框是否多選
???? * true 多選
???? * false 單選
???? * @var type
???? */
??? public $isMultiple = false;

??? /**
???? * 綁定到下拉框的默認值
???? * @var type
???? */
??? public $bindSelectValue = 0;
???

??? /**
???? * 運行
???? */
??? 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));
??? }

??? /**
???? *
???? * @return type
???? */
??? private function _run($datas){???????????
??????????? foreach ($datas as $data)
??????????????????? $this->arrAll[] = $data;
??????????????????? $this->dataKey = array_keys($data);

??????????? $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;
??? }

??? /**
???? * 獲得html
???? * @return type
???? */
??? public function getHtml() {
??????????? return $this->genHtml();
??? }

??? /**
???? * 設置分層字段
???? * 表格類型
???? * @return string
???? */
??? public function getItemName(){???????????
??????????? $html = '

';
??????????? foreach($this->dataKey as $v) {???????????????????
??????????????????? if ($this->formatParam == $v)
??????????????????????????? $str = '{$strSep}';
??????????????????? else
??????????????????????????? $str = '';

??????????????????? $html .= ''.$str.'{$'.$v.'}';
??????????? }
??????????? $html .= '';
??????????? return $html;
??? }

??? /**
???? * 獲取表格列名稱
???? * @return string
???? */
??? public function getTableHead(){
??????????? $html = '';
??????????? foreach($this->tableHead as $v)
??????????????????? $html .= ''.$v.'';

??????????? $html .= '';
??????????? return $html;
??? }

??? /**
???? * 獲得表格形式的樹
???? * @return string
???? */
??? public function getTable() {???????????????????
??????????? $this->strItem = $this->getItemName();
??????????? $strRe = '

';
??????????? $strRe .= ''.$this->getTableHead().'';
??????????? $strRe .= $this->genHtml();
??????????? $strRe .= '
';
??????????? return $strRe;
??? }???

??? /**
???? * 獲取下拉框形式的樹
???? * @param type $strName
???? * @param array $arrValue
???? * @param type $blmMulti
???? * @param type $strExt
???? * @param type $arrFirst
???? * @return string
???? */
??? public function 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 = '';
??????????? $strRe = '';???????????
??????????? return $strRe;
??? }

??? /**
???? * 數據處理
???? * @param type $arrData
???? * @return type
???? */
??? private function helpForGetRelation($arrData) {
??????????? $arrRe = array();
??????????? foreach ($arrData as $strTemp => $arrTemp) {
??????????????????? $arrRe[$strTemp] = $arrTemp;
??????????????????? if (isset($this->arrIdRelation[$strTemp])) {
??????????????????????????? $arrRe[$strTemp] = $this->arrIdRelation[$strTemp];
??????????????????? }
??????????????????? if (count($arrRe[$strTemp]) > 0) {
??????????????????????????? $arrRe[$strTemp] = $this->helpForGetRelation($arrRe[$strTemp]);
??????????????????? } else {
??????????????????????????? array_push($this->arrIdLeaf, $strTemp);
??????????????????? }
??????????? }
??????????? return $arrRe;
??? }

??? /**
???? * 數據處理
???? * @param type $arrData
???? * @return type
???? */
??? private function helpForGetChildren($arrData) {
??????????? $arrRe = array_keys($arrData);
??????????? foreach ($arrData as $arrTemp) {
??????????????????? $arrRe = array_merge($arrRe, $this->helpForGetChildren($arrTemp));
??????????? }
??????????? return $arrRe;
??? }

??? /**
???? * 數據處理
???? * @param type $str
???? * @return type
???? */
??? private function helpForGetBackPath($str) {
??????????? $arrRe = array();
??????????? $intTemp = $this->arrIdAll[$str][$this->pid];
??????????? if ($intTemp > 0) {
??????????????????? $intTemp = '_' . $intTemp;
??????????????????? array_push($arrRe, $intTemp);
??????????????????? $arrRe = array_merge($arrRe, $this->helpForGetBackPath($intTemp));
??????????? }
??????????? return $arrRe;
??? }

??? /**
???? * 數據處理
???? */
??? private function processData() {
??????????? $count = count($this->arrAll);
??????????? foreach ($this->arrAll as $arrTemp) {???????????
??????????????????? $strTemp = '_' . $arrTemp['id'];
??????????????????? $this->arrIdAll[$strTemp] = $arrTemp;
??????????????????? if ($arrTemp[$this->pid] > 0 && $count > 1) {
??????????????????????????? $strTemp_ = '_' . $arrTemp[$this->pid];
??????????????????????????? !isset($this->arrIdRelation[$strTemp_]) && $this->arrIdRelation[$strTemp_] = array();
??????????????????????????? $this->arrIdRelation[$strTemp_][$strTemp] = array();
??????????????????????????? !isset($this->arrIdSon[$strTemp_]) && $this->arrIdSon[$strTemp_] = array();
??????????????????????????? array_push($this->arrIdSon[$strTemp_], $strTemp);
??????????????????? } else {
??????????????????????????? !isset($this->arrIdRelation[$strTemp]) && $this->arrIdRelation[$strTemp] = array();
??????????????????????????? array_push($this->arrIdRoot, $strTemp);
??????????????????? }
??????????? }

??????????? $this->arrIdRelation = $this->helpForGetRelation($this->arrIdRelation);
??????????? $this->arrIdLeaf = array_unique($this->arrIdLeaf);
??????????? foreach ($this->arrIdRelation as $strTemp => $arrTemp) {
??????????????????? $this->arrIdChildren[$strTemp] = $this->helpForGetChildren($arrTemp);
??????????????????? in_array($strTemp, $this->arrIdRoot) && $this->arrIdRelationSimple[$strTemp] = $arrTemp;
??????????? }
??????????? $arrTemp = array_keys($this->arrIdAll);
??????????? foreach ($arrTemp as $strTemp) {
??????????????????? $this->arrIdBackPath[$strTemp] = $this->helpForGetBackPath($strTemp);
??????????? }
??? }

??? /**
???? * 數據處理
???? * @param type $intLen
???? * @return string
???? */
??? private function genSeparator($intLen) {
??????????? $strRe = '';
??????????? $i = 0;
??????????? while ($i ??????????????????? $strRe .= ' ' . (($i + 1 == $intLen) ? '├' : '│');
??????????????????? $i++;
??????????? }

??????????? !empty($strRe) && $strRe .= '─';
??????????? return $strRe;
??? }

??? /**
???? * 數據處理
???? * @param type $arrRelation
???? * @param type $intSep
???? * @return type
???? */
??? private function genHtml($arrRelation = null, $intSep = 0) {
??????????? $strRe = '';
??????????? null === $arrRelation && $arrRelation = $this->arrIdRelationSimple;
??????????? foreach ($arrRelation as $strKey => $arrTemp) {
??????????????????? if (count($this->arrIdAll[$strKey]) > 0) {
??????????????????????????? if (!empty($this->formatTime) && count($this->formatTime) > 0) {
??????????????????????????????????? foreach($this->formatTime as $formatTime) {
??????????????????????????????????????????? if ($this->arrIdAll[$strKey][$formatTime] > 0) {
??????????????????????????????????????????????????? $this->arrIdAll[$strKey][$formatTime] = date('Y-m-d H:i:s' , $this->arrIdAll[$strKey][$formatTime]);
??????????????????????????????????????????? }
??????????????????????????????????? }???????????????????????????????????
??????????????????????????? }

??????????????????????????? $strSep = $this->genSeparator($intSep);???????????????????????
??????????????????????????? extract($this->arrIdAll[$strKey]);
??????????????????????????? eval('$strRe .= "' . $this->strItem . '";');???????????????????????????????????????????????
??????????????????????????? count($arrTemp) > 0 && $strRe .= $this->genHtml($arrTemp, ($intSep + 1));
??????????????????? }
??????????? }???????????
??????????? return $strRe;
??? }
}
?>

tree.php





沒有找到數據.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院
国产精品探花在线| 精品视频在线一区二区| 色综合久久五月天| 亚洲精品国自产拍在线观看| 伊人中文在线| 国产区在线视频| av在线free| 国产亚洲精品久久久久久移动网络 | 国产乱xxⅹxx国语对白| 国产字幕在线看| 国产精品久久麻豆| 亚洲精品一线| 超碰在线免费播放| 精品国产福利一区二区在线| 免费在线高清av| 在线视频中文字幕第一页| 国产在线三区| 亚洲一本大道| 18 激情视频在线| 黄色免费av| 人人澡人人爽| 在线中文字幕观看| 国产天堂资源| 天天爱天天做色综合| 亚洲字幕成人中文在线观看| 国产午夜在线| 国产乱人视频免费播放| 中文字幕2019第三页| 天天操夜夜摸| 好看的中文字幕在线播放| 国产福利av网站| 国产写真视频在线观看| 九九热视频在线| 欧美日韩在线精品成人综合网| 91久久精品国产性色| 国产无套粉嫩白浆在线2022年 | 伊人中文在线| 国产高清在线视频| 国产尤物视频在线| 欧美精品另类| 久久综合第一页| 毛片视频免费观看| 四虎久久影院| 狠狠综合久久久综合| 日本不卡1区2区3区| 天堂网中文在线| 牛牛热在线视频| 欧美日韩亚洲第一页| 超碰97在线免费观看| 亚洲成人福利| 久热久精久品这里在线观看| а天堂8中文最新版在线官网| av在线播放网| 天天草天天爽| 91超碰国产在线| 国产黄色高清在线| 在线色视频网| 国内外激情在线| 国产精品区一区二| 99免费视频| 青青艹在线视频| 国产午夜视频| 伊人色综合网| 国产农村av| 伊人影院蕉久影院在线播放| 欧美精品一区二区三区免费| 最近久乱中文字幕| 先锋av资源网| 丁香花在线电影| 一本久中文高清| 日本中文字幕在线视频| 亚洲成人福利| 国产福利电影在线| 黄网站在线观看高清免费| 国产超碰精品在线观看| 欧美xxxx黑人又粗又长| 国产精品白浆视频免费观看| 亚洲欧美综合乱码精品成人网| 狠狠干五月天| wwww在线观看| 亚洲欧美中文字幕在线观看| 国产三区视频在线观看| 日本高清中文字幕| 国产精品免费视频二三区| 日本黄色免费网址| 97国产视频| 国产精品久久久高清免费| 看成年女人免费午夜视频| 在线免费国产| 国产精品白浆视频免费观看| 黄网在线免费| 欧美专区日韩| 午夜影院免费| 亚洲高清在线免费| 精品极品三级久久久久| 国产青青草在线| 中文字幕不卡| 中文字幕人成高视频| 免费在线观看a| 天天干天天摸| 免费精品国产自产拍在| 青青草在线免费观看| 夜夜爽视频导航| 午夜在线不卡| xxxxx中文字幕| 超碰免费在线观看| 国产乱精品一区二区三区| 天堂资源最新在线| 国产精品美女一区二区视频| 国产精品你懂的在线观看| 国产精品区一区二| 精品免费视频一卡2卡三卡4卡不卡 | 天天插天天干| 欧美日韩久久中文字幕| 免费看ww视频网站入口| 天堂中文资源在线| 国产香蕉视频在线看| 国产精品美女一区二区三区四区 | 在线视频中文字幕久| av日韩国产| 九九在线免费视频| 国产高清在线| 在线一二三区| 好吊日视频在线观看| 国产精品777一区二区| av男人的天堂网| 大香伊人中文字幕精品| 国产福利三区| 高清欧美精品xxxxx在线看| 国产香蕉尹人视频在线| 9色在线视频网站| 欧美日韩亚洲国内综合网| 国产一级黄色大片| 日韩不卡高清| 国产高清在线看| 久久久久久久美女| 中文资源在线官网| 高潮白浆视频| 欧美日韩亚洲国内综合网| 国产精品视频一区二区久久| 四虎国产精品永久在线| 国产精品久久久久白浆| 丁香在线视频| eeuss影院www在线观看| 国产不卡精品一区二区三区| 九色视频网站| 欧美亚洲系列| 午夜影院在线| 精品一二三四| 国产精品99999| 国产午夜视频| 国产香蕉视频在线观看| 爱福利在线视频| 99在线播放| 91高清国产| 国产福利在线免费观看| 国产污视频在线| 最新黄网在线观看| 午夜免费福利在线观看| 国产麻豆视频网站| 中文字幕在线播放网址| 午夜视频在线| 国产精品毛片一区二区三区四区 | 国产福利视频在线| 国产精品冒白浆免费视频| 中文字幕在线看精品乱码| 超碰在线97国产| 丁香花在线电影| 国产偷激情在线| 91激情在线| av片在线观看永久免费| 亚洲欧美国产另类首页| 日本调教视频在线观看| 欧美xxxxx性| 丁香花高清在线观看完整版| 国产卡一卡二卡三| 国产国产国产国产国产国产| 国产不卡精品一区二区三区| 国产传媒在线播放| 亚洲网站一区| 国产美女被遭强高潮免费网站| 麻豆国产在线播放| 国产精品jvid在线观看| 在线观看午夜av| 久久国产情侣| 国产xxxxx| 久蕉依人在线视频| 国产精品免费视频一区一| 亚洲视频在线观看不卡| 国产免费福利网站| 在线观看的网站你懂的| 午夜视频在线| www.操操操| 国产黄色高清在线| 久热国产在线视频| 精品亚洲成a人片在线观看| 亚洲尤物在线视频| 国产视频精选在线| 九九免费视频| eeuss影院在线观看第一页|