public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     $strCateCode = $this->_request->getParam('controller');
     //get instance Cate
     $objCate = Thethao_Model_Category::getInstance();
     // Get models instance
     $modelFootball = Thethao_Model_Football::getInstance();
     // Get detail table ranking by league and season
     $arrMatch = $modelFootball->getListTableRanking(SEASON_ID, LEAGUE_ID);
     if (!empty($arrMatch)) {
         //set id object
         $this->view->objObject->getTeam()->setId(array_keys($arrMatch));
     }
     //gan meta data
     $titleMeta = 'Dự đoán World Cup 2014 - VnExpress';
     $keywords = 'World cup 2014, tin tuc , bong da';
     $description = 'Fifa World Cup 2014 - tin nhanh , hình ảnh , video clip bóng đá, lịch thi đấu WC 2014 tại Brazil, tường thuật bình luận bóng đá World Cup 2014';
     $this->view->assign(array('arrMatch' => $arrMatch, 'strCateCode' => $strCateCode, 'ogType' => 'website', 'ogTitle' => $titleMeta, 'ogUrl' => $this->view->configView['url'], 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $description));
     //Set param
     $this->_request->setParam('block_cate', WORLD_CUP);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', WORLD_CUP);
     //Add script
     $this->view->headTitle($titleMeta);
     $this->view->headMeta()->setName('description', $description);
     $this->view->headMeta()->setName('keywords', $keywords);
 }
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     $strCateCode = $this->_request->getParam('controller');
     //get instance Cate
     $objCate = Thethao_Model_Category::getInstance();
     // Get models instance
     $modelBlock = new Thethao_Model_Block();
     $arrParams = array('key_id' => 'trungthuong_worldcup2014');
     $arrListWinner = $modelBlock->getKeyBox($arrParams);
     $this->view->assign(array('arrListWinner' => $arrListWinner, 'strCateCode' => $strCateCode));
     //gan meta data
     $titleMeta = 'Danh sách trúng thưởng World Cup 2014 - VnExpress';
     $keywords = 'World cup 2014, tin tuc , bong da';
     $description = '';
     //Set param
     $this->_request->setParam('block_cate', WORLD_CUP);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', WORLD_CUP);
     //Add script
     $this->view->headTitle($titleMeta);
     $this->view->headMeta()->setName('description', $description);
     $this->view->headMeta()->setName('keywords', $keywords);
 }
