/**
  * Rewrite BXH cache
  * @param array $params
  * @author QuangTM
  */
 public function rewriteBXHCache($params)
 {
     if (!empty($params)) {
         // Init model Footbal
         $modelFootball = new Thethao_Model_Football();
         $modelFootball->rewriteBXHCache($params);
         //init news instance
         $caching = Thethao_Model_Caching::getInstance();
         $caching->clearCacheFile();
     }
 }
 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);
 }
 /**
  * @todo - Worldcup bang diem page
  * @author PhongTX
  */
 public function indexAction()
 {
     $leagueId = LEAGUE_ID;
     $seasonId = SEASON_ID;
     //Set category id for block_cate user in block
     $this->_request->setParam('block_cate', WORLD_CUP);
     // Get models instance
     $modelFootball = Thethao_Model_Football::getInstance();
     // Get detail table ranking by league and season
     $tableRanking = $modelFootball->getListTableRanking($seasonId, $leagueId);
     if (!empty($tableRanking)) {
         //set id object
         $this->view->objObject->getTeam()->setId(array_keys($tableRanking));
         $temp = current($tableRanking);
         $maxUpdateTime = $temp['UpdateTime'];
     } else {
         $maxUpdateTime = time();
     }
     // Get league detail
     $leagueDetail = $modelFootball->getListLeagueByIDs(array($leagueId));
     // Get season by league
     $arrSeasonByLeague = $modelFootball->getListSeasonByLeagueID($leagueId);
     $directUrL = $this->view->configView['url'] . '/bang-diem';
     //gan meta data
     $titleMeta = 'Bảng điểm 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('tableRanking' => $tableRanking, 'leagueDetail' => $leagueDetail[0], 'leagueID' => $leagueId, 'seasonID' => $seasonId, 'maxUpdateTime' => $maxUpdateTime, 'ogType' => 'website', 'ogTitle' => $titleMeta, 'ogUrl' => $directUrL, 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $description, 'strCateCode' => $this->_request->getParam('controller')));
     //set cateid to show active in menu
     $this->_request->setParam('cateid', WORLD_CUP);
     $this->view->headTitle($titleMeta);
     $this->view->headMeta()->setName('description', $description);
     $this->view->headMeta()->setName('keywords', $keywords);
 }
