/** * @todo - Worldcup video page * @author PhongTX */ public function indexAction() { //set cache $this->_request->setParam('cache_file', 1); //Set category id for block_cate user in block $this->_request->setParam('block_cate', CATE_SEA_GAMES_VIDEO); //get instance Cate $objCate = Thethao_Model_Category::getInstance(); //get page $intPage = max(1, $this->_request->getParam('p', 1)); //Get article id $intVideoId = $this->_request->getParam('id', 0); //New object $objNews = new Thethao_Model_News(); //Get instance $objArticle = $this->view->objArticle; $totalNew = 1; //trang chu video if ($intVideoId <= 0) { //Init params $arrParams = array('category_id' => CATE_SEA_GAMES_VIDEO, 'limit' => 1, 'offset' => 0); //get all article by rule 2 $arrListVideo = $objNews->getListArticleIdsByRule2($arrParams); //get Video new $intVideoId = array_shift($arrListVideo['data']); //Get detail video $arrVideoInfo = $objArticle->getArticleFull($intVideoId); //Id tracking $articleTrackingId = $intVideoId; } else { //Id tracking $articleTrackingId = $intVideoId; //Get detail video $arrVideoInfo = $objArticle->getArticleFull($intVideoId); //check data not empty if (empty($arrVideoInfo)) { $this->_redirect("/video"); } //check publish if (intval($arrVideoInfo['publish_time']) > time()) { $sig = md5($intVideoId . $arrVideoInfo['creation_time']); //gen sig if ($sig != $this->_request->getParam('sig')) { $this->_redirect($this->view->configView['linkerror'][DEVICE_ENV], array('code' => 301)); } } //str link $strLink = $this->_request->getPathInfo(); $arrVideoInfo['share_url'] = $this->view->ShareurlSeagame($arrVideoInfo['share_url']); //check link //check redirect link if (strpos($arrVideoInfo['share_url'], $strLink) === false && APPLICATION_ENV != 'development') { $this->_redirect($arrVideoInfo['share_url'], array('code' => 301)); } } //check pvtt if ($arrVideoInfo['privacy'] & 64) { $this->_redirect($this->view->configView['url_vne'] . "/phong-van-truc-tuyen/" . Fpt_Filter::setSeoLink($arrVideoInfo['title_format']) . '-' . $arrVideoInfo['article_id'] . '.html'); } /* Get video lien quan */ //video exclude $videoExclude = array($intVideoId); //khoi tao so luong video lien quan $mRelateVideo = 0; //khoi tao data arrVideoRelate $arrVideoRelate = array(); //get video lien quan -> by tag if (!empty($arrVideoInfo['list_tag_id'])) { //New object $obj = new Fpt_Data_News_Tag(); $arrParams = array('tag_id' => $arrVideoInfo['list_tag_id'], 'site_id' => CATE_SEA_GAMES_VIDEO, 'article_type' => TYPE_VIDEO, 'limit' => LIMIT_RELATED_VIDEO + 1, 'offset' => 0); //get list video lien quan $arrVideoResult = $obj->getArticleUnionTag($arrParams); //neu co video lien quan if (!empty($arrVideoResult)) { //loai tru tin dang xem $arrVideoRelate = array_slice(array_diff($arrVideoResult, $videoExclude), 0, LIMIT_RELATED_VIDEO); $videoExclude = array_unique(array_merge($videoExclude, $arrVideoRelate)); } unset($arrVideoResult); } //tong so video lien quan nho hon so luong can lay //Nếu không đủ 2 video thì lấy thêm video cùng chuyên mục //Loại trừ Video đang xem //Sắp xếp Video mới lên trên //tinh tong so video lien quan + exclude $mRelateVideo = count($arrVideoRelate); if ($mRelateVideo < LIMIT_RELATED_VIDEO) { //Init params $arrParamsVideoRule2 = array('category_id' => CATE_SEA_GAMES_VIDEO, 'limit' => 2 * LIMIT_RELATED_VIDEO - $mRelateVideo + 1, 'offset' => 0); //Get news by rule 2 : set folder X + ListOn vao folder X => order by publish_time $arrListVideoLasest = $objNews->getListArticleIdsByRule2($arrParamsVideoRule2); //Loai tru video dang xem + tin have $arrListVideoLasest = array_diff($arrListVideoLasest['data'], $videoExclude); //merge list video folder vao video lien de lay them cac video moi nhat // cung folder dang xem $arrVideoRelate = array_merge($arrVideoRelate, $arrListVideoLasest); //lay dung so luong hien thi $arrVideoRelate = array_slice(array_unique($arrVideoRelate), 0, LIMIT_RELATED_VIDEO); unset($arrListVideoLasest); } $videoExclude = array_unique(array_merge($videoExclude, $arrVideoRelate)); //get list video of page video //Init params $arrParams = array('category_id' => CATE_SEA_GAMES_VIDEO, 'limit' => LIMIT_LIST_VIDEO + LIMIT_RELATED_VIDEO + 1, 'offset' => 0); //get all article by rule 2 $arrListVideo = $objNews->getListArticleIdsByRule2($arrParams); if (!empty($arrListVideo['data'])) { $arrListVideo['data'] = array_diff($arrListVideo['data'], $videoExclude); } $arrListVideo['data'] = array_slice($arrListVideo['data'], 0, LIMIT_LIST_VIDEO); //set vao article detail $objArticle->setIdBasic(array_merge($arrListVideo['data'], $videoExclude)); ////////////////////get detail reference video ////////////////// $list_object = $arrVideoInfo['list_object']; if (!empty($list_object)) { foreach ($list_object as $object) { $object_type = $object['object_type']; $object_id = $object['object_id']; } } if ($object_type == 202) { // lấy detail video từ library $arrDataRV = $objArticle->getDetailVideo(array($object_id)); if (!empty($arrDataRV)) { $arrDataRV = array('url' => $arrDataRV[$object_id]['url'], 'object_id' => $object_id, 'object_type' => $object_type, 'have_license' => $arrDataRV[$object_id]['have_license']); } } else { $arrParamRV = array('article_id' => $intVideoId, 'limit' => 1, 'offset' => 0); $arrDataRV = $objArticle->getObjectReferenceByArticleId($arrParamRV); if (isset($arrDataRV['data']) && !empty($arrDataRV['data'])) { $arrDataRV = current($arrDataRV['data']); //$arrDataRV['have_license'] = 0; } else { $arrDataRV = array(); } } $arrVideoInfo['share_url'] = str_replace('http://thethao.vnexpress.net/', 'http://seagames.vnexpress.net/', $arrVideoInfo['share_url']); //init cate for set menu //set cate active $this->_request->setParam('cateActiveId', CATE_SEA_GAMES_VIDEO); //set cate id to show active in menu $this->_request->setParam('cateid', SEA_GAMES); //meta title + image + description $strMetaTitle = html_entity_decode($arrVideoInfo['title'], ENT_COMPAT, 'UTF-8') . ' SEA Games 28 - VnExpress'; $strMetaImage = !empty($arrVideoInfo['thumbnail_url']) ? $this->view->Imageurl($arrVideoInfo['thumbnail_url'], 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg'; $strMetaDescript = trim(strip_tags(html_entity_decode($arrVideoInfo['lead'], ENT_COMPAT, 'UTF-8'))) . ' - VnExpress'; //Assign to views $this->view->assign(array('arrEx' => $videoExclude, 'data' => $arrVideoInfo, 'arrData' => $arrListVideo['data'], 'arrVideoRelate' => $arrVideoRelate, 'intArticleId' => $articleTrackingId, 'intCategoryId' => CATE_SEA_GAMES_VIDEO, 'notRefreshPage' => 1, 'strMetaTitle' => htmlspecialchars($strMetaTitle), 'strMetaImage' => $strMetaImage, 'strMetaDescript' => htmlspecialchars($strMetaDescript), 'isArticleHotVnE' => $arrVideoInfo['privacy'] & 512, 'arrDataRV' => $arrDataRV, 'ogType' => 'website', 'ogTitle' => $strMetaTitle, 'ogUrl' => $arrVideoInfo['share_url'], 'ogImage' => !empty($arrVideoInfo['thumbnail_url']) ? $this->view->Imageurl($arrVideoInfo['thumbnail_url'], 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $strMetaDescript)); //Add js /*$this->view->->headScript()->appendFile($this->view->configView['js'] . '/video.js') ->headScript()->appendFile($this->view->configView['eclick']['ads']['js']);*/ $keywords = 'SEA Games 28, tin tuc , bong da'; $this->view->headTitle($strMetaTitle); $this->view->headMeta()->setName('description', $strMetaDescript); $this->view->headMeta()->setName('keywords', $keywords); //init cate for set menu //set cate active $this->_request->setParam('cateActiveId', CATE_SEA_GAMES_VIDEO); //set cateid to show active in menu $this->_request->setParam('cateid', SEA_GAMES); }
/** * Get suggest video */ function vneMoreAction() { $this->_helper->layout()->disableLayout(); //Get video id $intVideoID = (int) $this->getRequest()->getParam('id', 0); $exclude = $this->getRequest()->getParam('exclude', ''); //dataExclude bao gom ID dang xem va 2 video lien quan $dataExclude = isset($exclude) && !empty($exclude) ? explode(',', $exclude) : array(); $countExclude = count($dataExclude); $arrArticle = array(); if ($intVideoID > 0) { //Get model isntance $newsModel = Thethao_Model_News::getInstance(); $modelTag = new Fpt_Data_News_Tag(); $arrVideoInfo = $this->view->objArticle->getArticleFull($intVideoID); $cateID = $intVideoID > 0 && !empty($arrVideoInfo) ? $arrVideoInfo["category_id"] : CATE_ID_VIDEO; //get video lien quan if (!empty($arrVideoInfo['list_tag_id'])) { $arrParams = array('tag_id' => $arrVideoInfo['list_tag_id'], 'article_type' => VIDEO, 'limit' => LIMIT_VIDEO_MORE + $countExclude, 'offset' => 0); //get list article by tag $arrArticle = $modelTag->getArticleUnionTag($arrParams); } //excluse video dang xem va 2 video lien quan $arrArticle = array_diff($arrArticle, $dataExclude); //toltal media $totalMedia = count($arrArticle); //if total media < 9 then get new video if ($totalMedia < LIMIT_VIDEO_MORE) { $limit_more = LIMIT_VIDEO_MORE - $totalMedia + $countExclude; //( $limitTopHot là total top & hot video) $arrParams = array('category_id' => $cateID, 'limit' => $limit_more, 'offset' => 0, 'article_type' => VIDEO); //get list articleid new $arrNewVideo = $newsModel->getListArticleIdsByRule2($arrParams); if (!empty($arrNewVideo["data"])) { //merge media & new video $arrArticle = array_merge($arrArticle, $arrNewVideo["data"]); } } //lay dung so luong hien thi $arrArticle = array_slice($arrArticle, 0, LIMIT_VIDEO_MORE); if (is_array($arrArticle) && count($arrArticle) > 0) { $this->view->objArticle->setIdBasic($arrArticle); //get Instance Block $objBlock = Thethao_Plugin_Block::getInstance(); //set excluses $objBlock->setExclude($arrArticle); $arrArticleResult = array(); foreach ($arrArticle as $intArticleID) { $arrParams = array('article_id' => $intArticleID, 'limit' => 1, 'offset' => 0); $arrMedia = $this->view->objArticle->getObjectReferenceByArticleId($arrParams); $duration = 0; if (!empty($arrMedia)) { $arrMedia = current($arrMedia); if ($arrMetaData = Zend_Json::decode($arrMedia['meta_data'])) { $duration = (int) $arrMetaData['duration']; } } $arrArticleDetail = $this->view->objArticle->getArticleBasic($intArticleID); $arrArticleDetail['duration'] = $duration; $arrArticleResult[] = $arrArticleDetail; } } $this->view->arrData = $arrArticleResult; } }