Exemple #1
0
 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     $model = new Video();
     $criteria = new CDbCriteria();
     $condition = "type = " . $this->_type;
     $name = trim($this->_request->getParam('name'));
     $catalogId = intval($this->_request->getParam('catalogId'));
     $title && ($condition .= ' AND name LIKE \'%' . $name . '%\'');
     $catalogId && ($condition .= ' AND catalog_id= ' . $catalogId);
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $criteria->with = array('catalog');
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     //根据title,catelogId,titleAlias查询
     $pageParams = $this->buildCondition($_GET, array('name', 'catalogId'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     //推荐位
     $recom_list = RecommendPosition::model()->findAll('type=:type', array(':type' => $this->_type));
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'recom_list' => $recom_list));
 }
 /**
  * 首页
  */
 public function actionIndex()
 {
     $catalog_id = trim($this->_request->getParam('catalog_id'));
     $keyword = trim($this->_request->getParam('keyword'));
     $catalog = Catalog::model()->findByPk($catalog_id);
     //调取子孙分类和当前分类
     $catalog_ids = Catalog::get($catalog ? $catalog_id : 0, $this->_catalog);
     $children_ids = Helper::array_key_values($catalog_ids, 'id');
     $catalog_id ? $all_ids = array_merge($children_ids, (array) $catalog_id) : ($all_ids = $children_ids);
     $db_in_ids = implode(',', $all_ids);
     if (!$db_in_ids || $catalog_id && $catalog->type != $this->_type_ids['video']) {
         throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
     }
     //SEO
     $navs = array();
     if ($catalog) {
         $this->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->_setting['site_name'];
         $this->_seoKeywords = $catalog->seo_keywords;
         $this->_seoDescription = $catalog->seo_description;
         $navs[] = array('url' => $this->createUrl('video/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
     } else {
         $this->_seoTitle = Yii::t('common', 'VideoListTitle') . ' - ' . $this->_setting['site_name'];
         $this->_seoKeywords = Yii::t('common', 'VideoListKeywords');
         $this->_seoDescription = Yii::t('common', 'VideoListDescription', array('{site_name}' => $this->_setting['site_name']));
         $navs[] = array('url' => $this->_request->getUrl(), 'name' => $this->_seoTitle);
     }
     //查询条件
     $post = new Video();
     $criteria = new CDbCriteria();
     $condition = "t.status = 'Y'";
     $keyword && ($condition .= ' AND title LIKE \'%' . $keyword . '%\'');
     $db_in_ids && ($condition .= ' AND catalog_id IN (' . $db_in_ids . ')');
     $criteria->condition = $condition;
     $criteria->order = 'video_score DESC, view_count DESC, t.id DESC';
     $criteria->with = array('catalog');
     $criteria->select = "title, id, t.cover_image, t.video_score,  t.update_time,t.introduce, t.view_count";
     //分页
     $count = $post->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $datalist = $post->findAll($criteria);
     //最近的视频
     $last_videos = Video::model()->findAll(array('condition' => 'catalog_id IN (' . $db_in_ids . ')', 'order' => 'id DESC', 'limit' => 10));
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/list.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     $this->render('index', array('navs' => $navs, 'videos' => $datalist, 'pagebar' => $pages, 'last_videos' => $last_videos));
 }
Exemple #3
0
 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl('video_index');
     $model = new Video();
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
Exemple #4
0
 public function run()
 {
     $model = new Video();
     //条件
     $criteria = new CDbCriteria();
     $title = trim(Yii::app()->request->getParam('title'));
     $catalogId = intval(Yii::app()->request->getParam('catalogId'));
     $criteria->addColumnCondition(array('type' => $this->controller->_type));
     $title && $criteria->addSearchCondition('title', $title);
     $catalogId && $criteria->addColumnCondition(array('catalog_id' => $catalogId));
     $criteria->order = 't.id DESC';
     $criteria->with = array('catalog');
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Video('search');
     $model->unsetAttributes();
     if (isset($_GET['Video'])) {
         $model->attributes = $_GET['Video'];
     }
     $model->user_id = uid();
     $user = User::model()->findByPk(uid());
     // print_r($user);
     $user->payModel = ucwords($user->payModel);
     //print_r($model->findAll());
     $all_data = $model->findAll("user_id=" . uid());
     $formated_data = array();
     foreach ($all_data as $data) {
         if ($data->category_id == "" || $data->category_id == 0) {
             $formated_data[0][] = $data;
         } else {
             if (!isset($formated_data[$data->category_id])) {
                 $formated_data[$data->category_id] = array();
             }
             $formated_data[$data->category_id][] = $data;
         }
     }
     // echo "<pre>";
     // print_r($formated_data);
     // echo "</pre>";
     // die();
     $this->render('admin', array('model' => $model, 'user' => $user, 'all_data' => $formated_data));
 }