/** * 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; } }
/** * Called before Zend_Controller_Front enters its dispatch loop. * @param Zend_Controller_Request_Abstract $request * @author LamTX */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { //get z front $front = Zend_Controller_Front::getInstance(); //get dispatch $dispatcher = $front->getDispatcher(); //check can dispatchable or not if (!$dispatcher->isDispatchable($request)) { //redirect error page $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoUrl('http://vnexpress.net/' . (DEVICE_ENV == 1 ? 'm' : '') . 'error.html')->redirectAndExit(); } //set layout for device $layout = DEVICE_ENV == 1 ? 'mobile' : 'default'; $mode_view = $this->getRequest()->getQuery('view'); if ($mode_view == 'instant_article') { $layout = 'instant_article'; } $layoutInstance = Zend_Layout::startMvc(array('layout' => $layout, 'layoutPath' => APPLICATION_PATH . '/layouts/scripts', 'contentKey' => 'content')); $view = $layoutInstance->getView(); $view->setHelperPath(APPLICATION_PATH . '/layouts/helpers'); $config = $this->_frontController->getParam('bootstrap')->getOptions(); $configFW = Fpt_Data_Model::getInstance()->getConfigStatic(); if (isset($configFW['vnexpress']['static'])) { $config['view']['vnecdn']['js'] = $configFW['vnexpress']['static']['js']; $config['view']['vnecdn']['css'] = $configFW['vnexpress']['static']['css']; $config['view']['vnecdn']['libs'] = $configFW['vnexpress']['static']['libs']; $config['view']['vnecdn']['flash'] = $configFW['vnexpress']['static']['flash']; $config['view']['vnecdn']['images'] = $configFW['vnexpress']['static']['images']; } unset($configFW); $view->assign(array('Snippet' => '', 'MenuActive' => true, 'configView' => $config['view'], 'imageSize' => $config['images'][DEVICE_ENV], 'objArticle' => Fpt_Data_News_Article::getInstance(), 'objObject' => Fpt_Data_Materials_Object::getInstance())); }
/** * function delete match * @param type $params */ public function deleteMatch($params) { // Get params $matchDetail = $params['MatchDetail']; // Verify parameter if (is_array($matchDetail)) { $modelObject = Fpt_Data_Materials_Object::getInstance(); $modelObject->getMatch()->updateObject($matchDetail['match_id']); $arrGmtTime = array(0, 7); $dateTimeHappenTemp = strtotime(date('d-m-Y', $matchDetail['datetime_happen'] + 25200)); $arrKeyCache = array(); foreach ($arrGmtTime as $gmt) { $arrKeyCache[] = vsprintf($this->_match_time_list, array($dateTimeHappenTemp, $matchDetail['league_id'], $gmt)); } Thethao_Global::deleteMemcache($arrKeyCache); $keyCache1 = vsprintf($this->_match_team_season_league, array($matchDetail['team1'], $matchDetail['league_id'], $matchDetail['season_id'])); $keyCache2 = vsprintf($this->_match_team_season_league, array($matchDetail['team2'], $matchDetail['league_id'], $matchDetail['season_id'])); $keyCache3 = vsprintf($this->_match_statistic, array($matchDetail['match_id'], $matchDetail['team1'])); $keyCache4 = vsprintf($this->_match_statistic, array($matchDetail['match_id'], $matchDetail['team2'])); Thethao_Global::deleteMemcache(array($keyCache1, $keyCache2, $keyCache3, $keyCache4)); //get app conf $config = Thethao_Global::getApplicationIni(); $matchNosql = $this->factory('Match', $config['database']['nosql']['adapter']); $matchNosql->deleteMatchByLeague($matchDetail['league_id'], $matchDetail['match_id']); } }
/** * Called before Zend_Controller_Front enters its dispatch loop. * @param Zend_Controller_Request_Abstract $request * @author LamTX */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { //get z front $front = Zend_Controller_Front::getInstance(); //get dispatch $dispatcher = $front->getDispatcher(); //check can dispatchable or not if (!$dispatcher->isDispatchable($request)) { //redirect error page $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoUrl('http://vnexpress.net/merror.html')->redirectAndExit(); } $layoutInstance = Zend_Layout::startMvc(array('layout' => 'm240', 'layoutPath' => APPLICATION_PATH . '/layouts/scripts', 'contentKey' => 'content')); $view = $layoutInstance->getView(); $view->setHelperPath(APPLICATION_PATH . '/layouts/helpers'); $config = $this->_frontController->getParam('bootstrap')->getOptions(); $view->assign(array('Snippet' => '', 'MenuActive' => true, 'configView' => $config['view'], 'imageSize' => $config['images'][DEVICE_ENV], 'objArticle' => Fpt_Data_News_Article::getInstance(), 'objObject' => Fpt_Data_Materials_Object::getInstance())); }
/** * 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; }
/** * Function get list match id by league, get list team by season id & league id, get list player * @param array */ public function boxPredicted($params) { try { $matchModel = Thethao_Model_Match::getInstance(); $modelObject = Fpt_Data_Materials_Object::getInstance(); $beginHappenDateTime = time() - 100 * 60; //lay truoc do 100p $endHappenDateTime = 1405382400; // ngay 15-7-2014 $sort = false; // Get list match id by league id with time happened from current -> 15/7 $arrMatchIDs = $matchModel->getMatchIDsByLeague(LEAGUE_ID, $beginHappenDateTime, $endHappenDateTime, $sort); // Count future $count = count($arrMatchIDs); if (is_array($arrMatchIDs) && $count > $params['limit']) { $arrMatchIDs = array_slice($arrMatchIDs, 0, $params['limit'], true); } if (!empty($arrMatchIDs)) { $modelObject->getMatch()->setId(array_keys($arrMatchIDs)); } //get list team id $arrTeamId = $this->getListTableRanking(); } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); } //return array result return array('arrMatchIDs' => $arrMatchIDs, 'arrTeamId' => $arrTeamId); }