Beispiel #4
0
 /**
  * Get singletom instance
  * @return Thethao_Model_Football
  * @author LamTX
  */
 public static final function getInstance()
 {
     //Check instance
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     //Return instance
     return self::$_instance;
 }
 public function loadListFixtureAction()
 {
     // Disable render layout
     $this->_helper->layout->disableLayout(true);
     $this->_helper->viewRenderer->setNoRender(true);
     // Get params
     $params = $this->_request->getParams();
     $teamID = $params['id'] ? $params['id'] : 0;
     $ajax = $params['ajax'] ? $params['ajax'] : 0;
     // Get models' instance
     $footballModel = Thethao_Model_Football::getInstance();
     $matchModel = Thethao_Model_Match::getInstance();
     $teamModel = Thethao_Model_Team::getInstance();
     // Get models' Oject instance
     $modelObject = $this->view->objObject;
     if ($ajax == 'fixture') {
         // Default response
         $response = array('error' => 0, 'msg' => 'Success', 'html' => NULL, 'ext' => NULL);
         if ($teamID) {
             $modelTeam = $modelObject->getTeam();
             $modelTeam->setId($teamID);
             // Get match id by team
             $arrMatchIDs = $modelTeam->getMatchIDsByTeam($teamID);
             if (is_array($arrMatchIDs) && count($arrMatchIDs)) {
                 // Get list league and season team attended
                 $arrLeagueSeason = $teamModel->getListLeagueAndSeasonTeamAttend($teamID);
                 $arrLeagueIDs = array_keys($arrLeagueSeason);
                 // Get league detail
                 $arrLeagueDetails = $footballModel->getListLeagueByIDs($arrLeagueIDs);
                 // Assign to view
                 $this->view->assign(array('arrLeagueDetails' => $arrLeagueDetails));
                 // Render HTML
                 $response['html'] = $this->view->render('object/fixture.phtml');
                 // Extend param
                 $response['ext'] = $arrLeagueSeason;
             } else {
                 $response['error'] = 2;
                 $response['msg'] = 'Not found match for team';
             }
         } else {
             $response['error'] = 1;
             $response['msg'] = 'Invalid parameters';
         }
     }
     if ($ajax == 'load-list-fixture') {
         $leagueID = intval($this->_request->getParam('leagueid', 0));
         $seasonID = intval($this->_request->getParam('seasonid', 0));
         // Default response
         $response = array('error' => 0, 'msg' => 'Success', 'html' => NULL);
         if ($teamID) {
             $modelMatch = $modelObject->getMatch();
             $modelTeam = $modelObject->getTeam();
             $modelTeam->setId($teamID);
             // Get all league and season
             if (!$leagueID && !$seasonID) {
                 // Get matchID
                 $arrMatchIDs = array_keys($modelTeam->getMatchIDsByTeam($teamID));
             } else {
                 // Get match id by team, season, league
                 $arrMatchIDs = $matchModel->getMatchIDsByTeamLeagueSeason($teamID, $leagueID, $seasonID);
             }
             //set id
             $modelMatch->setId($arrMatchIDs);
             if (is_array($arrMatchIDs) && count($arrMatchIDs)) {
                 // Split array into many chunks
                 $arrChunks = array_chunk($arrMatchIDs, 10);
                 // Set array match ids again
                 $arrMatchIDs = $arrChunks[0];
                 // Assign to view
                 $this->view->assign(array('arrMatchIDs' => $arrMatchIDs));
                 // Render HTML
                 if (DEVICE_ENV == 1) {
                     $response['html'] = $this->view->render('object/list_fixture_1.phtml');
                 } else {
                     $response['html'] = $this->view->render('object/list_fixture.phtml');
                 }
                 $response['extend'] = $arrChunks;
             } else {
                 $response['error'] = 2;
                 $response['msg'] = 'Not found match for team';
             }
         } else {
             $response['error'] = 1;
             $response['msg'] = 'Invalid parameters';
         }
     }
     if ($ajax == 'load-list-season') {
         // Get params
         $arrSeasonIDs = $this->_request->getParam('arrSeasonIDs', 0);
         // Default response
         $response = array('error' => 0, 'msg' => 'Success', 'data' => NULL);
         if (is_array($arrSeasonIDs) && count($arrSeasonIDs)) {
             // Get list season
             $arrSeaonDetails = $footballModel->getListSeasonByIDs($arrSeasonIDs);
             foreach ($arrSeaonDetails as $season) {
                 $response['data'][] = array('id' => $season['SeasonID'], 'name' => $season['NameSeason']);
             }
         } else {
             $response['error'] = 1;
             $response['msg'] = 'Invalid parameters';
         }
     }
     if ($ajax == 'expand-fixture-list') {
         // Default response
         $response = array('error' => 0, 'msg' => 'Success', 'html' => NULL);
         if ($this->_request->isXmlHttpRequest()) {
             // Get params
             $arrMatchIDs = $this->_request->getParam('arrMatchIDs', NULL);
             // Verify param request
             if (is_array($arrMatchIDs) && count($arrMatchIDs)) {
                 $modelMatch = $modelObject->getMatch();
                 //set id
                 $modelMatch->setId($arrMatchIDs);
                 // Assign to view
                 $this->view->assign(array('arrMatchIDs' => $arrMatchIDs));
                 // Render HTML
                 // Render HTML
                 if (DEVICE_ENV == 1) {
                     $response['html'] = $this->view->render('object/list_fixture_1.phtml');
                 } else {
                     $response['html'] = $this->view->render('object/list_fixture.phtml');
                 }
             } else {
                 $response['error'] = 2;
                 $response['msg'] = 'Invalid parameters';
             }
         } else {
             $response['error'] = 1;
             $response['msg'] = 'Invalid method';
         }
     }
     // Output
     echo Zend_Json::encode($response);
     exit;
 }
 /**
  * Get table worldcup
  */
 public function tableapiAction()
 {
     //set header
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET');
     //set cache
     $this->_request->setParam('cache_file', 1);
     //Disable layout
     $this->_helper->layout->disableLayout(true);
     //Set no render view
     $this->_helper->viewRenderer->setNoRender(true);
     //init response
     $respose = array('data' => '', 'error' => 1);
     $modelObject = Fpt_Data_Materials_Object::getInstance();
     // Get models instance
     $modelFootball = Thethao_Model_Football::getInstance();
     //get table with seasonId and leagueId
     $tableRanking = $modelFootball->getListTableRanking(153, 18);
     if (!empty($tableRanking)) {
         //set id object
         $modelObject->getTeam()->setId(array_keys($tableRanking));
         $respose['error'] = 0;
     }
     $respose['data'] = $tableRanking;
     $jsonData = Zend_Json::encode($respose);
     # JSON if no callback
     if (!isset($_GET['callback'])) {
         echo $jsonData;
         exit;
     }
     //init model new
     $modelNew = Thethao_Model_News::getInstance();
     # JSONP if valid callback
     if ($modelNew->isValidCallback($_GET['callback'])) {
         echo "{$_GET['callback']}({$jsonData})";
         exit;
     }
 }
 /**
  * Action show table ranking detail by season and league
  * @author QuangTM
  */
 public function bangXepHangAction()
 {
     $leagueId = intval($this->_request->getParam('lid', 1));
     $seasonId = intval($this->_request->getParam('sid', 0));
     //Set category id for block_cate user in block
     $this->_request->setParam('block_cate', 'league_' . $leagueId);
     // Get models instance
     $modelFootball = Thethao_Model_Football::getInstance();
     if (!$seasonId) {
         // Get season by league
         $arrSeasonByLeague = $modelFootball->getListSeasonByLeagueID($leagueId);
         $currentYear = date('Y');
         foreach ($arrSeasonByLeague as $value) {
             if (substr($value['NameSeason'], 0, 4) == $currentYear) {
                 $currentSeasonByLeague = $value;
             }
         }
         if (isset($currentSeasonByLeague)) {
             $seasonByLeague = $currentSeasonByLeague;
         } else {
             $currentYear = $currentYear - 1;
             foreach ($arrSeasonByLeague as $value) {
                 if (substr($value['NameSeason'], 0, 4) == $currentYear) {
                     $currentSeasonByLeague = $value;
                 }
             }
             if (isset($currentSeasonByLeague)) {
                 $seasonByLeague = $currentSeasonByLeague;
             } else {
                 $seasonByLeague = $arrSeasonByLeague[0];
             }
         }
         // Get league detail
         $leagueDetail = $modelFootball->getListLeagueByIDs(array($leagueId));
         // Get link to redirect
         $directUrL = $this->view->configView['url'] . '/bang-xep-hang/' . Fpt_Filter::setSeoLink($leagueDetail[0]['Name']) . '-' . $seasonByLeague['NameSeason'] . '-' . $leagueId . '-' . $seasonByLeague['SeasonID'] . '.html';
         // Redirect
         $this->_redirect($directUrL);
         exit;
     }
     // Get detail table ranking by league and season
     $tableRanking = $modelFootball->getListTableRanking($seasonId, $leagueId);
     if (!empty($tableRanking)) {
         //set id object
         $this->view->objObject->getTeam()->setId(array_keys($tableRanking));
         $temp = current($tableRanking);
         $maxUpdateTime = $temp['UpdateTime'];
     } else {
         $maxUpdateTime = time();
     }
     // Get all league
     $allLeague = $modelFootball->getLeagueAll();
     // Get league to json
     $arrLeagues = array();
     foreach ($allLeague as $league) {
         $arrLeagues[$league['LeagueID']] = Fpt_Filter::setSeoLink($league['Name']);
     }
     // Get league detail
     $leagueDetail = $modelFootball->getListLeagueByIDs(array($leagueId));
     // Get season by league
     $arrSeasonByLeague = $modelFootball->getListSeasonByLeagueID($leagueId);
     $arrSeasons = array();
     //Sort descending list season
     if (is_array($arrSeasonByLeague) && count($arrSeasonByLeague)) {
         foreach ($arrSeasonByLeague as $value) {
             $arrSeasons[$value['SeasonID']] = $value['NameSeason'];
         }
     }
     arsort($arrSeasons);
     // Get season detail
     $seasonDetail = $modelFootball->getListSeasonByIDs(array($seasonId));
     switch ($leagueId) {
         case 1:
             $cateActiveId = CATE_ID_NGOAIHANGANH;
             break;
         case 2:
             $cateActiveId = CATE_ID_LALIGA;
             break;
         case 3:
             $cateActiveId = CATE_ID_SERIA;
             break;
         case 6:
         case 7:
             $cateActiveId = CATE_ID_BONGDATRONGNUOC;
             break;
         default:
             $cateActiveId = CATE_ID_CACGIAIKHAC;
             break;
     }
     $directUrL = $this->view->configView['url'] . '/bang-xep-hang/' . Fpt_Filter::setSeoLink($leagueDetail[0]['Name']) . '-' . $seasonDetail[0]['NameSeason'] . '-' . $leagueId . '-' . $seasonDetail[0]['SeasonID'] . '.html';
     $title = 'Bảng xếp hạng ' . $leagueDetail[0]['Name'];
     $description = 'Bảng xếp hạng ' . $leagueDetail[0]['Name'] . ' - Tin nhanh mới nhất, lịch thi đấu, video, hình ảnh, kết quả bảng xếp hạng các giải Bóng đá.';
     $keywords = 'bang xep hang ngoai hang Anh, bang xep hang seri a, bang xep hang bungdesliga, bang xep hang la liga';
     // Assign to view
     $this->view->assign(array('tableRanking' => $tableRanking, 'allLeague' => $allLeague, 'arrLeagueJson' => Zend_Json::encode($arrLeagues), 'leagueDetail' => $leagueDetail[0], 'arrSeasonByLeague' => $arrSeasons, 'arrSeasonJson' => Zend_Json::encode($arrSeasons), 'seasonDetail' => $seasonDetail[0], 'leagueID' => $leagueId, 'seasonID' => $seasonId, 'maxUpdateTime' => $maxUpdateTime, 'intCategoryId' => $cateActiveId, 'ogType' => 'website', 'ogTitle' => $title, 'ogUrl' => $directUrL, 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $description));
     // Init menu
     $this->_request->setParam('cateid', CATE_ID_BONGDA);
     $this->_request->setParam('cateActiveId', $cateActiveId);
     $this->view->headTitle($title . ' - VnExpress');
     $this->view->headMeta()->setName('description', $description);
     $this->view->headMeta()->setName('keywords', $keywords);
     //Append JS
     $this->view->headScript()->appendFile($this->view->configView['js'] . '/table_ranking.js');
 }
 /**
  * @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);
 }
 public function getFixtureAction()
 {
     // Disable render view
     $this->_helper->layout->disableLayout(true);
     $this->_helper->viewRenderer->setNoRender(true);
     // Get param
     $strLeagueID = $this->_request->getParam('lid', NULL);
     $strSeasonID = $this->_request->getParam('sid', NULL);
     $gmt = intval($this->_request->getParam('gmt', 0));
     // Default response
     $response = array('error' => 0, 'html' => NULL, 'msg' => 'Success');
     if (!empty($strLeagueID) && !empty($strSeasonID)) {
         $arrSeasonID = explode(',', $strSeasonID);
         $arrLeagueID = explode(',', $strLeagueID);
         // Determine unix time today (ignore hour, minute, second)
         $unixTimeToday = intval(strtotime(date('Y/m/d')));
         // Determine day of week
         $dayOfWeek = date('N');
         // Determine unix time of monday
         $unixTimeModay = $unixTimeToday - ($dayOfWeek - 1) * 86400;
         // Determine unix time of sunday
         $unixTimeSunday = $unixTimeToday + (7 - $dayOfWeek + 1) * 86400 - 1;
         // Get model match
         $footballModel = Thethao_Model_Football::getInstance();
         $matchModel = Thethao_Model_Match::getInstance();
         // Get league name
         $arrLeagues = $footballModel->getListLeagueByIDs($arrLeagueID);
         $numLeagues = count($arrLeagueID);
         $arrData = array();
         for ($i = 0; $i < $numLeagues; $i++) {
             array_push($arrData, $matchModel->getMatchInWeek($arrSeasonID[$i], $arrLeagueID[$i], $unixTimeModay, $unixTimeSunday));
         }
         // Assign to view
         $this->view->assign(array('arrData' => $arrData, 'arrLeagues' => $arrLeagues, 'strSeasonID' => $strSeasonID, 'strLeagueID' => $strLeagueID, 'gmt' => $gmt));
         $response['html'] = $this->view->render('lich-thi-dau/list_fixtures.phtml');
     } else {
         $response['error'] = 1;
         $response['msg'] = 'Invalid parameters';
     }
     // Output response
     echo Zend_Json::encode($response);
     exit;
 }
Beispiel #10
0
 /**
  * Get detail table ranking by league and season
  * @param array $arrParam - array of league id and season id
  */
 public function getListTableRanking()
 {
     $leagueId = LEAGUE_ID;
     $seasonId = SEASON_ID;
     $modelObject = Fpt_Data_Materials_Object::getInstance();
     // Get models instance
     $modelFootball = Thethao_Model_Football::getInstance();
     $tableRanking = $modelFootball->getListTableRanking($seasonId, $leagueId);
     if (!empty($tableRanking)) {
         //set id object
         $modelObject->getTeam()->setId(array_keys($tableRanking));
     }
     //assign to view
     return array('tableRanking' => $tableRanking);
 }