Beispiel #3
0
 /**
  * Get singletom instance
  * @return Thethao_Model_Category
  * @author LamTX
  */
 public static final function getInstance()
 {
     //Check instance
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     //Return instance
     return self::$_instance;
 }
 /**
  * Widget category
  */
 public function categoryAction()
 {
     //disable layout
     $this->_helper->layout->disableLayout();
     //set cache
     $this->_request->setParam('cache_file', 1);
     //Get article id
     $arrParam = $this->_request->getParams();
     //get Instance News
     $modelNews = Thethao_Model_News::getInstance();
     switch ($arrParam['type']) {
         case 2:
             $intLimit = 4;
             break;
         case 1:
         default:
             $intLimit = 3;
             break;
     }
     //init category id
     $intCategoryId = isset($arrParam['id']) ? $arrParam['id'] : SITE_ID;
     //get info cache
     $objCategory = Thethao_Model_Category::getInstance();
     $arrCate = $objCategory->getInfoCateByBlock(array('category_id' => $intCategoryId));
     $intCategoryId = empty($arrCate['cate']['name']) ? SITE_ID : $intCategoryId;
     //init parram
     $arrParams = array('category_id' => $intCategoryId, 'article_type' => 0, 'limit' => $intLimit, 'offset' => 0);
     //get data with rule 1
     $arrData = $modelNews->getListArticleIdsByRule1($arrParams);
     //set id article
     $this->view->objArticle->setIdBasic($arrData['data']);
     //check type
     $intType = 1;
     if (isset($arrParam['type'])) {
         $intType = $arrParam['type'] > 2 ? 1 : $arrParam['type'];
     }
     $this->view->assign(array('arrData' => $arrData['data'], 'type' => $intType, 'cateInfo' => $arrCate));
 }
 public function moreAction()
 {
     // set cache
     $this->_request->setParam('cache_file', 1);
     //Disable layout
     $this->_helper->layout->disableLayout(true);
     //Set no render view
     $this->_helper->viewRenderer->setNoRender(true);
     //get instance Cate
     $objCate = Thethao_Model_Category::getInstance();
     $offset = $this->_request->getParam('offset');
     $limit = $this->_request->getParam('limit');
     // Get models instance
     $modelPlayer = new Thethao_Model_Player();
     $arrTopPlayer = $modelPlayer->getListTopPlayers(SEASON_ID);
     $countTotal = count($arrTopPlayer);
     if (!empty($arrTopPlayer)) {
         $arrTopPlayer = array_slice($arrTopPlayer, $offset, $limit);
         foreach ($arrTopPlayer as $data) {
             $arrPlayerId[] = $data['PlayerID'];
             $arrTeamId[] = $data['TeamID'];
         }
         $this->view->objObject->getPlayer()->setId($arrPlayerId);
         $this->view->objObject->getTeam()->setId($arrTeamId);
     }
     $this->view->assign(array('arrTopPlayer' => $arrTopPlayer, 'strCateCode' => $strCateCode, 'stt' => $offset + 1));
     $arrResult = array('error' => 0, 'offset' => $offset + $limit, 'total' => $countTotal, 'html' => '');
     if (empty($arrTopPlayer)) {
         $arrResult['error'] = 1;
         $arrResult['message'] = 'Dữ liệu đã được tải hết';
     } else {
         //set obj get Article
         $arrResult['html'] = $this->view->render('/scorer/box/m_more.phtml');
     }
     echo Zend_Json::encode($arrResult);
     exit;
 }
 /**
  * Get suggest video
  */
 public function vneMoreAction()
 {
     //disable layout
     $this->_helper->layout()->disableLayout();
     //get params
     $params = $this->_request->getParams();
     //Get instance
     $objArticle = $this->view->objArticle;
     //New object
     $objNews = new Thethao_Model_News();
     //dataExclude bao gom ID dang xem, tags, video cung chuyen muc
     $dataExclude = isset($params['exclude']) && !empty($params['exclude']) ? explode(',', $params['exclude']) : array();
     $countExclude = count($dataExclude);
     //get detail video
     $id = $params['cate_code'];
     $arrVideoInfo = $objArticle->getArticleFull($id);
     //khoi tao so luong $count
     $count = 0;
     //khoi tao data $arrVideoSuggest
     $arrVideoSuggest = array();
     //get data suggest
     //get video lien quan
     if (!empty($arrVideoInfo['list_tag'])) {
         //New object
         $obj = new Fpt_Data_News_Tag();
         $arrParams = array('tag_id' => array(), 'article_type' => TYPE_VIDEO, 'limit' => LIMIT_SUGGEST_VIDEO + $countExclude, 'offset' => 0);
         foreach ($arrVideoInfo['list_tag'] as $tag) {
             $arrParams['tag_id'][] = $tag['tag_id'];
         }
         //get list video lien quan
         $arrVideoResult = $obj->getArticleByArrTag($arrParams);
         foreach ($arrVideoResult as $value) {
             $arrVideoSuggest = array_unique(array_merge($arrVideoSuggest, $value['data']));
         }
         //neu co video lien quan
         if (!empty($arrVideoResult)) {
             //loai tru tin dang xem
             $arrVideoSuggest = array_diff($arrVideoSuggest, $dataExclude);
             //tinh tong so video lien quan
             $count = count($arrVideoSuggest);
         }
         unset($arrVideoResult);
     }
     //tong so nho hon so luong can lay
     //Nếu không đủ 9 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
     if ($count < LIMIT_SUGGEST_VIDEO) {
         //get instance Cate
         $objCate = Thethao_Model_Category::getInstance();
         //Get cate id
         $intCateId = $arrVideoInfo['category_id'];
         $arrCateDetail = $objCate->getMenu(BLOCK_CATE_VIDEO);
         if (!isset($arrCateDetail['child'][$intCateId])) {
             $intCateId = BLOCK_CATE_VIDEO;
         }
         //Init params
         $arrParamsVideoRule3 = array('category_id' => $intCateId, 'limit' => LIMIT_SUGGEST_VIDEO + $countExclude, 'offset' => 0);
         //Get news by rule 3 : folder X + subfolder X  => order by publish_time
         $arrListVideoLasest = $objNews->getListArticleIdsByRule3($arrParamsVideoRule3);
         //Loai tru video dang xem
         $arrListVideoLasest = array_diff($arrListVideoLasest['data'], $dataExclude);
         //merge list video folder vao video lien de lay them cac video moi nhat
         // cung folder dang xem
         $arrVideoSuggest = array_merge($arrVideoSuggest, $arrListVideoLasest);
         //lay dung so luong hien thi
         $arrVideoSuggest = array_slice(array_unique($arrVideoSuggest), 0, LIMIT_SUGGEST_VIDEO);
     } else {
         //lay dung so luong hien thi
         $arrVideoSuggest = array_slice($arrVideoSuggest, 0, LIMIT_SUGGEST_VIDEO);
     }
     //set vao article detail
     $objArticle->setIdBasic($arrVideoSuggest);
     //var_dump($arrVideoSuggest);die;
     //assign to view
     $this->view->assign(array('arrData' => $arrVideoSuggest));
 }
 /**
  * cate folder page
  * @author HungNT1
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     //get instance Cate
     $objCate = Thethao_Model_Category::getInstance();
     //get cate id by cate code
     $intCateId = $objCate->getIdByCode($this->_request->getParam('cate_code', SITE_ID));
     //get page of cate
     $intPage = $this->_request->getParam('page', 1);
     //check cate id is not exists
     if ($intCateId < 1) {
         $this->_redirect("/");
     }
     // Get Category detail
     $cateDetail = $objCate->getDetailByCateId($intCateId);
     //str link
     $strLink = $this->_request->getPathInfo();
     if (strpos(rtrim($strLink, '/'), $cateDetail['link']) === FALSE) {
         $this->_redirect($this->view->configView['url'] . $cateDetail['link'], array('code' => 301));
     }
     //init param to get list data with rule 2
     $arrParamNews = array('category_id' => $intCateId, 'article_type' => NULL, 'limit' => LIMIT_LIST, 'offset' => ($intPage - 1) * LIMIT_LIST);
     //init model news
     $objNews = Thethao_Model_News::getInstance();
     //get list article with rule 2 list on Thethao
     $arrListData = $objNews->getListArticleIdsByRule2($arrParamNews);
     $arrArticleExclude = array();
     $arrHotNews = array();
     //get Instance Block
     $objBlock = Thethao_Plugin_Block::getInstance();
     if (1 == $intPage && !empty($arrListData['data'])) {
         //check bai thuong mai, chi so sanh o trang 1 ma thoi
         $zoneID = Thethao_Global::getZoneByCateId($intCateId);
         if ($zoneID != 0) {
             $modelBlock = Fpt_Data_News_Block::getInstance();
             $modelBlock->setZoneId($zoneID);
             $arrListData['data'] = $modelBlock->getNewsByZone($zoneID, $arrListData['data']);
         }
         $arrArticleExclude = $arrListData['data'];
         // set exclude article id from arrData
         $objBlock->setExclude($arrListData['data']);
         $arrHotNews = array_slice($arrListData['data'], 0, LIMIT_TOP);
         $arrListData['data'] = array_diff($arrListData['data'], $arrHotNews);
         // set id from $arrListPaging to get article
         $this->view->objArticle->setIdBasic($arrHotNews);
     }
     // set id from $arrListPaging to get article
     $this->view->objArticle->setIdBasic($arrListData['data']);
     //check if page > max page then return to max page
     if ($arrListData['total'] > 0) {
         $maxPage = ceil($arrListData['total'] / LIMIT_LIST);
         if ($intPage > $maxPage) {
             $this->_redirect($this->configView['url'] . $cateDetail['link'] . '/page/' . $maxPage . '.html');
         }
     }
     //InitParam Paging
     $arrParamPaging = array('total' => $arrListData['total'], 'page' => $intPage, 'url' => $this->view->configView['url'] . $cateDetail['link'] . '/page', 'perpage' => LIMIT_LIST, 'classPagination' => 'pagination_news right', 'extEnd' => '.html', 'separate' => '/');
     //Set param
     $this->_request->setParam('block_cate', $intCateId);
     //Param calendar
     $parserParent = SITE_ID;
     $parserChild = $intCateId;
     $parserChildRecursive = 0;
     if (!empty($cateDetail['full_parent']) && DEVICE_ENV != 1) {
         $nParser = count($cateDetail['full_parent']);
         switch ($nParser) {
             case 1:
                 $parserChild = $cateDetail['full_parent'][0];
                 $parserChildRecursive = $intCateId;
                 break;
             case 2:
             default:
                 $parserChild = $cateDetail['full_parent'][0];
                 $parserChildRecursive = $cateDetail['full_parent'][1];
                 break;
         }
         //end switch
     }
     //end if
     //gan meta data
     $titleMenta = $keywords = $cateDetail['catename'] . ' - VnExpress Thể Thao';
     $description = $cateDetail['catename'] . ' - VnExpress Thể Thao';
     switch ($intCateId) {
         case CATE_ID_BONGDA:
             $titleMenta = 'Lưu trữ tin tức bóng đá thể thao – Bóng đá thể thao';
             $description = 'Lưu trữ tin tức hình ảnh các ngôi sao thể thao,bóng đá,hậu trường thể thao';
             $keywords = 'Bong da,the thao,tin tuc bong đá, bóng đá 24h';
             break;
         case CATE_ID_BONGDATRONGNUOC:
             $titleMenta = 'Tin tức, bình luận, Tin tức thể thao trong nước mới nhất, V-League, VFF – Bóng đá trong nước';
             $description = 'Thông tin mới nhất về THỂ THAO TRONG NƯỚC, Liên đoàn Bóng Đá Việt Nam, các giải đấu, lịch thi đấu V League, VFF, ĐTQG, Cúp Quốc Gia, Giải Hạng Nhất, U19, U23';
             $keywords = 'Tin tức, bong da, bóng đá việt nam,V-League, VFF bóng đá trong nước';
             break;
         case CATE_ID_NGOAIHANGANH:
             $titleMenta = 'Tin tức, bình luận, video, lịch thi đấu bóng đá giải - Ngoại hạng Anh';
             $description = 'Ngoại hạng Anh - Tin tức giải Premier League , Video bàn thắng, bảng xếp hạng, lịch thi đấu Ngoại hạng Anh, liên tục trên thể thao vnexpress';
             $keywords = 'Giải ngoại hạng Anh , ngoai hang anh , bong da ngoai hang anh , bong da anh , tin bong da , bong da quoc te , bao bong da';
             break;
         case CATE_ID_BEHINDS_SCENES:
             $titleMenta = 'Lưu trữ tin tức hậu trường thể thao';
             $description = 'Lưu trữ tin tức hình ảnh các ngôi sao thể thao,bóng đá,hậu trường thể thao';
             $keywords = 'Hau truong,the thao,bong da';
             break;
         case CATE_ID_CACMONKHAC:
             $titleMenta = 'Tin nhanh,hình ảnh,video kết quả thi đấu các môn thể thao khác';
             $description = 'Tin tức,hình ảnh,video các môn thể thao khác';
             $keywords = 'Bong da,the thao,tin tuc';
             break;
         case CATE_ID_TENNIS:
             $titleMenta = 'Tin tức quần vợt, tennis, lịch thi đấu, video trực tuyến - Tennis';
             $description = 'Cập nhật nhanh tin tức Quần vợt mới nhất hôm nay. Xem kết quả, lịch thi đấu, video clip thể thao Tennis trực tuyến Online tại Việt Nam & Thế giới.';
             $keywords = 'tennis 24h, quan vot, tennis truc tuyen , tennis online, tin tuc tennis, lich thi dau tennis';
             break;
         case CATE_ID_RACING:
             $titleMenta = 'Đua xe - Thể thao VnExpress';
             $description = 'Cập nhật nhanh tin tức, video các giải đua xe trong và ngoài nước.';
             $keywords = 'Đua xe, tay dua, cong thuc 1 , du axe F1';
             break;
         case CATE_ID_AFFCUP:
             $titleMenta = 'Aff Cup 2012 - Tin tức, hình ảnh ,video mới nhất về AFF Cup 2012 - VnExpress';
             $description = 'Cập nhật liên tục tin tức mới nhất về giải bóng đá Đông Nam Á - AFF cup 2012 tổ chức tại Malaysia và Thái Lan';
             $keywords = 'aff cup 2012,bong da,the thao';
             break;
         case CATE_ID_CHESS:
             $titleMenta = 'Cờ Vua: Lịch thi đấu, giải thi đấu cờ vua - VnExpress Thể Thao';
             $description = 'Tin tức nhanh về thông tin các giải thi đấu cờ vua Quốc tế, giải thi đấu tại Việt Nam cùng các cờ thủ xuất sắc nhất';
             $keywords = 'Tin tức nhanh về thông tin các giải thi đấu cờ vua Quốc tế, giải thi đấu tại Việt Nam cùng các cờ thủ xuất sắc nhất';
             break;
         case CATE_ID_GOLF:
             $titleMenta = 'Tin Golf Việt Nam: Giải đấu và lịch thi đấu môn đánh Golf – Golf thể thao';
             $description = 'Tin tức, video đánh giá bình luận về Golf, nhận xét các giải đấu trong nước, quốc tế cùng hướng dẫn các kỹ năng chơi Golf dành cho giới kinh doanh, Golf thủ Việt Nam..';
             $keywords = 'Golf thủ, tay golf,tin tức golf, giải golf, Presidents Cup, FLC Golf Championship 2015';
             break;
         default:
             $titleMenta = 'Tin tức, bình luận, video, lịch thi đấu bóng đá giải - ' . $cateDetail['catename'];
             $description = 'Tin nhanh,tin tức với hình ảnh,Video clip,bình luận về các giải bóng đá: ' . $cateDetail['catename'];
             $keywords = 'Tin tức, bong da, the gioi';
     }
     //Assign to view
     $this->view->assign(array('intCategoryId' => $intCateId, 'arrHotNews' => $arrHotNews, 'arrParamPaging' => $arrParamPaging, 'arrData' => $arrListData['data'], 'parserParent' => $parserParent, 'parserChild' => $parserChild, 'parserChildRecursive' => $parserChildRecursive, 'arrArticleExclude' => $arrArticleExclude, 'paramsBlock' => Zend_Json::encode(array('pagecode' => 'default_category_index_' . $intCateId, 'exclude' => implode(',', $objBlock->getExclude()))), 'ogType' => 'website', 'ogTitle' => $titleMenta, 'ogUrl' => $this->view->configView['url'] . $cateDetail['link'], 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $description));
     //init cate for set menu
     $idCateMenu = $cateDetail['parent_id'] == SITE_ID ? $intCateId : $cateDetail['parent_id'];
     //set cate active
     $this->_request->setParam('cateActiveId', $intCateId);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', $idCateMenu);
     // Set metadata tags
     $this->view->headTitle()->prepend($titleMenta);
     $this->view->headMeta()->setName('description', $description)->setName('keywords', $keywords);
     if (DEVICE_ENV != 1) {
         //ad js
         $this->view->headScript()->appendFile($this->view->configView['vnecdn']['js'] . '/utils/calendar/calendar.js');
     } else {
         //Set no render view
         $this->_helper->viewRenderer->setNoRender(true);
         echo $this->view->render('mobile/index.phtml');
     }
 }
 /**
  * cate folder page
  * @author HungNT1
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     $strCateCode = $this->_request->getParam('cate_code');
     //get instance Cate
     $objCate = Thethao_Model_Category::getInstance();
     //get cate id by cate code
     $intCateId = $objCate->getIdByCode($strCateCode, WORLD_CUP);
     //get page of cate
     $intPage = $this->_request->getParam('page', 1);
     //check cate id is not exists
     if ($intCateId < 1) {
         $this->_redirect("/");
     }
     // Get Category detail
     $cateDetail = $objCate->getDetailByCateId($intCateId);
     //str link
     $strLink = $this->_request->getPathInfo();
     if (strpos(rtrim($strLink, '/'), $cateDetail['link']) === FALSE) {
         //$this->_redirect($this->view->configView['url'] . $cateDetail['link'], array('code' => 301));
     }
     //init param to get list data with rule 2
     $arrParamNews = array('category_id' => $intCateId, 'article_type' => NULL, 'limit' => LIMIT_LIST_CATE, 'offset' => ($intPage - 1) * LIMIT_LIST_CATE);
     //init model news
     $objNews = Thethao_Model_News::getInstance();
     //get list article with rule 2 list on Thethao
     $arrListData = $objNews->getListArticleIdsByRule2($arrParamNews);
     // set id from $arrListPaging to get article
     $this->view->objArticle->setIdBasic($arrListData['data']);
     $arrArticleExclude = array();
     $arrHotNews = $arrListExclude = array();
     if (1 == $intPage && !empty($arrListData['data'])) {
         $arrArticleExclude = $arrListData['data'];
         //get Instance Block
         $objBlock = Thethao_Plugin_Block::getInstance();
         // set exclude article id from arrData
         $objBlock->setExclude($arrArticleExclude);
         $arrHotNews = array_slice($arrListData['data'], 0, LIMIT_TOP);
         $arrListData['data'] = array_diff($arrListData['data'], $arrHotNews);
         //get Exclude
         $arrListExclude = $objBlock->getExclude();
     }
     //get video
     $arrParamVideo = array('category_id' => CATE_ID_VIDEO, 'limit' => LIMIT_VIDEO + LIMIT_LIST_CATE, 'offset' => 0, 'article_type' => TYPE_VIDEO);
     //get list article with rule 2 list on Thethao
     $arrListVideo = $objNews->getListArticleIdsByRule1($arrParamVideo);
     if (1 == $intPage && !empty($arrListVideo['data'])) {
         $arrListVideo['data'] = array_diff($arrListVideo['data'], $arrListExclude);
     }
     if (count($arrListVideo['data']) > LIMIT_VIDEO) {
         $arrListVideo['data'] = array_slice($arrListVideo['data'], 0, LIMIT_VIDEO);
     }
     // set id from $arrListPaging to get article
     $this->view->objArticle->setIdBasic($arrListVideo['data']);
     //get video
     $arrParamPhoto = array('category_id' => CATE_ID_PHOTO, 'limit' => LIMIT_PHOTO + LIMIT_LIST_CATE, 'offset' => 0, 'article_type' => TYPE_PHOTO);
     //get list article with rule 2 list on Thethao
     $arrListPhoto = $objNews->getListArticleIdsByRule1($arrParamPhoto);
     if (1 == $intPage && !empty($arrListPhoto['data'])) {
         $arrListPhoto['data'] = array_diff($arrListPhoto['data'], $arrListExclude);
     }
     if (count($arrListPhoto['data']) > LIMIT_PHOTO) {
         $arrListPhoto['data'] = array_slice($arrListPhoto['data'], 0, LIMIT_PHOTO);
     }
     // set id from $arrListPaging to get article
     $this->view->objArticle->setIdBasic($arrListPhoto['data']);
     //check if page > max page then return to max page
     if ($arrListData['total'] > 0) {
         $maxPage = ceil($arrListData['total'] / LIMIT_LIST_CATE);
         if ($intPage > $maxPage) {
             //$this->_redirect($this->configView['url'] . $cateDetail['link'] . '/page/' . $maxPage . '.html');
         }
     }
     //InitParam Paging
     $arrParamPaging = array('total' => $arrListData['total'], 'page' => $intPage, 'url' => $this->view->configView['url'] . $cateDetail['link'] . '/page', 'perpage' => LIMIT_LIST_CATE, 'classPagination' => 'pagination_news', 'extEnd' => '.html', 'separate' => '/');
     //Set param
     $this->_request->setParam('block_cate', $intCateId);
     //gan meta data
     $titleMeta = $cateDetail['catename'] . ' World Cup 2014 - VnExpress';
     $keywords = 'World cup 2014, tin tuc , bong da';
     $description = 'Fifa World Cup 2014 - tin nhanh , hình ảnh , video clip bóng đá, lịch thi đấu WC 2014 tại Brazil, tường thuật bình luận bóng đá World Cup 2014';
     //Assign to view
     $this->view->assign(array('intCategoryId' => $intCateId, 'arrHotNews' => $arrHotNews, 'arrParamPaging' => $arrParamPaging, 'arrData' => $arrListData['data'], 'arrListVideo' => $arrListVideo['data'], 'arrListPhoto' => $arrListPhoto['data'], 'arrArticleExclude' => $arrArticleExclude, 'arrListExclude' => $arrListExclude, 'ogType' => 'website', 'ogTitle' => $titleMenta, 'ogUrl' => $this->view->configView['url'] . $cateDetail['link'], 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $description));
     if (DEVICE_ENV != 1) {
         //ad js
         $this->view->headScript()->appendFile($this->view->configView['vnecdn']['js'] . '/utils/calendar/calendar.js');
     } else {
         //Set no render view
         $this->_helper->viewRenderer->setNoRender(true);
         echo $this->view->render('mobile/category.phtml');
     }
     //init cate for set menu
     //set cate active
     $this->_request->setParam('cateActiveId', $intCateId);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', WORLD_CUP);
     // Set metadata tags
     $this->view->headTitle()->prepend($titleMeta);
     $this->view->headMeta()->setName('description', $description)->setName('keywords', $keywords);
 }
 /**
  * revert from web routes url to mobile url and redirect
  * @author: NhuanTP
  */
 public function mobilerevertAction()
 {
     //Disable layout
     $this->_helper->layout->disableLayout(true);
     $this->_helper->viewRenderer->setNoRender(true);
     //Get params
     $params = $this->_request->getParams();
     //Set COOKIE for PDA !important
     setcookie("VNEPDA", 1, time() + 3600, '/', '.vnexpress.net');
     //Get model article
     $objArticle = $this->view->objArticle;
     //Set href redirect
     $href = $this->view->configView['url'];
     if ($params['a'] > 0 && $params['c'] == 0) {
         $modelObject = Fpt_Data_Materials_Object::getInstance();
         $modelMatch = $modelObject->getMatch();
         $modelTeam = $modelObject->getTeam();
         // Set list matches' id
         $modelMatch->setId($params['a']);
         $matchDetail = $modelMatch->getDetailObjectBasic($params['a']);
         if (!empty($matchDetail)) {
             $team1 = $team2 = array();
             $modelTeam->setId(array($matchDetail['team1'], $matchDetail['team2']));
             $team1 = $modelTeam->getDetailObjectBasic($matchDetail['team1']);
             $team2 = $modelTeam->getDetailObjectBasic($matchDetail['team2']);
             $title = Fpt_Filter::setSeoLink($team1['name'] . ' vs ' . $team2['name']);
             $href .= "/tuong-thuat/tran-{$title}-{$params['a']}";
         }
     } elseif ($params['a'] > 0) {
         $objArticle->setIdBasic($params['a']);
         $arrArticleDetail = $objArticle->getArticleBasic($params['a']);
         $arrArticleDetail['product_id'] = 130;
         //Check detail article
         if (is_array($arrArticleDetail) && isset($arrArticleDetail['product_id'])) {
             //kiem tra mot lan nua xem co nhieu hon mot bai viet khong
             //Get model news
             $objNews = Thethao_Model_News::getInstance();
             $arrArticleId = $objNews->getArticleIdByProductId($arrArticleDetail['product_id']);
             if ($arrArticleId != -1) {
                 foreach ($arrArticleId as $index => $id) {
                     if ($id == $params['a']) {
                         unset($arrArticleId[$index]);
                     }
                 }
                 if (count($arrArticleId) > 0) {
                     //Get detail article
                     $this->view->objArticle->setIdBasic($arrArticleId[0]);
                     $arrArticleDetail = $this->view->objArticle->getArticleBasic($arrArticleId[0]);
                 }
             }
         }
         if (!empty($arrArticleDetail)) {
             //Redirect
             $this->_redirect($arrArticleDetail['share_url'], array('code' => 301));
             exit;
         }
     }
     if ($params['c'] > 0) {
         if ($params['c'] != SITE_ID) {
             //get instance Thethao_Model_Category
             $objCategory = Thethao_Model_Category::getInstance();
             //get detail cate current
             $cateDetail = $objCategory->getDetailByCateId($params['c']);
             //Check menu detail
             if (is_array($cateDetail)) {
                 $href .= $cateDetail['link'];
             }
             //end if
         }
     }
     //Redirec
     $this->_redirect($href, array('code' => 301));
     exit;
 }
