當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Video::model方法代碼示例

本文整理匯總了PHP中Video::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Video::model方法的具體用法?PHP Video::model怎麽用?PHP Video::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Video的用法示例。


在下文中一共展示了Video::model方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 public function run()
 {
     $tags = Tag::model()->findAll();
     if ($tags) {
         foreach ($tags as $tag) {
             $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             if (!$post && !$image && !$soft && !$video) {
                 $tag->delete();
             } else {
                 $tag->data_count = count($post) + count($image) + count($soft);
                 $tag->save();
             }
         }
     }
     $tagdatas = TagData::model()->findAll();
     if ($tagdatas) {
         foreach ($tagdatas as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $data = $model::model()->findByPk($value->content_id);
             if (!$data) {
                 $value->delete();
             }
         }
     }
     $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index'));
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:30,代碼來源:ResetAction.php

示例2: actionVideo

 public function actionVideo()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = 25;
     $model = Video::model()->is_publish()->findAll($criteria);
     $this->setRss($model, 'video', 'Video', 'Rss Feed Video', $this->createUrl('video'));
 }
開發者ID:beckblurry,項目名稱:Yii1-Base-Core-V.Alpha.1,代碼行數:7,代碼來源:RssController.php

示例3: run

 public function run()
 {
     //限製下載頻率
     $cookie = Yii::app()->request->getCookies();
     $id = Yii::app()->request->getParam('id');
     $cookie_key = 'DL' . $id . 'TIMES';
     if (isset($cookie[$cookie_key]) && $cookie[$cookie_key]->value) {
         throw new CHttpException(404, Yii::t('common', 'Access frequency too fast'));
     }
     $video = Video::model()->findByPk($id);
     if ($video) {
         $file = Helper::convertChineseName(ROOT_PATH . '/' . $video->video_file);
         if ($video->video_file && file_exists($file)) {
             $filename = pathinfo($file, PATHINFO_BASENAME);
             //更新下載次數
             $video->updateCounters(array('down_count' => 1), 'id=:id', array('id' => $id));
             //存儲下載cookie次數
             unset($cookie[$cookie_key]);
             $down = 1;
             $cookie = new CHttpCookie($cookie_key, $down);
             $cookie->expire = time() + 20;
             //20秒之後可以再次下載
             Yii::app()->request->cookies[$cookie_key] = $cookie;
             //開始下載
             Yii::app()->request->sendFile($filename, file_get_contents($file));
             exit;
         } else {
             throw new CHttpException(404, Yii::t('common', 'Source Is Not Found'));
         }
     } else {
         throw new CHttpException(404, Yii::t('common', 'Source Is Not Found'));
     }
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:33,代碼來源:DownloadAction.php

示例4: run

 public function run()
 {
     //SEO
     $this->controller->_seoTitle = $this->controller->_setting['seo_title'];
     $this->controller->_seoKeywords = $this->controller->_setting['seo_keywords'];
     $this->controller->_seoDescription = $this->controller->_setting['seo_description'];
     //頭部banner
     $index_top_banner = Ad::model()->getAdOne(4);
     //中部banner
     $index_mid_banner = Ad::model()->getAdOne(3);
     //底部banner
     $index_bottom_banner = Ad::model()->getAdOne(5);
     //最新資訊
     $news_new = Post::model()->getList(array('limit' => 20));
     //熱門資訊
     $news_hot = Post::model()->getList(array('order' => 't.view_count DESC, t.id DESC', 'limit' => 20));
     //最新圖集
     $image_new = Image::model()->getList(array('limit' => 10));
     //熱門圖集
     $image_hot = Image::model()->getList(array('limit' => 10, 'order' => 'view_count DESC, t.id DESC'));
     //最新軟件
     $soft_new = Soft::model()->getList(array('limit' => 20));
     //熱門軟件
     $soft_hot = Soft::model()->getList(array('limit' => 10, 'order' => 'down_count DESC, t.id DESC'));
     //最新視頻
     $video_new = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY id DESC Limit 20", array(':status' => 'Y'));
     //熱門視頻
     $video_hot = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY view_count DESC, video_score DESC, id DESC Limit 20", array(':status' => 'Y'));
     //友情鏈接
     $link_logos = Link::model()->findAll("logo !='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $link_texts = Link::model()->findAll("logo ='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $this->controller->render('index', array('index_top_banner' => $index_top_banner, 'index_mid_banner' => $index_mid_banner, 'index_bottom_banner' => $index_bottom_banner, 'link_logos' => $link_logos, 'link_texts' => $link_texts, 'news_new' => $news_new, 'news_hot' => $news_hot, 'image_new' => $image_new, 'image_hot' => $image_hot, 'soft_new' => $soft_new, 'soft_hot' => $soft_hot, 'video_new' => $video_new, 'video_hot' => $video_hot));
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:33,代碼來源:IndexAction.php

示例5: run

 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //刪除
             foreach ((array) $ids as $id) {
                 $videoModel = Video::model()->findByPk($id);
                 if ($videoModel) {
                     Uploader::deleteFile(ROOT_PATH . $videoModel->cover_image);
                 }
             }
             Video::model()->deleteAll($criteria);
             break;
         case 'show':
             //顯示
             Video::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隱藏
             Video::model()->updateAll(['status' => 'N'], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:34,代碼來源:BatchAction.php

示例6: loadPost

 private function loadPost($id, $slug)
 {
     $model = Video::model()->is_publish()->findByAttributes(array('ID' => (int) $id, 'post_link' => $slug));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
開發者ID:beckblurry,項目名稱:Yii1-Base-Core-V.Alpha.1,代碼行數:8,代碼來源:VideoController.php

示例7: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Video the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Video::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
開發者ID:Vladimirtishenko,項目名稱:sn,代碼行數:15,代碼來源:VideoController.php

示例8: run

 public function run()
 {
     $criteria = new CdbCriteria();
     $criteria->limit = $this->data('limit');
     $criteria->offset = $this->data('offset');
     $criteria->order = "ID DESC";
     $model = Video::model()->is_publish()->findAll($criteria);
     $this->layout($model);
 }
開發者ID:beckblurry,項目名稱:Yii1-Base-Core-V.Alpha.1,代碼行數:9,代碼來源:widget_video.php

示例9: actionPlay

 public function actionPlay($id)
 {
     $this->layout = '//layouts/header_default';
     $video = Video::model()->findByPk($id);
     if (count($video)) {
         $this->render('play', array('url' => $video->path));
     } else {
         echo "Video not found!";
     }
 }
開發者ID:snipesn,項目名稱:UkrYama-2,代碼行數:10,代碼來源:VideoController.php

示例10: loadModel

 /**
  * 判斷數據是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = Video::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:17,代碼來源:VideoController.php

示例11: run

 public function run()
 {
     $catalog_id = trim(Yii::app()->request->getParam('catalog_id'));
     $order = trim(Yii::app()->request->getParam('order'));
     if (!$order) {
         $order = 'id';
     }
     switch ($order) {
         case 'id':
             $order_by = 't.id DESC';
             break;
         case 'view_count':
             $order_by = 'view_count DESC';
             break;
         default:
             $order = 'id';
             $order_by = 't.id DESC';
             break;
     }
     //SEO
     $navs = array();
     $search_cats = '所有';
     if ($catalog_id) {
         $condition = ' AND catalog_id = ' . $catalog_id;
         $catalog = Catalog::model()->findByPk($catalog_id);
         if ($catalog) {
             $this->controller->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->controller->_setting['site_name'];
             $this->controller->_seoKeywords = $catalog->seo_keywords;
             $this->controller->_seoDescription = $catalog->seo_description;
             $navs[] = array('url' => $this->controller->createUrl('video/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
             //已搜索的分類
             $cat_parents = Catalog::getParantsCatalog($catalog_id);
             $search_cats = $cat_parents ? implode('>', $cat_parents) . '>' . $catalog->catalog_name : $catalog->catalog_name;
         }
     } else {
         $condition = '';
         $catalog = array();
         $seo = ModelType::getSEO('post');
         $this->controller->_seoTitle = $seo['seo_title'] . ' - ' . $this->controller->_setting['site_name'];
         $this->controller->_seoKeywords = $seo['seo_keywords'];
         $this->controller->_seoDescription = $seo['seo_description'];
         $navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $this->controller->_seoTitle);
     }
     //獲取所有符合條件的視頻
     $pages = array();
     $datalist = Video::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages);
     //該欄目下最新的視頻
     $last_videos = Video::model()->getList(array('condition' => $condition, 'limit' => 10));
     $this->controller->render('index', array('navs' => $navs, 'catalog' => $catalog, 'videos' => $datalist, 'pagebar' => $pages, 'last_videos' => $last_videos, 'order' => $order, 'search_cats' => $search_cats));
 }
開發者ID:manjingzi,項目名稱:yiifcms,代碼行數:50,代碼來源:IndexAction.php

示例12: run

 public function run($id)
 {
     if (app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $this->controller->getModel(null)->findByPk($id)->delete();
         if ($this->controller->getId() == 'user') {
             Video::model()->deleteAll("user_id = :p", array(":p" => $id));
         }
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->controller->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
         } else {
             app()->end();
         }
     }
 }
開發者ID:rajveer4155,項目名稱:vidmgr,代碼行數:16,代碼來源:DeleteAction.php

示例13: actionView

 public function actionView()
 {
     if (isset($_GET['id'])) {
         $video = Video::model()->findByPk($_GET['id']);
         //var_dump($video->user_id);die;
         $video->view += 1;
         $video->update(array('view'));
         //$video->user = XfUser::model()->find("user_id=".$video->user_id);
         $comment = $this->newComment($video);
         $cs = Yii::app()->getClientScript();
         $js = $this->generateJs();
         $cs->registerScript('sharebox', $js, CClientScript::POS_READY);
         /*$xf = new XfAuthentication();
           $user = $xf->getUser();
           var_dump($user);*/
         $this->render('view', array('video' => $video, 'comment' => $comment));
     } else {
         $this->redirect($this->createUrl('index'));
     }
 }
開發者ID:ngdvan,項目名稱:lntguitar,代碼行數:20,代碼來源:VideoController.php

示例14: run

 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $post = Video::model()->findByPk(intval($id));
     if (false == $post || $post->status == 'N') {
         throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
     }
     //更新瀏覽次數
     $post->updateCounters(array('view_count' => 1), 'id=:id', array('id' => $id));
     //seo信息
     $this->controller->_seoTitle = empty($post->seo_title) ? $post->title . ' - ' . $this->controller->_setting['site_name'] : $post->seo_title;
     $this->controller->_seoKeywords = empty($post->seo_keywords) ? $post->tags : $post->seo_keywords;
     $this->controller->_seoDescription = empty($post->seo_description) ? $this->controller->_seoDescription : $post->seo_description;
     //最近的視頻
     $last_videos = Video::model()->findAll(array('condition' => 'catalog_id = ' . $post->catalog_id, 'order' => 'id DESC', 'limit' => 10));
     //nav
     $navs = array();
     $navs[] = array('url' => $this->controller->createUrl('video/view', array('id' => $id)), 'name' => $post->title);
     $tplVar = array('video' => $post, 'navs' => $navs, 'last_videos' => $last_videos);
     $this->controller->render('view', $tplVar);
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:21,代碼來源:ViewAction.php

示例15: run

 public function run()
 {
     $g = Yii::app()->request->getParam('g');
     //1獲取 0評分
     $id = Yii::app()->request->getParam('id');
     $s = Yii::app()->request->getParam('s');
     //等級0-5
     $res = Video::model()->findByPk($id);
     //t 總人數 s 從低分人數到高分人數分布
     if ($g == 1) {
         if ($res->voted) {
             exit($res->voted);
         } else {
             exit('{"t":0,"s":[0,0,0,0,0]}');
         }
     } else {
         if ($res->voted) {
             $arr_res = CJSON::decode($res->voted);
         } else {
             $arr_res = array('t' => 0, 's' => array(0, 0, 0, 0, 0));
         }
         $arr_res['t'] = $arr_res['t'] + 1;
         $arr_res['s'][$s - 1] = $arr_res['s'][$s - 1] + 1;
         //計算得分
         $avg_1 = $arr_res['t'] > 0 ? round(($arr_res['s'][0] + 2 * $arr_res['s'][1] + 3 * $arr_res['s'][2] + 4 * $arr_res['s'][3] + 5 * $arr_res['s'][4]) / $arr_res['t'] * 2, 1) : '0.0';
         $avg_2 = substr($avg_1, 0, 3);
         //取前三位
         $avg = trim($avg_2, '.');
         //去除多餘的前後.
         $data = CJSON::encode($arr_res);
         $res->voted = $data;
         $res->video_score = $avg;
         $res->save();
         exit('1');
     }
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:36,代碼來源:ScoreAction.php


注:本文中的Video::model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。