Beispiel #1
0
 /**
  * Function add article from backend editor
  * @param array $arrArticleDetail
  * @return boolean | array
  * @author PhuongTN
  * @todo thethao
  * @modify HungNT1
  */
 public function addArticle($intArticleId)
 {
     try {
         //default response
         $response = array();
         //new article fw
         $objArticle = Fpt_Data_News_Article::getInstance();
         //get full article
         $arrArticleDetail = $objArticle->getArticleFull($intArticleId);
         //check cate on site
         if (!$arrArticleDetail['cate'] || !array_key_exists(SITE_ID, $arrArticleDetail['cate'])) {
             return false;
         }
         //end if
         //check is schedule article
         if ($arrArticleDetail['publish_time'] > time()) {
             return false;
         }
         //init model news
         $modelNews = Thethao_Model_News::getInstance();
         //format data
         $this->getArticleForJob($arrArticleDetail);
         //get app conf
         $config = Thethao_Global::getApplicationIni();
         /* @var $newsNosql Thethao_Business_News_Adapter_Nosql */
         $newsNosql = $this->factory('Article', $config['database']['nosql']['adapter']);
         //rule 1
         foreach ($arrArticleDetail['cate_rule1'] as $intCateId) {
             $arrDBParams = array('category_id' => $intCateId, 'article_type' => 0, 'offset' => 0, 'limit' => 1);
             //get db list
             $modelNews->getListArticleIdsByRule1($arrDBParams);
             $arrDBParams = array('category_id' => $intCateId, 'article_type' => $arrArticleDetail['article_type'], 'offset' => 0, 'limit' => 1);
             //get db list
             $modelNews->getListArticleIdsByRule1($arrDBParams);
         }
         //rule 2
         foreach ($arrArticleDetail['cate_list_on'] as $intCateId) {
             $modelNews->getListArticleIdsByRule2(array('category_id' => $intCateId, 'offset' => 0, 'limit' => 1));
         }
         //add list news
         $response['rule2'] = $newsNosql->addArticle($arrArticleDetail);
         //precache rule 3 cho site seagame
         $param_rule3 = array('category_id' => SEA_GAMES, 'offset' => 0, 'limit' => 1);
         $response['rule3'] = $modelNews->getListArticleIdsByRule3($param_rule3);
     } catch (Exception $ex) {
         //log error
         Thethao_Global::sendLog($ex);
     }
     return $response;
 }
Beispiel #2
0
 /**
  * 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()));
 }
Beispiel #3
0
 /**
  * get Data for Block
  * @return void
  * @author LamTX
  */
 public function getBlockAll($pagecode = false)
 {
     $class = array();
     //check get block detail
     if ($this->_data == null) {
         if ($pagecode === false) {
             //get object Request
             $request = Zend_Controller_Front::getInstance()->getRequest();
             //get module application
             $module = $request->getModuleName();
             //get controller application
             $controller = $request->getControllerName();
             //get action application
             $action = $request->getActionName();
             //get cate for block
             $cate = $request->getParam('block_cate', SITE_ID);
         } else {
             $arrParams = explode('_', $pagecode);
             //get module application
             $module = $arrParams[0];
             //get controller application
             $controller = $arrParams[1];
             //get action application
             $action = $arrParams[2];
             //get cate for block
             $cate = $arrParams[3];
         }
         //get block detail for page
         $pageCode = $module . '_' . $controller . '_' . $action . '_' . $cate;
         if ($controller == 'detail') {
             //check device is mobile, then not get block
             if (DEVICE_ENV == 1) {
                 $this->_data = '-1';
                 return;
             }
             //check cate to get list block
             if ($cate == SITE_ID) {
                 $pageCode = $module . '_index_index_' . $cate;
             } else {
                 $pageCode = $module . '_category_index_' . $cate;
             }
         }
         //get model block in fw
         $modelBlock = Fpt_Data_News_Block::getInstance();
         $layout = $modelBlock->getBlockByPage($pageCode);
         if (empty($layout) || $layout == '-1') {
             $this->_data = '-1';
             return;
         }
         //get Instance Article
         $objArtilce = Fpt_Data_News_Article::getInstance();
         //each pos block
         foreach ($layout as $pos => $blocks) {
             //each get data type left or right
             foreach ($blocks as $key => $block) {
                 //set default data block
                 $block['data'] = array();
                 //check type block
                 if ($block['type'] == 'dynamic') {
                     //get paramt to block
                     $arrParam = $block['param'];
                     //get paramt to block
                     $arrParam['exclude'] = isset($arrParam['exclude']) ? (int) $arrParam['exclude'] : 0;
                     // get class block
                     $className = $block['class'];
                     // get function block
                     $functionName = $block['function'];
                     //check exclude data require limit
                     if (!isset($class[$className])) {
                         $class[$className] = new $className();
                     }
                     $data = $class[$className]->{$functionName}($arrParam);
                     //get data for block
                     //$data = call_user_func_array(array(new $className(), $functionName), array($arrParam));
                     //check data empty
                     if (is_array($data) && !empty($data)) {
                         //set data to block
                         $block['data'] = $data;
                         //print_r($data);
                         if (!empty($data['data'])) {
                             $objArtilce->setIdBasic($data['data']);
                         }
                     }
                 }
                 //set data to object
                 $this->_data["{$pos}"][$key] = $block;
             }
         }
     }
     return;
 }
Beispiel #4
0
 /**
  * Get news by rule 4 : folder X + subfolder X in week => order by total_view desc, publish_time desc
  * from in the framework
  * @author HungNT1
  * @param type array('category_id', 'offset', 'limit')
  * @return array('data' => array());
  */
 public function getListArticleIdsByRule4($arrParams)
 {
     //set paramt default
     $arrDefault = array('category_id' => NULL, 'site_id' => SITE_ID, 'type' => 1, 'limit' => 10, 'offset' => 0);
     //merge param with default
     $arrParams = array_merge($arrDefault, $arrParams);
     //check limit with max_limit to reset limit
     $arrParams['limit'] = $arrParams['limit'] > $this->_max_limit ? $this->_max_limit : $arrParams['limit'];
     $arrReturn = array();
     try {
         $intLimit = intval($arrParams['limit']);
         if ($arrParams['category_id'] == SITE_ID) {
             $arrParams['category_id'] = NULL;
         }
         $objArticle = Fpt_Data_News_Article::getInstance();
         $arrReturn = $objArticle->getNewsByTopView($arrParams);
         //Count data
         $count = count($arrData);
         if ($count < $intLimit) {
             $arrParams['category_id'] = NULL;
             $arrParams['site_id'] = SITE_ID;
             $arrParams['limit'] = 10;
             $arrData = $objArticle->getNewsByTopView($arrParams);
             $arrReturn = array_merge($arrReturn, $arrData);
         }
         if (!empty($arrData)) {
             $arrReturn = array_slice($arrReturn, 0, $intLimit);
         }
     } catch (Zend_Exception $ex) {
         //log error
         Thethao_Global::sendLog($ex);
     }
     return $arrReturn;
 }
Beispiel #5
0
 /**
  * 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()));
 }
Beispiel #6
0
 public function __construct()
 {
     $this->_article = Fpt_Data_News_Article::getInstance();
     $this->_block = Fpt_Data_News_Block::getInstance();
 }