Beispiel #10
0
 /**
  * get list rule 1 for job
  * @param array $arrArticleDetail
  * @author PhuongTN
  * @todo thethao
  */
 public function getArticleForJob(&$arrArticleDetail)
 {
     try {
         //get all category listed on
         $arrListOn = array();
         if (isset($arrArticleDetail['cate'][SITE_ID])) {
             $arrListOn = $arrArticleDetail['cate'][SITE_ID];
         }
         //get cate instance
         $categoryInstance = new Thethao_Model_Category();
         //init arr cate
         $arrCate = array($arrArticleDetail['original_cate']);
         //check if show_on_folder or not
         if ($arrArticleDetail['show_status'] == 1) {
             $arrCate = array_merge($arrCate, $arrListOn);
         }
         //get detail all category related
         $arrCateDetail = $categoryInstance->getDetailByArrCate($arrCate);
         //check show status
         if ($arrArticleDetail['show_status'] == 1) {
             //init rule 1 with this original_cate
             $arrCateRule1 = array($arrArticleDetail['original_cate']);
             //loop array list on to check subcate
             foreach ($arrListOn as $intCateId) {
                 if (isset($arrCateDetail[$intCateId]['child_recursive'])) {
                     //this cate recursive children
                     $listOnChild = (array) $arrCateDetail[$intCateId]['child_recursive'];
                     //check valid rule 1: article belong to subcate of liston
                     if (in_array($arrArticleDetail['original_cate'], $listOnChild)) {
                         $arrCateRule1[] = $intCateId;
                     }
                 }
                 //Update rule 1
                 //- Lấy các tin: được set folder vào folder cấp trên của X và được liston vào folder X
                 if (isset($arrCateDetail[$intCateId]['full_parent_original'])) {
                     //this cate recursive children
                     $listOnChild = (array) $arrCateDetail[$intCateId]['full_parent_original'];
                     //check valid rule 1: article belong to subcate of liston
                     if (in_array($arrArticleDetail['original_cate'], $listOnChild)) {
                         $arrCateRule1[] = $intCateId;
                     }
                 }
             }
             //end loop liston
             $arrArticleDetail['cate_rule1'] = array_unique($arrCateRule1);
             $arrArticleDetail['cate_list_on'] = array_unique($arrListOn);
         }
         $arrArticleDetail['matchId'] = false;
         //kiem tra xem bai nay co phai tuong thuat tran dau khong?=> return false/true
         if ($arrArticleDetail['article_type'] == 5) {
             //check live match is redirect to match
             if (isset($arrArticleDetail['list_object_type']) && !empty($arrArticleDetail['list_object_type'])) {
                 //check exist object match article and have 1 obj
                 if (isset($arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE]) && count($arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE] == 1)) {
                     $arrArticleDetail['matchId'] = $arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE][0];
                 }
             }
         }
     } catch (Exception $ex) {
         Thethao_Global::sendLog($ex);
     }
 }
