示例#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 index($request)
 {
     $data = [];
     $counts = [];
     $counts['videos'] = Video::count();
     $counts['users'] = User::count();
     $counts['channels'] = UserChannel::count();
     $counts['comments'] = Comment::count();
     $counts['total_views'] = Video::sumViews();
     $counts['channel_user_ratio'] = round($counts['channels'] / $counts['users'], 2);
     $counts['videos_that_has_comments'] = Statistic::countVideosHavingComments();
     $counts['channels_having_videos'] = Video::find_by_sql('SELECT count(DISTINCT poster_id) as count from `videos`')[0]->count;
     $counts['part_of_commented_videos'] = round($counts['videos_that_has_comments'] / $counts['videos'] * 100, 2);
     $counts['part_of_channels_having_videos'] = round($counts['channels_having_videos'] / $counts['channels'] * 100, 2);
     $counts['user_1_channel'] = Statistic::countUserHavingChannels('= 1');
     $counts['user_2_channel'] = Statistic::countUserHavingChannels('= 2');
     $counts['user_3_channel'] = Statistic::countUserHavingChannels('= 3');
     $counts['user_more3_channel'] = Statistic::countUserHavingChannels('> 3');
     $counts['user_1_channel_part'] = round($counts['user_1_channel'] / $counts['users'] * 100, 2);
     $counts['user_2_channel_part'] = round($counts['user_2_channel'] / $counts['users'] * 100, 2);
     $counts['user_3_channel_part'] = round($counts['user_3_channel'] / $counts['users'] * 100, 2);
     $counts['user_more3_channel_part'] = round($counts['user_more3_channel'] / $counts['users'] * 100, 2);
     $data['counts'] = $counts;
     return new ViewResponse('admin/statistic/index', $data);
 }
 /**
  * 首页
  */
 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));
 }
示例#4
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));
 }
示例#5
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));
 }
示例#6
0
 public static function getLinkData($link)
 {
     $r = new Video();
     $r->_link = $link;
     if (!filter_var($r->_link, FILTER_VALIDATE_URL)) {
         $r->_results = '';
         $r->_data = '';
         $r->_count = 0;
         return $r;
     }
     $link = urlencode($link);
     $link = 'http://www.getlinkinfo.com/info?link=' . $link;
     $r->_results = array();
     $html = file_get_html($link);
     $data = $html->find('dd');
     $videoid = '';
     $vidname = '';
     $viddesc = '';
     $length = '';
     foreach ($data as $key => $value) {
         switch ($key) {
             case 0:
                 $videoid = strip_tags('' . $value . '');
                 break;
             case 3:
                 $vidname = strip_tags('' . $value . '');
                 break;
             case 4:
                 $viddesc = strip_tags('' . $value . '');
                 break;
         }
     }
     array_push($r->_data, array('videoid' => $videoid, 'vidname' => $vidname, 'viddesc' => $viddesc));
     $r->_count = $r->count();
     return $r;
 }
示例#7
0
 public function channelslist($request)
 {
     if (Session::isActive()) {
         if (count(Session::get()->getOwnedChannels()) > 1) {
             $data['user'] = Session::get();
             $data['currentPageTitle'] = 'Mon compte';
             $data['channel'] = Session::get()->getOwnedChannels();
             $data['videos_count'] = array();
             foreach ($data['channel'] as $chan) {
                 $data['videos_count'][$chan->id] = Video::count(array('conditions' => array('poster_id = ?', $chan->id)));
             }
             $data['current'] = 'videos';
             $response = new ViewResponse('account/channels_videos', $data);
             if (empty($data['channel'])) {
                 $response->addMessage(ViewMessage::error('Vous n\'avez aucune chaîne'));
             }
             return $response;
         } else {
             return new RedirectResponse(WEBROOT . 'account/videos/' . Session::get()->getMainChannel()->id);
         }
     } else {
         return new RedirectResponse(Utils::generateLoginURL());
     }
 }