Exemplo n.º 1
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     //        cacheFlush();
     parent::_acl();
     $fid = reqGet('fid', 0);
     $rootCatalog = $dataList = null;
     //顶级分类
     //        ppr($this->_catalogAll);
     foreach ($this->_catalogAll as $key => $value) {
         $value['parent_id'] == 0 && ($rootCatalog[$value['id']] = $value['catalog_name']);
     }
     $fid > 0 && ($dataList = XXcache::_doCatalog($fid, $this->_catalogAll));
     //        ppr($dataList);
     empty($dataList) && ($dataList = $this->_catalogAll);
     //得到所包含的链接数量,这里得到所有分类链接数,缓存
     $catalogLinksNum = $this->_getCatalogLinksNum();
     foreach ($dataList as $key => $value) {
         if ($value['last']) {
             $dataList[$key]['num'] = empty($catalogLinksNum[$value['id']]) ? 0 : $catalogLinksNum[$value['id']];
         }
     }
     unset($catalogLinksNum);
     $this->render('index', array('dataList' => $dataList, 'rootCatalog' => $rootCatalog, 'fid' => $fid));
     //        ppr($this->_catalog);        ppr($dataList);
 }
Exemplo n.º 2
0
 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl();
     //过期
     $show = reqGet('show', null);
     $catalogId = intval(reqGet('catalogId', 0));
     $catalogList = $catalogListSub = null;
     //顶级分类
     if ($catalogId > 0) {
         $catalogList = XXcache::_doCatalog($catalogId, $this->_catalog);
         foreach ($this->_catalog as $value) {
             if ($value['id'] == $catalogId) {
                 $value['catalog_name'] = '==' . $value['catalog_name'] . '==';
                 if (empty($catalogList)) {
                     $catalogList = array($value);
                 } else {
                     $catalogList = array_merge(array($value), $catalogList);
                 }
             }
         }
         if (!empty($catalogList)) {
             //非last
             foreach ($catalogList as $value) {
                 $catalogListSub[] = $value['id'];
             }
             //                $catalogListSub = implode(',', $catalogListSub);
         }
     } else {
         //全部有效分类
         if (!empty($this->_catalog)) {
             //非last
             foreach ($this->_catalog as $value) {
                 $catalogListSub[] = $value['id'];
             }
         }
     }
     $catalogList = $this->_catalog;
     $model = new Links();
     $criteria = new CDbCriteria();
     $condition = '1';
     $keyword = trim(reqGet('keyword'));
     $search_type = trim(reqGet('search_type'));
     $keyword && $search_type && ($condition .= ' AND ' . $search_type . ' LIKE \'%' . $keyword . '%\'');
     if ($show) {
         $theTime = time();
         //有效但过期
         if ($show == 'past') {
             $condition .= " AND t.status_is = 'Y' AND begin_time>0 AND end_time>0 AND (`begin_time` > '{$theTime}' OR `end_time` < '{$theTime}')";
         }
         //无效
         if ($show == 'status_n') {
             $condition .= " AND t.status_is = 'N' ";
         }
     }
     if (!empty($catalogListSub)) {
         $temp = null;
         foreach ($catalogListSub as $value) {
             $temp[] = "`catalog_id` = '{$value}'";
         }
         $condition .= ' AND (' . implode(' OR ', $temp) . ')';
         //            $condition .= ' AND `catalog_id` IN ('.$catalogListSub.')';
     } else {
         $catalogId && ($condition .= ' AND `catalog_id`= ' . $catalogId);
     }
     $criteria->condition = $condition;
     $criteria->order = 't.catalog_id ASC,t.status_is ASC,t.sort_order ASC';
     $criteria->with = array('catalog', 'user');
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pageParams = XUtils::buildCondition($_GET, array('title', 'catalogId', 'search_type', 'keyword', 'show', 'r'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     //        ppr($result);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'pagecount' => $count, 'catalogList' => $catalogList, 'catalogId' => $catalogId, 'keyword' => $keyword, 'search_type' => $search_type));
 }
Exemplo n.º 3
0
 private function _getDataPid($pid)
 {
     //得到所有的父id为$pid的分类
     $dataList = XXcache::_doCatalog($pid, $this->_catalogAll);
     $dataRe = null;
     if (!empty($dataList)) {
         foreach ($dataList as $key => $value) {
             $dataRe[$value['id']]['name'] = empty($value['catalog_name']) ? null : $value['catalog_name'];
             $dataRe[$value['id']]['count'] = empty($value['data_count']) ? null : $value['data_count'];
             $dataRe[$value['id']]['path'] = empty($value['path']) ? null : $value['path'];
             $dataRe[$value['id']]['t'] = empty($value['seo_t']) ? null : $value['seo_t'];
             $dataRe[$value['id']]['k'] = empty($value['seo_k']) ? null : $value['seo_k'];
             $dataRe[$value['id']]['d'] = empty($value['seo_d']) ? null : $value['seo_d'];
             $dataRe[$value['id']]['url'] = empty($value['redirect_url']) ? null : $value['redirect_url'];
             $dataRe[$value['id']]['opt_1'] = empty($value['opt_1']) ? null : $value['opt_1'];
             $dataRe[$value['id']]['opt_2'] = empty($value['opt_2']) ? null : $value['opt_2'];
             if (!empty($value['last']) && !empty($value['id'])) {
                 $dataRe[$value['id']]['data'] = $this->_getDataCid($value['id'], $value['data_count']);
             }
         }
     }
     unset($dataList);
     //        ppr($dataRe,1);
     return $dataRe;
 }