Beispiel #11
0
 /**
  * Called after an action is dispatched by the dispatcher.
  * This callback allows for proxy or filter behavior.
  * By altering the request and resetting its dispatched flag
  * via Zend_Controller_Request_Abstract::setDispatched(false)),
  * a new action may be specified for dispatching.
  * @param Zend_Controller_Request_Abstract $request
  * @author LamTX
  */
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     $layout = Zend_Layout::getMvcInstance();
     if ($layout->isEnabled()) {
         //get cate id & cate id active
         $cateid = $request->getParam('cateid');
         $cateActiveId = $request->getParam('cateActiveId', $cateid);
         //get instance Thethao_Model_Category
         $objCategory = Thethao_Model_Category::getInstance();
         //get menu all
         $menu = $objCategory->getMenu(SITE_ID);
         //get detail cate current
         $cateDetail = $objCategory->getDetailByCateId($cateid);
         //check cate detail exists
         if (!empty($cateDetail)) {
             //get Menu Active == full parent
             $arrActiveMenu = $cateDetail['full_parent'];
             //add cate current to  Menu Active
             array_push($arrActiveMenu, $cateid, $cateActiveId);
             $arrActiveMenu = array_unique($arrActiveMenu);
             $count = count($arrActiveMenu);
             $folderHidden = false;
             if (!empty($arrActiveMenu)) {
                 $breakCumb = $objCategory->getDetailByArrCate($arrActiveMenu);
                 if ($breakCumb[$cateActiveId]['show_folder'] == 0) {
                     $folderHidden = true;
                     $breakCumbSub[$cateActiveId] = $breakCumb[$cateActiveId];
                 }
                 if (empty($breakCumb[$cateActiveId]['child']) && 1 < $count) {
                     unset($breakCumb[$cateActiveId]);
                 }
             }
             //subBreakCumb
             if (!empty($breakCumb[$cateActiveId])) {
                 $breakCumbSub = $objCategory->getDetailByArrCate($breakCumb[$cateActiveId]['child']);
                 if (!empty($breakCumbSub) || 1 < $count) {
                     $count = count($breakCumbSub);
                     foreach ($breakCumb as $k => $bc) {
                         if (1 != $bc['cate_type'] || !$bc['show_folder']) {
                             $count--;
                             unset($breakCumbSub[$k]);
                         }
                     }
                     if (0 == $count) {
                         unset($breakCumb[$cateActiveId]);
                     }
                 }
             } elseif (!empty($cateDetail['child']) && !$folderHidden) {
                 $breakCumbSub = $objCategory->getDetailByArrCate($cateDetail['child']);
             }
         } else {
             $arrActiveMenu = $breakCumb = $breakCumbSub = array();
         }
         $view = $layout->getView();
         $view->assign(array('arrMenu' => $menu['child'], 'arrActiveMenu' => $arrActiveMenu, 'breakCumb' => $breakCumb, 'breakCumbSub' => $breakCumbSub, 'menuDetail' => isset($breakCumbSub[$cateActiveId]) ? $breakCumbSub[$cateActiveId] : $cateDetail));
     }
 }
 /**
  * @todo - VnE Thethao detail page
  * @author HungNT1
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     //Get article id
     $intArticleId = (int) $this->_request->getParam('id', 0);
     //Get page
     $intPage = max(1, $this->_request->getParam('page', 1));
     $viewApp = $this->_request->getParam('view', '');
     if ($intArticleId < 1) {
         $this->_redirect('/');
         return;
     }
     //get detail full of article
     $arrArticleDetail = $this->view->objArticle->getArticleFull($intArticleId);
     //init category of article detail
     $intCategoryId = $arrArticleDetail['category_id'];
     //check other
     $arrCateOther = array(SEA_GAMES, CATE_SEA_GAMES_BENLE, CATE_SEA_GAMES_BONGDA, CATE_SEA_GAMES_BINHLUAN, CATE_SEA_GAMES_CACMONKHAC, CATE_SEA_GAMES_THONGTIN);
     //check cate in array other
     if (in_array($intCategoryId, $arrCateOther)) {
         $link_other = str_replace('http://thethao.vnexpress.net', 'http://seagames.vnexpress.net', $arrArticleDetail['share_url']);
         if ($intPage > 1) {
             $link_other = str_replace('.html', '-p' . $intPage . '.html', $link_other);
         }
         $this->_redirect($link_other . (in_array($viewApp, array('app', 'app_sport_live')) ? '?view=' . $viewApp : ''), array('code' => 301));
     }
     //check public time and now time
     if (intval($arrArticleDetail['publish_time']) > time()) {
         $sig = md5($intArticleId . $arrArticleDetail['creation_time']);
         //gen sig
         if ($sig != $this->_request->getParam('sig')) {
             $this->_redirect($this->view->configView['linkerror'][DEVICE_ENV], array('code' => 301));
         }
     }
     //Valid data
     if (empty($arrArticleDetail)) {
         $this->_redirect("/");
     }
     if ($arrArticleDetail['privacy'] & 64) {
         $this->_redirect($this->view->configView['url_vne'] . "/phong-van-truc-tuyen/" . Fpt_Filter::setSeoLink($arrArticleDetail['title_format']) . '-' . $arrArticleDetail['article_id'] . '.html');
     }
     //str link
     $strLink = $this->view->configView['url'] . $this->_request->getPathInfo();
     //forward to live action if article type is 5
     if ($arrArticleDetail['article_type'] == 5) {
         //check live match is redirect to match
         if (isset($arrArticleDetail['list_object_type']) && !empty($arrArticleDetail['list_object_type'])) {
             if (isset($arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE]) && count($arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE] == 1)) {
                 //get match detail
                 $matchId = $arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE][0];
                 $this->view->objObject->getMatch()->setId($matchId);
                 $matchDetail = $this->view->objObject->getMatch()->getDetailObjectBasic($matchId);
                 if (!empty($matchDetail)) {
                     $link_other = str_replace('/thong-ke/', '/tuong-thuat/', $matchDetail['share_url']) . (in_array($viewApp, array('app', 'app_sport_live')) ? '?view=' . $viewApp : '');
                     $this->_redirect($link_other, array('code' => 301));
                 }
             }
         }
         //check page tuong thuat and redirect to tuong thuat or tong thuat
         if ($arrArticleDetail['category_id'] == CATE_ID_TUONGTHUAT) {
             //check living or not
             if (($arrArticleDetail['privacy'] & 8) == 8) {
                 $strLink = preg_replace('#/tin-tuc/tuong-thuat/#', '/tuong-thuat/', $strLink);
             } else {
                 //get data page extend
                 $arrDataExtend = $this->view->objArticle->getDetailPageExtend($intArticleId, 2);
                 if (!empty($arrDataExtend) && !empty($arrDataExtend['content'])) {
                     unset($arrDataExtend['creation_time'], $arrDataExtend['publish_time_format'], $arrDataExtend['publish_time']);
                     //merge page extend to data detail
                     $arrArticleDetail = array_merge($arrArticleDetail, (array) $arrDataExtend);
                     //get link remove -p2
                     $strLink = preg_replace('#/tin-tuc/tuong-thuat/#', '/tong-thuat/', $strLink);
                 } else {
                     $strLink = preg_replace('#/tin-tuc/tuong-thuat/#', '/tuong-thuat/', $strLink);
                 }
             }
             if (strpos($strLink, '/tuong-thuat/') !== FALSE || strpos($strLink, '/tong-thuat/') !== FALSE) {
                 $strLink = $strLink . (in_array($viewApp, array('app', 'app_sport_live')) ? '?view=' . $viewApp : '');
                 $this->_redirect($strLink, array('code' => 301));
             }
         }
         return $this->_forward('live');
     }
     //get category on breakcumb (Using when view page > 2)
     $page = 1;
     //check page of detail
     if ($intPage > 1) {
         //get data page extend
         $arrDataExtend = $this->view->objArticle->getDetailPageExtend($intArticleId, $intPage);
         if (!empty($arrDataExtend)) {
             unset($arrDataExtend['creation_time'], $arrDataExtend['publish_time_format'], $arrDataExtend['publish_time']);
             //merge page extend to data detail
             $arrArticleDetail = array_merge($arrArticleDetail, (array) $arrDataExtend);
             //Check page_type popup
             if (2 == $arrDataExtend['page_type']) {
                 //Disable layout
                 $this->_helper->layout->disableLayout(true);
                 //Set no render view
                 $this->_helper->viewRenderer->setNoRender(true);
                 $this->view->assign(array('arrData' => $arrArticleDetail));
                 echo $this->view->render('detail/popup.phtml');
                 exit;
             }
             //end if
             //get link remove -p2
             $strLink = preg_replace('#(-p[\\d]+\\.html)#', '.html', $strLink);
             $page = $intPage;
         } else {
             $strLink = '';
         }
     }
     //check redirect link
     if ($strLink != $arrArticleDetail['share_url'] && APPLICATION_ENV != 'development') {
         $link_more = $arrArticleDetail['share_url'];
         if ($page > 1) {
             $link_more = str_replace('.html', '-p' . $page . '.html', $arrArticleDetail['share_url']);
         }
         $this->_redirect($link_more . ($viewApp == 'app' ? '?view=app' : ''), array('code' => 301));
     }
     //check view app
     if (!empty($viewApp) && $viewApp == 'app') {
         //Disable layout
         $this->_helper->layout->disableLayout(true);
         $content = $arrArticleDetail['content'];
         $content = preg_replace('/src="(.[^>]*)_500x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*).(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*)_m_460x0_m_460x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $arrArticleDetail['content'] = $content;
         //Trim data
         $arrArticleDetail['title'] = trim($arrArticleDetail['title']);
         $arrArticleDetail['title_format'] = trim($arrArticleDetail['title_format']);
         $arrArticleDetail['lead'] = trim($arrArticleDetail['lead']);
         // Assign to view
         $this->view->assign(array('arrArticleDetail' => $arrArticleDetail, 'intCategoryId' => $intCategoryId, 'intArticleId' => $intArticleId, 'ogType' => 'website', 'ogTitle' => $arrArticleDetail['title_format'] . ' - VnExpress Thể Thao', 'ogUrl' => $arrArticleDetail['share_url'], 'ogImage' => !empty($arrArticleDetail['thumbnail_url']) ? $this->view->ImageurlArticle($arrArticleDetail, 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8')))));
         // SEO
         $arrKeyword = array();
         $arrArticleDetail['title'] = html_entity_decode($arrArticleDetail['title'], ENT_QUOTES, 'UTF-8');
         $this->view->headTitle($arrArticleDetail['title'] . ' - VnExpress Thể Thao');
         $this->view->headMeta()->setName('description', trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8'))))->setName('keywords', join(',', $arrKeyword));
         echo $this->view->render('detail/app.phtml');
         exit;
     }
     //get topic of article detail
     //set topic show style
     $topic_show_style = 1;
     //init topic default
     $arrTopic = array();
     $arrTopicDetail = array();
     //set recommend
     $arrRecommend = array('data' => array(), 'total' => 0);
     if (!empty($arrArticleDetail['list_topic_id'])) {
         //init model topic
         $modelTopic = new Fpt_Data_News_Topic();
         // init topic params
         $arrTopicParams = array('site_id' => 1000000, 'topic_id' => $arrArticleDetail['list_topic_id'], 'limit' => LIMIT_TOPIC_DETAIL + 1, 'offset' => 0, 'withscore' => true, 'article_type' => NULL);
         // get list article by topic
         $arrTopic = $modelTopic->getTopicNewsByScore($arrTopicParams);
         // check array topic data
         if (!empty($arrTopic)) {
             $score = 0;
             $temp_topic_id = 0;
             foreach ($arrArticleDetail['list_topic_id'] as $index => $topic_id) {
                 if (isset($arrTopic[$topic_id]['data'][$intArticleId])) {
                     unset($arrTopic[$topic_id]['data'][$intArticleId]);
                     $arrTopic[$topic_id]['total'] = $arrTopic[$topic_id]['total'] - 1;
                 }
                 if (empty($arrTopic[$topic_id]['data'])) {
                     unset($arrArticleDetail['list_topic_id'][$index]);
                     unset($arrTopic[$topic_id]);
                     continue;
                 }
                 // get first article to compare
                 $firstCore = current($arrTopic[$topic_id]['data']);
                 if ($firstCore > $score) {
                     $temp_topic_id = $topic_id;
                     $score = $firstCore;
                 }
             }
             // get detail of topic id list
             $arrTopicDetail = $modelTopic->getDetailTopicByArrId(array($temp_topic_id));
             //shift data
             $arrShift = isset($arrArticleDetail['list_topic_full'][$temp_topic_id]) ? $arrArticleDetail['list_topic_full'][$temp_topic_id] : array_shift($arrArticleDetail['list_topic_full']);
             //set topic style topic
             $topic_show_style = $arrShift['show_style'] != 2 ? 1 : $arrShift['show_style'];
             //array slice list article
             $arrTopic = array_slice(array_keys($arrTopic[$temp_topic_id]['data']), 0, $topic_show_style == 1 ? LIMIT_TOPIC_DETAIL_STYLE_1 : LIMIT_TOPIC_DETAIL_STYLE_2);
         }
     }
     //check neu empty data topic + link cheo moi xuat recommend
     if (empty($arrTopic) && empty($arrArticleDetail['list_reference_sites_id'])) {
         // Recommendation
         $arrRecommendParams = array('article_id' => $intArticleId, 'limit' => LIMIT_TOPIC_DETAIL_STYLE_1 + 1, 'offset' => 0);
         $arrRecommend = $this->view->objArticle->getRecommendationById($arrRecommendParams);
         //valid data
         if (!empty($arrRecommend['data'])) {
             $arrRecommend['data'] = array_diff($arrRecommend['data'], array($intArticleId));
             $arrRecommend['data'] = array_slice($arrRecommend['data'], 0, LIMIT_TOPIC_DETAIL_STYLE_1);
             // set to article instance
             $this->view->objArticle->setIdBasic($arrRecommend['data']);
         }
     }
     //end get topic of article detail
     //get cate instance
     $modelCategory = Thethao_Model_Category::getInstance();
     // Get parent info
     $arrCateInfo = $modelCategory->getDetailbyCateId($intCategoryId);
     $intOtherCate = $intCategoryId;
     //check cate result
     if (!empty($arrCateInfo) && !empty($arrCateInfo['parent_id'])) {
         //check parent_id
         if (SITE_ID != $arrCateInfo['parent_id']) {
             $intOtherCate = $arrCateInfo['parent_id'];
         }
     }
     //get other news of article detail from commendation
     $arrOrtherArticle = array();
     $instanceNews = Thethao_Model_News::getInstance();
     //get list top 15 article with rule 2
     $arrNewsArticle = $instanceNews->getListArticleIdsByRule2(array('category_id' => $intOtherCate, 'limit' => LIMIT_OTHER_NEWS + 1, 'offset' => 0, 'article_type' => NULL));
     if (count($arrNewsArticle['data']) > LIMIT_OTHER_NEWS) {
         $arrDiff = array_diff($arrNewsArticle['data'], array($intArticleId));
         $arrNewsArticle['data'] = array_slice($arrDiff, 0, LIMIT_OTHER_NEWS);
     }
     //set flag check exclude
     $flag = false;
     //check is empty list news
     if (is_array($arrNewsArticle) && !empty($arrNewsArticle['data'])) {
         if (in_array($intArticleId, $arrNewsArticle['data'])) {
             $flag = true;
             //excluse current article
             $arrOrtherArticle = array_diff($arrNewsArticle['data'], array($intArticleId));
         } else {
             $arrOrtherArticle = $arrNewsArticle['data'];
         }
         //then slice to get only 14 item
         $arrOrtherArticle = array_slice($arrOrtherArticle, 0, LIMIT_OTHER_NEWS);
     }
     //end check is empty latest news
     //end get other news of article detail
     //get top view article
     $arrTopViewID = array();
     if (DEVICE_ENV != 1) {
         //get top view with rule 4
         $arrTopViewData = $instanceNews->getListArticleIdsByRule4(array('category_id' => $intOtherCate, 'offset' => 0, 'limit' => LIMIT_TOP_VIEW + 1));
         if (!empty($arrTopViewData)) {
             //excluse current article
             $arrTopViewID = array_diff($arrTopViewData, array($intArticleId));
             $arrTopViewID = array_slice($arrTopViewID, 0, LIMIT_TOP_VIEW);
         }
     }
     //end get top view article
     //array merge article id to set id basic
     $arrArticleIds = array_unique(array_merge($arrTopic, $arrOrtherArticle, $arrTopViewID));
     $this->view->objArticle->setIdBasic($arrArticleIds);
     //Set category id for block_cate user in block & menu breakumb
     $this->_request->setParam('block_cate', $intCategoryId);
     //init cate for set menu
     $idCateMenu = $arrCateInfo['parent_id'] == SITE_ID ? $intCategoryId : $arrCateInfo['parent_id'];
     //set cate active
     $this->_request->setParam('cateActiveId', $intCategoryId);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', $idCateMenu);
     //get Instance Block
     $objBlock = Thethao_Plugin_Block::getInstance();
     //set exclude for detail
     $objBlock->setExclude(array($intArticleId));
     //replace image size for mobile
     if (DEVICE_ENV == 1) {
         $content = $arrArticleDetail['content'];
         $content = preg_replace('/src="(.[^>]*)_500x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*).(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*)_m_460x0_m_460x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $arrArticleDetail['content'] = $content;
     }
     //Trim data
     $arrArticleDetail['title'] = trim($arrArticleDetail['title']);
     $arrArticleDetail['title_format'] = trim($arrArticleDetail['title_format']);
     $arrArticleDetail['lead'] = trim($arrArticleDetail['lead']);
     // Assign to view
     $this->view->assign(array('arrRecommend' => $arrRecommend, 'arrNewsArticle' => $arrNewsArticle, 'arrOrtherArticle' => $arrOrtherArticle, 'flagExc' => $flag, 'totalPageOtherNews' => intval(ceil($arrNewsArticle['total'] / LIMIT_OTHER_NEWS)), 'isArticleHotVnE' => $arrArticleDetail['privacy'] & 512, 'arrTopViewID' => $arrTopViewID, 'parentCategoryID' => $arrCateInfo['parent_id'], 'arrArticleDetail' => $arrArticleDetail, 'intCategoryId' => $intCategoryId, 'intArticleId' => $intArticleId, 'intOtherCate' => $intOtherCate, 'intViewApp' => empty($viewApp) ? 0 : 1, 'isAdsFullScreen' => $arrArticleDetail['privacy'] & 2048, 'topic_show_style' => $topic_show_style, 'arrTopic' => $arrTopic, 'arrTopicDetail' => $arrTopicDetail[$temp_topic_id], 'ogType' => 'website', 'ogTitle' => $arrArticleDetail['title_format'] . ' - VnExpress Thể Thao', 'ogUrl' => $arrArticleDetail['share_url'], 'ogImage' => !empty($arrArticleDetail['thumbnail_url']) ? $this->view->ImageurlArticle($arrArticleDetail, 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8')))));
     // SEO
     $arrKeyword = array();
     $arrArticleDetail['title'] = html_entity_decode($arrArticleDetail['title'], ENT_QUOTES, 'UTF-8');
     $this->view->headTitle($arrArticleDetail['title'] . ' - VnExpress Thể Thao');
     $this->view->headMeta()->setName('description', trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8'))))->setName('keywords', join(',', $arrKeyword));
 }
$Autoloader->registerNamespace('Thethao_')->registerNamespace('Fpt_')->registerNamespace('Job_');
//get application conf
$arrConfig = Thethao_Global::getConfig('job');
//new application conf
$application = new Application($arrConfig);
//set to bootstrap params
Zend_Controller_Front::getInstance()->setParam('bootstrap', $application);
//unset applicaion
unset($application);
//Try execute
$result = array();
try {
    //get model news
    $modelNews = Thethao_Model_News::getInstance();
    //get model category
    $modelCategory = Thethao_Model_Category::getInstance();
    //get full array cate
    $arrCate = $modelCategory->getFullCategoryByParentId();
    //only get id
    $arrCate = array_keys($arrCate);
    //add site_id
    $arrCate[] = SITE_ID;
    //clear cache
    $result['interaction'] = $modelNews->clearCacheTop('all', $arrCate);
    //get top view 24h all Site
    $result['top_view_all_site'] = $modelNews->getTopView24hAllSite();
    //Closed all resource
    Thethao_Global::closeResource();
    Fpt_Data_Model::_destruct();
} catch (Exception $ex) {
    //send log
Beispiel #14
0
 /**
  * job edit/delete article
  * @param type $data
  * @return type
  */
 public function updateCategory()
 {
     //default return
     $response = false;
     try {
         $modelCate = Thethao_Model_Category::getInstance();
         $response = $modelCate->editCategory();
     } catch (Exception $ex) {
         //log error
         Thethao_Global::sendLog($ex);
     }
     return $response;
 }
 public function Categoryname($intCateID)
 {
     $arrCatInfo = Thethao_Model_Category::getInstance()->getDetailbyCateId($intCateID);
     return empty($arrCatInfo) ? '' : $arrCatInfo['catename'];
 }
 /**
  * @todo - VnE Thethao Rss Detail Page
  * @author HungNT1
  */
 public function detailAction()
 {
     //Set no view & no layout
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     header("Content-Type: application/xml; charset=utf-8");
     //Auto refesh
     $this->view->headMeta()->appendHttpEquiv('refesh', '300');
     $strCodeTinMoi = 'tin-moi-nhat';
     $strCodeTinHot = 'tin-hot';
     //Get cate_id
     $cate = $this->_request->getParam('cate');
     if ($strCodeTinMoi !== $cate && $strCodeTinHot != $cate) {
         if ($cate == null) {
             $this->_redirect($this->view->configView['url']);
         }
         $category = Thethao_Model_Category::getInstance();
         $result = $category->getCategoryByCode($cate);
         $cate_id = $result['category_id'];
         if ($cate_id < 0 || $cate_id == null) {
             $this->_redirect($this->view->configView['url']);
         }
     }
     //Get instance
     $modelNews = Thethao_Model_News::getInstance();
     //Create parent feed
     $feed = new Zend_Feed_Writer_Feed();
     $feed->setGenerator('Thehao.VnExpress.net:' . $this->view->configView['url'] . '/rss');
     $feed->setDateModified(time());
     $feed->setDescription('VNExpress Thể thao RSS');
     if ($cate == $strCodeTinMoi) {
         //redirect to vne
         $this->_redirect($this->view->configView['url_vne'] . '/rss/the-thao.rss', array('code' => 301));
     } elseif ($cate == $strCodeTinHot) {
         // Get lastest article in 1 days
         $arrParams = array('area' => array(0 => array('category_id' => SITE_ID, 'showed_area' => 'trangchu')), 'offset' => 0, 'limit' => 100);
         $arrLastestArticleID = $this->view->objArticle->getTopHotArticleByArr($arrParams);
         if (!empty($arrLastestArticleID[0])) {
             foreach ($arrLastestArticleID[0] as $val) {
                 $val['article_id'] = intval($val['article_id']);
                 $entry = $feed->createEntry();
                 $link = '';
                 $link .= $val['share_url'];
                 if ($val['title'] != null) {
                     $entry->setTitle($val['title']);
                 }
                 if ($val['share_url'] != null) {
                     $entry->setLink($link);
                 }
                 if ($val['update_time'] > 0) {
                     $entry->setDateModified($val['update_time']);
                 }
                 if ($val['publish_time'] > 0) {
                     $entry->setDateCreated($val['publish_time']);
                 }
                 $val['lead'] != null ? $entry->setDescription('<a href="' . $link . '"><img width=130 height=100 src="' . $this->view->ImageurlArticle($val, 'size1') . '" ></a></br>' . $val['lead']) : $entry->setDescription('No Description');
                 $feed->addEntry($entry);
             }
         }
         $result['catename'] = 'Tin hot';
     } else {
         // Get list article with rule 3
         $arrPamram = array('category_id' => $cate_id, 'site_id' => SITE_ID, 'offset' => 0, 'limit' => 20);
         $arrTopArticleID = $modelNews->getListArticleIdsByRule3($arrPamram);
         //Add entry
         if (!empty($arrTopArticleID['data'])) {
             $this->view->objArticle->setIdBasic($arrTopArticleID['data']);
             foreach ($arrTopArticleID['data'] as $id) {
                 $val = $this->view->objArticle->getArticleBasic($id);
                 if (empty($val)) {
                     continue;
                 }
                 $link = $val['share_url'];
                 $entry = $feed->createEntry();
                 if ($val['title'] != null) {
                     $entry->setTitle($val['title']);
                 }
                 if (!empty($link) && null != $link) {
                     $entry->setLink($link);
                 }
                 if ($val['update_time'] != null) {
                     $entry->setDateModified($val['update_time']);
                 }
                 if ($val['creation_time'] != null) {
                     $entry->setDateCreated($val['creation_time']);
                 }
                 $val['lead'] != null ? $entry->setDescription('<a href="' . $link . '"><img width=130 height=100 src="' . $this->view->ImageurlArticle($val, 'size5') . '" ></a></br>' . $val['lead']) : $entry->setDescription('No Description');
                 $feed->addEntry($entry);
             }
         }
     }
     $feed->setTitle($result['catename'] . ' - VNExpress Thể thao RSS');
     $feed->setLink('http://thethao.vnexpress.net/rss/' . $cate . '.rss');
     //Create xml
     $out = $feed->export('rss');
     echo $out;
 }
 /**
  * @todo - VnE Thethao detail page
  * @author ThuyNT2
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     //Get article id
     $intArticleId = (int) $this->_request->getParam('id', 0);
     //Get page
     $intPage = max(1, $this->_request->getParam('page', 1));
     $viewApp = $this->_request->getParam('view', '');
     $modelTeam = Thethao_Model_Team::getInstance();
     if ($intArticleId < 1) {
         $this->_redirect('/');
         return;
     }
     //get detail full of article
     $arrArticleDetail = $this->view->objArticle->getArticleFull($intArticleId);
     //init category of article detail
     $intCategoryId = $arrArticleDetail['category_id'];
     $arrCateWorldcup = array(WORLD_CUP, CATE_ID_TINTUC, CATE_ID_BINHLUAN, CATE_ID_BENLE, CATE_ID_LICHSU);
     //check cate in array worldcup
     if (!in_array($intCategoryId, $arrCateWorldcup)) {
         $this->_redirect($arrArticleDetail['share_url'] . ($viewApp == 'app' ? '?view=app' : ''), array('code' => 301));
     }
     //forward to live action if article type is 5
     if ($arrArticleDetail['article_type'] == 5) {
         //check live match is redirect to match
         if (isset($arrArticleDetail['list_object_type']) && !empty($arrArticleDetail['list_object_type'])) {
             if (isset($arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE]) && count($arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE] == 1)) {
                 //get match detail
                 $matchId = $arrArticleDetail['list_object_type'][OBJECT_TYPE_MATCH_ARTICLE][0];
                 $this->view->objObject->getMatch()->setId($matchId);
                 $matchDetail = $this->view->objObject->getMatch()->getDetailObjectBasic($matchId);
                 if (!empty($matchDetail)) {
                     $link_worldcup = str_replace('http://thethao.vnexpress.net/thong-ke/', 'http://worldcup.vnexpress.net/report/', $matchDetail['share_url']);
                     $this->_redirect($link_worldcup . ($viewApp == 'app' ? '?view=app' : ''), array('code' => 301));
                 }
             }
         }
         return $this->_forward('live');
     }
     if (!empty($arrArticleDetail['list_object_type'])) {
         foreach ($arrArticleDetail['list_object_type'] as $type => $arrObjId) {
             $this->view->objObject->getObjectByType($type)->setId($arrObjId);
         }
     }
     // detail infomation player
     $arrPlayerData = array();
     if (isset($arrArticleDetail['list_object_type'][OBJECT_TYPE_PLAYER]) && !empty($arrArticleDetail['list_object_type'][OBJECT_TYPE_PLAYER])) {
         $countPlayer = count($arrArticleDetail['list_object_type'][OBJECT_TYPE_PLAYER]);
         foreach ($arrArticleDetail['list_object_type'][OBJECT_TYPE_PLAYER] as $player_id) {
             $arrPlayerData[$player_id] = $this->view->objObject->getObjectByType(OBJECT_TYPE_PLAYER)->getDetailObjectBasic($player_id);
         }
         if ($countPlayer == 1) {
             $player_id = array_shift($arrArticleDetail['list_object_type'][OBJECT_TYPE_PLAYER]);
             //init param get news of playser
             $arrParamNews = array('object_id' => $player_id, 'object_type' => OBJECT_TYPE_PLAYER, 'limit' => LIMIT_NEWS_PLAYER, 'offset' => 0);
             $objectNews = $this->view->objArticle->getObjectNews($arrParamNews);
             if (!empty($objectNews['data'])) {
                 $objectNews['data'] = array_diff($objectNews['data'], array($intArticleId));
                 $this->view->objArticle->setIdBasic($objectNews['data']);
                 $arrPlayerData[$player_id]['object_news'] = $objectNews['data'];
             }
         }
         if (!empty($arrPlayerData)) {
             $arrPlayerData = array_slice($arrPlayerData, 0, 4);
         }
     }
     //thong tin doi bong va tran dau gan day
     $arrTeamData = array();
     if (isset($arrArticleDetail['list_object_type'][OBJECT_TYPE_TEAM]) && !empty($arrArticleDetail['list_object_type'][OBJECT_TYPE_TEAM])) {
         foreach ($arrArticleDetail['list_object_type'][OBJECT_TYPE_TEAM] as $teamId) {
             $arrTeamData[$teamId] = $this->view->objObject->getObjectByType(OBJECT_TYPE_TEAM)->getDetailObjectBasic($teamId);
             $arrTeamData[$teamId]['extend'] = $modelTeam->getDetailTeamExtendByIDs(array($teamId));
             $minHappenDateTime = $arrArticleDetail['publish_time'];
             $maxHappenDateTime = 1405382400;
             // ngay 15-7-2014
             //get match id
             $arrMatchId[$teamId] = array();
             $arrMatchIdOld = array();
             $arrMatchIdFuture = $this->view->objObject->getObjectByType(OBJECT_TYPE_TEAM)->getMatchIDsByTeam($teamId, $maxHappenDateTime, $minHappenDateTime, false);
             $countMatch = count($arrMatchIdFuture);
             if ($countMatch < 3) {
                 $arrMatchIdOld = $this->view->objObject->getObjectByType(OBJECT_TYPE_TEAM)->getMatchIDsByTeam($teamId, $minHappenDateTime, 1402632000, false);
                 $arrMatchId[$teamId] = $arrMatchIdFuture + $arrMatchIdOld;
                 if (!empty($arrMatchId[$teamId])) {
                     asort($arrMatchId[$teamId]);
                 }
             } else {
                 $arrMatchId[$teamId] = $arrMatchIdFuture;
             }
             if (count($arrMatchId[$teamId]) > 3) {
                 $arrMatchId[$teamId] = array_slice($arrMatchId[$teamId], 0, 3, true);
             }
             $arrMatchId[$teamId] = array_keys($arrMatchId[$teamId]);
             unset($arrMatchIdFuture, $arrMatchIdOld);
             if (!empty($arrMatchId[$teamId])) {
                 $arrMatchId[$teamId] = array_unique($arrMatchId[$teamId]);
                 $this->view->objObject->getObjectByType(OBJECT_TYPE_MATCH)->setId($arrMatchId[$teamId]);
                 //get match detail
                 foreach ($arrMatchId[$teamId] as $matchId) {
                     $arrTeamData[$teamId]['match_detail'][$matchId] = $this->view->objObject->getObjectByType(OBJECT_TYPE_MATCH)->getDetailObjectBasic($matchId);
                 }
             }
         }
         if (!empty($arrTeamData)) {
             $arrTeamData = array_slice($arrTeamData, 0, 4);
         }
     }
     //end
     //Du doan doi vo dich & vua pha luoi
     // Get models instance
     $modelFootball = Thethao_Model_Football::getInstance();
     // Get detail table ranking by league and season
     $arrAllMatch = $modelFootball->getListTableRanking(SEASON_ID, LEAGUE_ID);
     if (!empty($arrAllMatch)) {
         //set id object
         $this->view->objObject->getTeam()->setId(array_keys($arrAllMatch));
     }
     //end
     //check public time and now time
     if (intval($arrArticleDetail['publish_time']) > time()) {
         $sig = md5($id . $arrArticleDetail['creation_time']);
         //gen sig
         if ($sig != $this->_request->getParam('sig')) {
             $this->_redirect($this->view->configView['linkerror'][DEVICE_ENV], array('code' => 301));
         }
     }
     //Valid data
     if (empty($arrArticleDetail)) {
         $this->_redirect("/");
     }
     //str link
     $strLink = $this->_request->getPathInfo();
     //get category on breakcumb (Using when view page > 2)
     $page = 1;
     //check page of detail
     if ($intPage > 1) {
         //get data page extend
         $arrDataExtend = $this->view->objArticle->getDetailPageExtend($intArticleId, $intPage);
         if (!empty($arrDataExtend)) {
             unset($arrDataExtend['creation_time'], $arrDataExtend['publish_time_format'], $arrDataExtend['publish_time']);
             //merge page extend to data detail
             $arrArticleDetail = array_merge($arrArticleDetail, (array) $arrDataExtend);
             //Check page_type popup
             if (2 == $arrDataExtend['page_type']) {
                 //Disable layout
                 $this->_helper->layout->disableLayout(true);
                 //Set no render view
                 $this->_helper->viewRenderer->setNoRender(true);
                 $this->view->assign(array('arrData' => $arrArticleDetail));
                 echo $this->view->render('detail/popup.phtml');
                 exit;
             }
             //end if
             //get link remove -p2
             $strLink = preg_replace('#(-p[\\d]+\\.html)#', '.html', $strLink);
             $page = $intPage;
         } else {
             $strLink = '';
         }
     }
     //check redirect link
     if (strpos($arrArticleDetail['share_url'], $strLink) === FALSE && APPLICATION_ENV != 'development') {
         $link_more = $this->view->ShareurlWorldcup($arrArticleDetail['share_url']);
         if ($page > 1) {
             $link_more = str_replace('.html', '-p' . $page . '.html' . ($viewApp == 'app' ? '?view=app' : ''), $arrArticleDetail['share_url']);
         }
         $this->_redirect($link_more, array('code' => 301));
     }
     //check view app
     if (!empty($viewApp) && $viewApp == 'app') {
         //Disable layout
         $this->_helper->layout->disableLayout(true);
         $content = $arrArticleDetail['content'];
         $content = preg_replace('/src="(.[^>]*)_500x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*).(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*)_m_460x0_m_460x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $arrArticleDetail['content'] = $content;
         //Trim data
         $arrArticleDetail['title'] = trim($arrArticleDetail['title']);
         $arrArticleDetail['title_format'] = trim($arrArticleDetail['title_format']);
         $arrArticleDetail['lead'] = trim($arrArticleDetail['lead']);
         // Assign to view
         $this->view->assign(array('flagExc' => $flag, 'isArticleHotVnE' => $arrArticleDetail['privacy'] & 512, 'parentCategoryID' => $arrCateInfo['parent_id'], 'arrArticleDetail' => $arrArticleDetail, 'intCategoryId' => $intCategoryId, 'intArticleId' => $intArticleId, 'arrTeamData' => $arrTeamData, 'arrMatchId' => $arrMatchId, 'arrPlayerData' => $arrPlayerData, 'arrAllMatch' => $arrAllMatch, 'intOtherCate' => $intOtherCate, 'arrNewsArticle' => $arrNewsArticle, 'arrOrtherArticle' => $arrOrtherArticle, 'flagExc' => $flag, 'totalPageOtherNews' => $totalPage, 'totalOtherNews' => $arrNewsArticle['total'], 'intPage' => 1, 'intCateIdPolyAds' => $arrArticleDetail['category_id'], 'articleTrackingId' => $arrArticleDetail['article_id'], 'arrTopic' => $arrTopic, 'arrTopicDetail' => $arrTopicDetail[$temp_topic_id], 'isDetail' => 1, 'ogType' => 'website', 'ogTitle' => $arrArticleDetail['title_format'] . ' - VnExpress World Cup', 'ogUrl' => $share_url, 'ogImage' => !empty($arrArticleDetail['thumbnail_url']) ? $this->view->ImageurlArticle($arrArticleDetail, 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8')))));
         // SEO
         $arrKeyword = 'World cup 2014, tin tuc , bong da';
         $arrArticleDetail['title'] = html_entity_decode($arrArticleDetail['title'], ENT_QUOTES, 'UTF-8');
         $this->view->headTitle($arrArticleDetail['title'] . ' - VnExpress');
         $this->view->headMeta()->setName('description', trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8'))))->setName('keywords', $arrKeyword);
         echo $this->view->render('detail/app.phtml');
         exit;
     }
     //get topic of article detail
     //init topic default
     $arrTopic = array();
     $arrTopicDetail = array();
     if (!empty($arrArticleDetail['list_topic_id'])) {
         //init model topic
         $modelTopic = new Fpt_Data_News_Topic();
         // init topic params
         $arrTopicParams = array('site_id' => 1000000, 'topic_id' => $arrArticleDetail['list_topic_id'], 'limit' => LIMIT_TOPIC_DETAIL + 1, 'offset' => 0, 'withscore' => true, 'article_type' => NULL);
         // get list article by topic
         $arrTopic = $modelTopic->getTopicNewsByScore($arrTopicParams);
         // check array topic data
         if (!empty($arrTopic)) {
             $score = 0;
             $temp_topic_id = 0;
             foreach ($arrArticleDetail['list_topic_id'] as $index => $topic_id) {
                 if (isset($arrTopic[$topic_id]['data'][$intArticleId])) {
                     unset($arrTopic[$topic_id]['data'][$intArticleId]);
                 }
                 if (empty($arrTopic[$topic_id]['data'])) {
                     unset($arrArticleDetail['list_topic_id'][$index]);
                     continue;
                 }
                 // get first article to compare
                 $firstCore = current($arrTopic[$topic_id]['data']);
                 if ($firstCore > $score) {
                     $temp_topic_id = $topic_id;
                     $score = $firstCore;
                 }
             }
             // get detail of topic id list
             $arrTopicDetail = $modelTopic->getDetailTopicByArrId(array($temp_topic_id));
             $arrTopic = array_slice(array_keys($arrTopic[$temp_topic_id]['data']), 0, LIMIT_TOPIC_DETAIL);
             //set id
             $this->view->objArticle->setIdBasic($arrTopic);
         }
     }
     //end get topic of article detail
     //get other news of article detail
     //array default other news
     $arrOrtherArticle = array();
     //get cate instance
     $modelCategory = Thethao_Model_Category::getInstance();
     // Get parent info
     $arrCateInfo = $modelCategory->getDetailbyCateId($intCategoryId);
     $intOtherCate = $intCategoryId;
     //check cate result
     if (!empty($arrCateInfo) && !empty($arrCateInfo['parent_id'])) {
         //check parent_id
         if (SITE_ID != $arrCateInfo['parent_id']) {
             $intOtherCate = $arrCateInfo['parent_id'];
         }
     }
     // Get article detail
     $instanceNews = Thethao_Model_News::getInstance();
     //get list top 15 article with rule 2
     $arrNewsArticle = $instanceNews->getListArticleIdsByRule2(array('category_id' => $intOtherCate, 'limit' => LIMIT_OTHER_NEWS + 1, 'offset' => 0, 'article_type' => NULL));
     if (count($arrNewsArticle['data']) > LIMIT_OTHER_NEWS) {
         $arrDiff = array_diff($arrNewsArticle['data'], array($intArticleId));
         $arrNewsArticle['data'] = array_slice($arrDiff, 0, LIMIT_OTHER_NEWS);
     }
     //set flag check exclude
     $flag = false;
     //check is empty list news
     if (is_array($arrNewsArticle) && !empty($arrNewsArticle['data'])) {
         if (in_array($intArticleId, $arrNewsArticle['data'])) {
             $flag = true;
             //excluse current article
             $arrOrtherArticle = array_diff($arrNewsArticle['data'], array($intArticleId));
         } else {
             $arrOrtherArticle = $arrNewsArticle['data'];
         }
         //then slice to get only 14 item
         $arrOrtherArticle = array_slice($arrOrtherArticle, 0, LIMIT_OTHER_NEWS);
     }
     //end check is empty latest news
     $totalPage = intval(ceil(($arrNewsArticle['total'] - 1) / LIMIT_OTHER_NEWS));
     //end get other news of article detail
     $arrArticleIds = array_unique(array_merge($arrOrtherArticle));
     $this->view->objArticle->setIdBasic($arrArticleIds);
     //Set category id for block_cate user in block & menu breakumb
     $this->_request->setParam('block_cate', $intCategoryId);
     //init cate for set menu
     $idCateMenu = $arrCateInfo['parent_id'] == SITE_ID ? $intCategoryId : $arrCateInfo['parent_id'];
     //set cate active
     $this->_request->setParam('cateActiveId', $intCategoryId);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', $idCateMenu);
     //get Instance Block
     $objBlock = Thethao_Plugin_Block::getInstance();
     //set exclude for detail
     $objBlock->setExclude(array($intArticleId));
     //replace image size for mobile
     if (DEVICE_ENV == 1) {
         $content = $arrArticleDetail['content'];
         $content = preg_replace('/src="(.[^>]*)_500x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*).(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*)_m_460x0_m_460x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $arrArticleDetail['content'] = $content;
     }
     //Trim data
     $arrArticleDetail['title'] = trim($arrArticleDetail['title']);
     $arrArticleDetail['title_format'] = trim($arrArticleDetail['title_format']);
     $arrArticleDetail['lead'] = trim($arrArticleDetail['lead']);
     $share_url = str_replace('http://thethao.vnexpress.net', 'http://worldcup.vnexpress.net', $arrArticleDetail['share_url']);
     // Assign to view
     $this->view->assign(array('flagExc' => $flag, 'isArticleHotVnE' => $arrArticleDetail['privacy'] & 512, 'parentCategoryID' => $arrCateInfo['parent_id'], 'arrArticleDetail' => $arrArticleDetail, 'intCategoryId' => $intCategoryId, 'intArticleId' => $intArticleId, 'arrTeamData' => $arrTeamData, 'arrMatchId' => $arrMatchId, 'arrPlayerData' => $arrPlayerData, 'arrAllMatch' => $arrAllMatch, 'intOtherCate' => $intOtherCate, 'arrNewsArticle' => $arrNewsArticle, 'arrOrtherArticle' => $arrOrtherArticle, 'flagExc' => $flag, 'totalPageOtherNews' => $totalPage, 'totalOtherNews' => $arrNewsArticle['total'], 'intPage' => 1, 'intCateIdPolyAds' => $arrArticleDetail['category_id'], 'articleTrackingId' => $arrArticleDetail['article_id'], 'arrTopic' => $arrTopic, 'arrTopicDetail' => $arrTopicDetail[$temp_topic_id], 'isDetail' => 1, 'ogType' => 'website', 'ogTitle' => $arrArticleDetail['title_format'] . ' - VnExpress World Cup', 'ogUrl' => $share_url, 'ogImage' => !empty($arrArticleDetail['thumbnail_url']) ? $this->view->ImageurlArticle($arrArticleDetail, 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8')))));
     // SEO
     $arrKeyword = 'World cup 2014, tin tuc , bong da';
     $arrArticleDetail['title'] = html_entity_decode($arrArticleDetail['title'], ENT_QUOTES, 'UTF-8');
     $this->view->headTitle($arrArticleDetail['title'] . ' - VnExpress');
     $this->view->headMeta()->setName('description', trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8'))))->setName('keywords', $arrKeyword);
 }
 /**
  * @todo - VnE Thethao detail page
  * @author ThuyNT2
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     //Get article id
     $intArticleId = (int) $this->_request->getParam('id', 0);
     //Get page
     $intPage = max(1, $this->_request->getParam('page', 1));
     $viewApp = $this->_request->getParam('view', '');
     if ($intArticleId < 1) {
         $this->_redirect('/');
         return;
     }
     //get detail full of article
     $arrArticleDetail = $this->view->objArticle->getArticleFull($intArticleId);
     //init category of article detail
     $intCategoryId = $arrArticleDetail['category_id'];
     $arrCateOther = array(SEA_GAMES, CATE_SEA_GAMES_BONGDA, CATE_SEA_GAMES_ANH, CATE_SEA_GAMES_VIDEO, CATE_SEA_GAMES_CACMONKHAC, CATE_SEA_GAMES_BINHLUAN, CATE_SEA_GAMES_BENLE, CATE_SEA_GAMES_THONGTIN);
     //check cate in array other
     if (!in_array($intCategoryId, $arrCateOther)) {
         $this->_redirect($arrArticleDetail['share_url'] . ($viewApp == 'app' ? '?view=app' : ''), array('code' => 301));
     }
     //str link
     $strLink = $this->view->configView['url'] . $this->_request->getPathInfo();
     //forward to live action if article type is 5
     if ($arrArticleDetail['article_type'] == 5) {
         //check page tuong thuat and redirect to tuong thuat or tong thuat
         if ($arrArticleDetail['category_id'] == SEA_GAMES) {
             //check living or not
             if (($arrArticleDetail['privacy'] & 8) == 8) {
                 $strLink = preg_replace('#/tin-tuc/sea-games/#', '/tuong-thuat/', $strLink);
             } else {
                 //get data page extend
                 $arrDataExtend = $this->view->objArticle->getDetailPageExtend($intArticleId, 2);
                 if (!empty($arrDataExtend) && !empty($arrDataExtend['content'])) {
                     unset($arrDataExtend['creation_time'], $arrDataExtend['publish_time_format'], $arrDataExtend['publish_time']);
                     //merge page extend to data detail
                     $arrArticleDetail = array_merge($arrArticleDetail, (array) $arrDataExtend);
                     //get link remove -p2
                     $strLink = preg_replace('#/tin-tuc/sea-games/#', '/tong-thuat/', $strLink);
                 } else {
                     $strLink = preg_replace('#/tin-tuc/sea-games/#', '/tuong-thuat/', $strLink);
                 }
             }
             if (strpos($strLink, '/tuong-thuat/') !== false || strpos($strLink, '/tong-thuat/') !== false) {
                 $strLink = $strLink . ($viewApp == 'app' ? '?view=app' : '');
                 $this->_redirect($strLink, array('code' => 301));
             }
         }
         return $this->_forward('live');
     }
     //get category on breakcumb (Using when view page > 2)
     $page = 1;
     //check page of detail
     if ($intPage > 1) {
         //get data page extend
         $arrDataExtend = $this->view->objArticle->getDetailPageExtend($intArticleId, $intPage);
         if (!empty($arrDataExtend)) {
             unset($arrDataExtend['creation_time'], $arrDataExtend['publish_time_format'], $arrDataExtend['publish_time']);
             //merge page extend to data detail
             $arrArticleDetail = array_merge($arrArticleDetail, (array) $arrDataExtend);
             //Check page_type popup
             if (2 == $arrDataExtend['page_type']) {
                 //Disable layout
                 $this->_helper->layout->disableLayout(true);
                 //Set no render view
                 $this->_helper->viewRenderer->setNoRender(true);
                 $this->view->assign(array('arrData' => $arrArticleDetail));
                 echo $this->view->render('detail/popup.phtml');
                 exit;
             }
             //end if
             //get link remove -p2
             $strLink = preg_replace('#(-p[\\d]+\\.html)#', '.html', $strLink);
             $page = $intPage;
         } else {
             $strLink = '';
         }
     }
     //check redirect link
     if ($strLink != $arrArticleDetail['share_url'] && APPLICATION_ENV != 'development') {
         $link_more = $this->view->ShareurlSeagame($arrArticleDetail['share_url']);
         if ($page > 1) {
             $link_more = str_replace('.html', '-p' . $page . '.html' . ($viewApp == 'app' ? '?view=app' : ''), $arrArticleDetail['share_url']);
         }
         //$this->_redirect($link_more, array('code' => 301));
     }
     //check view app
     if (!empty($viewApp) && $viewApp == 'app') {
         //Disable layout
         $this->_helper->layout->disableLayout(true);
         $content = $arrArticleDetail['content'];
         $content = preg_replace('/src="(.[^>]*)_500x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*).(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*)_m_460x0_m_460x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $arrArticleDetail['content'] = $content;
         //Trim data
         $arrArticleDetail['title'] = trim($arrArticleDetail['title']);
         $arrArticleDetail['title_format'] = trim($arrArticleDetail['title_format']);
         $arrArticleDetail['lead'] = trim($arrArticleDetail['lead']);
         // Assign to view
         $this->view->assign(array('isArticleHotVnE' => $arrArticleDetail['privacy'] & 512, 'arrArticleDetail' => $arrArticleDetail, 'intCategoryId' => $intCategoryId, 'intArticleId' => $intArticleId, 'intPage' => 1, 'isDetail' => 1, 'ogType' => 'website', 'ogTitle' => $arrArticleDetail['title_format'] . ' - VnExpress SEA Games', 'ogImage' => !empty($arrArticleDetail['thumbnail_url']) ? $this->view->ImageurlArticle($arrArticleDetail, 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8')))));
         // SEO
         $arrKeyword = 'SEA Game 28, tin tuc , bong da';
         $arrArticleDetail['title'] = html_entity_decode($arrArticleDetail['title'], ENT_QUOTES, 'UTF-8');
         $this->view->headTitle($arrArticleDetail['title'] . ' - VnExpress SEA Games');
         $this->view->headMeta()->setName('description', trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8'))))->setName('keywords', $arrKeyword);
         echo $this->view->render('detail/app.phtml');
         exit;
     }
     //get topic of article detail
     //init topic default
     $arrTopic = array();
     $arrTopicDetail = array();
     if (!empty($arrArticleDetail['list_topic_id'])) {
         //init model topic
         $modelTopic = new Fpt_Data_News_Topic();
         // init topic params
         $arrTopicParams = array('site_id' => 1000000, 'topic_id' => $arrArticleDetail['list_topic_id'], 'limit' => LIMIT_TOPIC_DETAIL + 1, 'offset' => 0, 'withscore' => true, 'article_type' => NULL);
         // get list article by topic
         $arrTopic = $modelTopic->getTopicNewsByScore($arrTopicParams);
         // check array topic data
         if (!empty($arrTopic)) {
             $score = 0;
             $temp_topic_id = 0;
             foreach ($arrArticleDetail['list_topic_id'] as $index => $topic_id) {
                 if (isset($arrTopic[$topic_id]['data'][$intArticleId])) {
                     unset($arrTopic[$topic_id]['data'][$intArticleId]);
                 }
                 if (empty($arrTopic[$topic_id]['data'])) {
                     unset($arrArticleDetail['list_topic_id'][$index]);
                     continue;
                 }
                 // get first article to compare
                 $firstCore = current($arrTopic[$topic_id]['data']);
                 if ($firstCore > $score) {
                     $temp_topic_id = $topic_id;
                     $score = $firstCore;
                 }
             }
             // get detail of topic id list
             $arrTopicDetail = $modelTopic->getDetailTopicByArrId(array($temp_topic_id));
             $arrTopic = array_slice(array_keys($arrTopic[$temp_topic_id]['data']), 0, LIMIT_TOPIC_DETAIL);
             //set id
             $this->view->objArticle->setIdBasic($arrTopic);
         }
     }
     //end get topic of article detail
     //get cate instance
     $modelCategory = Thethao_Model_Category::getInstance();
     // Get parent info
     $arrCateInfo = $modelCategory->getDetailbyCateId($intCategoryId);
     $intOtherCate = $intCategoryId;
     //check cate result
     if (!empty($arrCateInfo) && !empty($arrCateInfo['parent_id'])) {
         //check parent_id
         if (SITE_ID != $arrCateInfo['parent_id']) {
             $intOtherCate = $arrCateInfo['parent_id'];
         }
     }
     //get other news of article detail from commendation
     $arrOrtherArticle = array();
     $instanceNews = Thethao_Model_News::getInstance();
     //get list top 15 article with rule 2
     $arrNewsArticle = $instanceNews->getListArticleIdsByRule2(array('category_id' => $intOtherCate, 'limit' => LIMIT_OTHER_NEWS + 1, 'offset' => 0, 'article_type' => NULL));
     if (count($arrNewsArticle['data']) > LIMIT_OTHER_NEWS) {
         $arrDiff = array_diff($arrNewsArticle['data'], array($intArticleId));
         $arrNewsArticle['data'] = array_slice($arrDiff, 0, LIMIT_OTHER_NEWS);
     }
     //set flag check exclude
     $flag = false;
     //check is empty list news
     if (is_array($arrNewsArticle) && !empty($arrNewsArticle['data'])) {
         if (in_array($intArticleId, $arrNewsArticle['data'])) {
             $flag = true;
             //excluse current article
             $arrOrtherArticle = array_diff($arrNewsArticle['data'], array($intArticleId));
         } else {
             $arrOrtherArticle = $arrNewsArticle['data'];
         }
         //then slice to get only 14 item
         $arrOrtherArticle = array_slice($arrOrtherArticle, 0, LIMIT_OTHER_NEWS);
     }
     //end check is empty latest news
     //set article id to get detail
     $this->view->objArticle->setIdBasic($arrOrtherArticle);
     //end get other news of article detail
     //get top view article
     $arrTopViewID = array();
     if (DEVICE_ENV != 1) {
         //get top view with rule 4
         $arrTopViewData = $instanceNews->getListArticleIdsByRule4(array('category_id' => $intOtherCate, 'offset' => 0, 'limit' => LIMIT_TOP_VIEW + 1));
         if (!empty($arrTopViewData)) {
             //excluse current article
             $arrTopViewID = array_diff($arrTopViewData, array($intArticleId));
             $arrTopViewID = array_slice($arrTopViewID, 0, LIMIT_TOP_VIEW);
         }
         //set article id to get detail
         $this->view->objArticle->setIdBasic($arrTopViewID);
     }
     //end get top view article
     //Set category id for block_cate user in block & menu breakumb
     $this->_request->setParam('block_cate', $intCategoryId);
     //init cate for set menu
     $idCateMenu = $arrCateInfo['parent_id'] == SITE_ID ? $intCategoryId : $arrCateInfo['parent_id'];
     //set cate active
     $this->_request->setParam('cateActiveId', $intCategoryId);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', SEA_GAMES);
     //get Instance Block
     $objBlock = Thethao_Plugin_Block::getInstance();
     //set exclude for detail
     $objBlock->setExclude(array($intArticleId));
     //replace image size for mobile
     if (DEVICE_ENV == 1) {
         $content = $arrArticleDetail['content'];
         $content = preg_replace('/src="(.[^>]*)_500x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*).(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $content = preg_replace('/src="(.[^>]*)_m_460x0_m_460x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
         $arrArticleDetail['content'] = $content;
     }
     //Trim data
     $arrArticleDetail['title'] = trim($arrArticleDetail['title']);
     $arrArticleDetail['title_format'] = trim($arrArticleDetail['title_format']);
     $arrArticleDetail['lead'] = trim($arrArticleDetail['lead']);
     //print_r($arrTopic);die;
     // Assign to view
     $this->view->assign(array('flagExc' => $flag, 'isArticleHotVnE' => $arrArticleDetail['privacy'] & 512, 'parentCategoryID' => $arrCateInfo['parent_id'], 'arrArticleDetail' => $arrArticleDetail, 'intCategoryId' => $intCategoryId, 'intArticleId' => $intArticleId, 'intOtherCate' => $intOtherCate, 'arrNewsArticle' => $arrNewsArticle, 'arrOrtherArticle' => $arrOrtherArticle, 'flagExc' => $flag, 'totalOtherNews' => $arrNewsArticle['total'], 'intPage' => 1, 'intCateIdPolyAds' => $arrArticleDetail['category_id'], 'articleTrackingId' => $arrArticleDetail['article_id'], 'arrTopic' => $arrTopic, 'arrTopicDetail' => $arrTopicDetail[$temp_topic_id], 'arrTopViewID' => $arrTopViewID, 'isDetail' => 1, 'ogType' => 'article', 'ogTitle' => $arrArticleDetail['title_format'] . ' - VnExpress SEA Games', 'ogUrl' => $this->view->ShareurlSeagame($arrArticleDetail['share_url']), 'ogImage' => !empty($arrArticleDetail['thumbnail_url']) ? $this->view->ImageurlArticle($arrArticleDetail, 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8')))));
     // SEO
     $arrKeyword = 'SEA Games 28, tin tuc , bong da';
     $arrArticleDetail['title'] = html_entity_decode($arrArticleDetail['title'], ENT_QUOTES, 'UTF-8');
     $this->view->headTitle($arrArticleDetail['title'] . ' - VnExpress SEA Games');
     $this->view->headMeta()->setName('description', trim(strip_tags(html_entity_decode($arrArticleDetail['lead'], ENT_COMPAT, 'UTF-8'))))->setName('keywords', $arrKeyword);
 }
 /**
  * Detail Action
  */
 public function detailAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     //Get article id
     $id = $this->_request->getParam('id', 0);
     if (!is_numeric($id) || $id <= 0) {
         $this->_redirect($this->view->configView['linkerror'][DEVICE_ENV]);
     }
     //end if
     //Get full detail article
     $arrData = $this->view->objArticle->getArticleFull($id);
     //********************* Check Detail Article *************************//
     if (empty($arrData)) {
         $this->_redirect($this->view->configView['linkerror'][DEVICE_ENV]);
     }
     //end if
     //********************* Check Bài Hẹn Giờ *************************//
     if (intval($arrData['publish_time']) > time()) {
         //secr not match
         if (md5($id . $arrData['creation_time']) != $this->_request->getParam('sig')) {
             //redirect về Trang Error
             $this->_redirect($this->view->configView['linkerror'][DEVICE_ENV]);
         }
         //end if
     }
     //end if
     //Get string link
     $strLink = $this->view->configView['url'] . $this->_request->getPathInfo();
     //check page
     $pageTypeExt = 0;
     $page = 0;
     //Get page
     $intPage = max(1, $this->_request->getParam('page', 1));
     if ($intPage > 1) {
         //get data page extend
         $arrDataExtend = $this->view->objArticle->getDetailPageExtend($id, $intPage);
         if (!empty($arrDataExtend)) {
             //Page type
             $pageTypeExt = $arrDataExtend['page_type'];
             //unset
             unset($arrDataExtend['creation_time']);
             unset($arrDataExtend['publish_time_format']);
             unset($arrDataExtend['publish_time']);
             //merge page extend to data detail
             $arrData = array_merge($arrData, (array) $arrDataExtend);
             //get link remove -p2
             $strLink = preg_replace('#(-p[\\d]+\\.html)#', '.html', $strLink);
             $page = $intPage;
         } else {
             $strLink = '';
         }
         //end if
     }
     //end if
     //Check page_type popup
     if ($pageTypeExt == 2) {
         $this->view->assign('arrData', $arrData);
         echo $this->view->render('/m240/popup.phtml');
         exit;
     }
     //end if
     //replace share_url
     $arrData['share_url'] = $this->view->ShareurlM240($arrData['share_url']);
     //check link to redirect
     if ($strLink != $arrData['share_url']) {
         //($page>1)?$this->_redirect(str_replace('.html', '-p'.$page.'.html', $arrData['share_url']), array('code'=>301)):$this->_redirect($arrData['share_url'], array('code'=>301));
     }
     //end if
     //Set category id for block_cate user in block
     $this->_request->setParam('cateid', $arrData['category_id']);
     //News object
     $modelNews = Thethao_Model_News::getInstance();
     //Category object
     $modelCate = Thethao_Model_Category::getInstance();
     //********************* Process Tin khác *************************//
     //Init array params other news
     $arrOtherNewsParams = array('category_id' => $arrData['category_id'], 'limit' => LIMIT_OTHER_NEWS + 1, 'offset' => 0, 'article_type' => TYPE_ALL);
     //Get news by rule 2: folder và liston lên folder của tin đang xem)
     $arrOtherNews = $modelNews->getListArticleIdsByRule2($arrOtherNewsParams);
     //check data empty
     if (is_array($arrOtherNews) && !empty($arrOtherNews['data'])) {
         $intKeyExists = array_search($id, $arrOtherNews['data']);
         if ($intKeyExists !== FALSE) {
             unset($arrOtherNews['data'][$intKeyExists]);
         } elseif (isset($arrOtherNews['data'][LIMIT_OTHER_NEWS])) {
             unset($arrOtherNews['data'][LIMIT_OTHER_NEWS]);
         }
         //end if
     }
     //end if
     //********************* Process Topic - Tin liên quan *************************//
     /*
      *  - Nếu bài đang xem thuộc duy nhất 1 topic thì lấy 2 tin mới nhất của topic đó
      *  - Nếu bài đang xem thuộc từ 2 topic trở lên thì lấy 2 tin mới nhất của topic có tin mới nhất
      */
     // GET TOPIC NEWS
     $arrTopic = $arrTopicDetail = array();
     // check empty list topic
     if (!empty($arrData['list_topic_id'])) {
         // get topic object
         $modeTopic = new Fpt_Data_News_Topic();
         // init topic params
         $arrTopicParams = array('site_id' => SITE_ID_VNE, 'topic_id' => $arrData['list_topic_id'], 'limit' => LIMIT_TOPIC_DETAIL + 1, 'offset' => 0, 'withscore' => true, 'article_type' => TYPE_ALL);
         // get list article by topic
         $arrTopic = $modeTopic->getTopicNewsByScore($arrTopicParams);
         // check array topic data
         if (!empty($arrTopic)) {
             $score = 0;
             $temp_topic_id = 0;
             //Loop
             foreach ($arrData['list_topic_id'] as $index => $topic_id) {
                 if (isset($arrTopic[$topic_id]['data'][$id])) {
                     unset($arrTopic[$topic_id]['data'][$id]);
                     $arrTopic[$topic_id]['total'] = $arrTopic[$topic_id]['total'] - 1;
                 }
                 //end if
                 if (empty($arrTopic[$topic_id]['data'])) {
                     unset($arrData['list_topic_id'][$index]);
                 }
                 //end if
                 // get first article to compare
                 $firstCore = current($arrTopic[$topic_id]['data']);
                 if ($firstCore > $score) {
                     $temp_topic_id = $topic_id;
                     $score = $firstCore;
                 }
                 //end if
             }
             //end foreach
             if (!empty($arrData['list_topic_id'])) {
                 // get detail of topic id list
                 $arrTopicDetail = $modeTopic->getDetailTopicByArrId(array($temp_topic_id));
                 $arrTopic = array_slice(array_keys($arrTopic[$temp_topic_id]['data']), 0, LIMIT_TOPIC_DETAIL);
                 $arrTopicDetail = $arrTopicDetail[$temp_topic_id];
                 // set to article instance
                 $this->view->objArticle->setIdBasic($arrTopic);
             }
             //end if
         }
         //end if
     }
     //end if
     //Check empty
     if (!empty($arrOtherNews['data'])) {
         //set obj get Article
         $this->view->objArticle->setIdBasic($arrOtherNews['data']);
     }
     //end if
     //replace image size for mobile
     $content = $arrData['content'];
     $content = preg_replace('/src="(.[^>]*)_500x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
     $content = preg_replace('/src="(.[^>]*).(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
     $content = preg_replace('/src="(.[^>]*)_m_460x0_m_460x0.(jpg|gif|png|jpeg)"/', 'src="$1_m_460x0.$2"', $content);
     //remove all iframe and div has class embed-container
     $content = preg_replace('/<iframe.[^>]*>.*<\\/iframe>/siU', '<div class="clear">&nbsp;</div>', $content);
     $content = preg_replace('/<div(.[^>]*)class="embed-container(.*[^\\"])?"(.[^>])*>(.*)<\\/div><\\/div>/siU', '<div class="clear">&nbsp;</div>', $content);
     $content = $this->view->ShareurlM240($content);
     $arrData['content'] = $content;
     //Trim data
     $arrData['title'] = trim($arrData['title']);
     $arrData['title_format'] = trim($arrData['title_format']);
     $arrData['lead'] = trim($this->view->ShareurlM240($arrData['lead']));
     //********************* Process Meta: title + description + keywords Facebook*************************//
     $strMetaTitle = strip_tags(html_entity_decode($arrData['title'], ENT_COMPAT, 'UTF-8')) . ' - VnExpress Giải Trí';
     $strMetaDescript = strip_tags(html_entity_decode($arrData['lead'], ENT_COMPAT, 'UTF-8')) . ' - VnExpress Giải Trí';
     //********************* Assign to views *************************//
     $this->view->assign(array('arrArticleDetail' => $arrData, 'arrOtherNews' => $arrOtherNews, 'arrTopic' => $arrTopic, 'arrTopicDetail' => $arrTopicDetail, 'intCategoryId' => $arrData['category_id'], 'intArticleId' => $arrData['article_id']));
     // Prepend title
     $this->view->headTitle()->prepend($strMetaTitle);
     $this->view->headMeta()->setName('description', $strMetaDescript)->setName('keywords', $strMetaTitle);
 }
 /**
  * cate folder page
  * @author HungNT1
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     $strCateCode = $this->_request->getParam('cate_code');
     //set render view if cate code is lich-thi-dau
     if ($strCateCode == 'lich-thi-dau') {
         return $this->_forward('lich-thi-dau');
     }
     //get instance Cate
     $objCate = Thethao_Model_Category::getInstance();
     //get cate id by cate code
     $intCateId = $objCate->getIdByCode($strCateCode, SEA_GAMES);
     //get page of cate
     $intPage = $this->_request->getParam('page', 1);
     //check cate id is not exists
     if ($intCateId < 1) {
         $this->_redirect("/");
     }
     // Get Category detail
     $cateDetail = $objCate->getDetailByCateId($intCateId);
     //str link
     $strLink = $this->_request->getPathInfo();
     if (strpos(rtrim($strLink, '/'), $cateDetail['link']) === FALSE) {
         //$this->_redirect($this->view->configView['url'] . $cateDetail['link'], array('code' => 301));
     }
     if ($intPage > 1) {
         $limit = LIMIT_LIST_CATE;
         $offset = ($intPage - 1) * LIMIT_LIST_CATE + LIMIT_TOP_NEWS_CATE;
     } else {
         $limit = LIMIT_LIST_CATE + LIMIT_TOP_NEWS_CATE;
         $offset = 0;
     }
     //init param to get list data with rule 2
     $arrParamNews = array('category_id' => $intCateId, 'article_type' => NULL, 'limit' => $limit, 'offset' => $offset);
     //init model news
     $objNews = Thethao_Model_News::getInstance();
     //get list article with rule 2 list on Thethao
     $arrListData = $objNews->getListArticleIdsByRule2($arrParamNews);
     // set id from $arrListPaging to get article
     $this->view->objArticle->setIdBasic($arrListData['data']);
     $arrArticleExclude = array();
     $arrHotNews = $arrListExclude = array();
     if (1 == $intPage && !empty($arrListData['data'])) {
         $arrArticleExclude = $arrListData['data'];
         //get Instance Block
         $objBlock = Thethao_Plugin_Block::getInstance();
         // set exclude article id from arrData
         $objBlock->setExclude($arrArticleExclude);
         $arrHotNews = array_slice($arrListData['data'], 0, LIMIT_TOP_NEWS_CATE);
         $arrListData['data'] = array_diff($arrListData['data'], $arrHotNews);
         //get Exclude
         $arrListExclude = $objBlock->getExclude();
     }
     //get video for box right
     $arrParamVideo = array('category_id' => CATE_SEA_GAMES_VIDEO, 'limit' => LIMIT_RELATED_VIDEO + LIMIT_LIST_CATE, 'offset' => 0, 'article_type' => TYPE_VIDEO);
     //get list article with rule 1 list on folder video
     $arrListVideo = $objNews->getListArticleIdsByRule1($arrParamVideo);
     if (1 == $intPage && !empty($arrListVideo['data'])) {
         $arrListVideo['data'] = array_diff($arrListVideo['data'], $arrListExclude);
     }
     if (count($arrListVideo['data']) > LIMIT_RELATED_VIDEO) {
         $arrListVideo['data'] = array_slice($arrListVideo['data'], 0, LIMIT_RELATED_VIDEO);
     }
     // set id from $arrListPaging to get article
     $this->view->objArticle->setIdBasic($arrListVideo['data']);
     //check if page > max page then return to max page
     if ($arrListData['total'] > 0) {
         $maxPage = ceil($arrListData['total'] / LIMIT_LIST_CATE);
         if ($intPage > $maxPage) {
             //$this->_redirect($this->configView['url'] . $cateDetail['link'] . '/page/' . $maxPage . '.html');
         }
     }
     //InitParam Paging
     $arrParamPaging = array('total' => $arrListData['total'] - LIMIT_TOP_NEWS_CATE, 'page' => $intPage, 'url' => $this->view->configView['url'] . $cateDetail['link'] . '/page', 'perpage' => LIMIT_LIST_CATE, 'classPagination' => 'pagination_news center', 'extEnd' => '.html', 'separate' => '/');
     //Set param
     $this->_request->setParam('block_cate', $intCateId);
     //gan meta data
     $titleMeta = $cateDetail['catename'] . ' SEA Games 28 - VnExpress';
     $keywords = 'SEA Games 28, tin tuc , bong da';
     $description = 'SEA Games 28 - tin nhanh , hình ảnh , video clip bóng đá, lịch thi đấu SEA Games 28, tường thuật bình luận bóng đá SEA Games 28';
     //Assign to view
     $this->view->assign(array('intCategoryId' => $intCateId, 'arrHotNews' => $arrHotNews, 'arrParamPaging' => $arrParamPaging, 'arrData' => $arrListData['data'], 'arrListVideo' => $arrListVideo['data'], 'arrArticleExclude' => $arrArticleExclude, 'arrListExclude' => $arrListExclude, 'ogType' => 'website', 'ogTitle' => $titleMeta, 'ogUrl' => $this->view->configView['url'] . $cateDetail['link'], 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $description));
     //init cate for set menu
     //set cate active
     $this->_request->setParam('cateActiveId', $intCateId);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', SEA_GAMES);
     // Set metadata tags
     $this->view->headTitle()->prepend($titleMeta);
     $this->view->headMeta()->setName('description', $description)->setName('keywords', $keywords);
 }
Beispiel #21
0
 /**
  * Get block interview in the verticle The Thao
  * @param type $arrParam
  * @return type
  */
 public function getBlockInterView($arrParam)
 {
     $arrReturn = array();
     $objCategory = Thethao_Model_Category::getInstance();
     //get Info Cate
     $arrCate = $objCategory->getInfoCateByBlock($arrParam);
     //Init model
     $modelMews = Thethao_Model_News::getInstance();
     //Get
     $arrReturn = $modelMews->getListArticleIdsByRule2($arrParam);
     if (!empty($arrReturn['data'])) {
         $this->_article->setIdBasic($arrReturn['data']);
         //Init Obj Interview
         $objInterview = Fpt_Data_News_Interview::getInstance();
         //Get Image, Time interview
         $arrParam = array('article_id' => $arrReturn['data'][0]);
         $arrReturn['info']['interview'] = $objInterview->getInterviewInfo($arrParam);
         $arrReturn['info']['cate'] = $arrCate['cate'];
     }
     return $arrReturn;
 }