예제 #1
0
파일: Update.php 프로젝트: piratevn/cms-gio
 public function linkAction()
 {
     $this->setNoRender();
     $this->disableLayout();
     $request = $this->getRequest();
     $linkId = (int) $request->getParam('link_id');
     $type = $request->getParam('web_id');
     if (!$linkId) {
         return;
     }
     $cron = new Modules_News_Services_Cron();
     switch ($type) {
         case 'vnexpress':
             $cron->vnexpress($linkId);
             break;
         case 'zing':
             $cron->zing($linkId);
             break;
         case 'dantri':
             $cron->dantri($linkId);
             break;
         case 'megafun':
             $cron->megafun($linkId);
             break;
         case 'kenh14':
             $cron->kenh14($linkId);
             break;
         case 'ngoisao':
             $cron->ngoisao($linkId);
             break;
         case 'haitugio':
             $cron->haitugio($linkId);
             break;
         case 'tuoitre':
             $cron->tuoitre($linkId);
             break;
         case 'thanhnien':
             $cron->thanhnien($linkId);
             break;
         case 'nguoilaodong':
             $cron->nguoilaodong($linkId);
             break;
         case 'haisao':
             $cron->haisao($linkId);
             break;
         case 'autopro':
             $cron->autopro($linkId);
             break;
         case 'bongda':
             $cron->bongda($linkId);
             break;
         case 'vtc':
             $cron->vtc($linkId);
             break;
         case 'tintuconline':
             $cron->tintuconline($linkId);
             break;
     }
     $arrayArticles = $cron->addArticles;
     $arrayCategories = $cron->addCategories;
     /**
      * 
      */
     if (!empty($arrayArticles) && !empty($arrayCategories)) {
         $conn = Gio_Db_Connection::getConnection();
         $articleDao = new Modules_News_Models_Mysql_Article();
         $articleDao->setConnection($conn);
         $articleAutoDao = new Modules_News_Models_Mysql_Articleauto();
         $articleAutoDao->setConnection($conn);
         for ($i = 0; $i < count($arrayArticles); $i++) {
             $addArticles = $arrayArticles[$i];
             $categories = $arrayCategories[$i];
             foreach ($addArticles as $index => $article) {
                 $existsArticle = $articleAutoDao->getByLink($article['link_source']);
                 if (null == $existsArticle) {
                     $articleAutoDao->add($article);
                 }
             }
         }
     }
 }
예제 #2
0
파일: Auto.php 프로젝트: piratevn/cms-gio
 public function run()
 {
     ini_set("max_execution_time", 100);
     ini_set('memory_limit', '256M');
     require_once LIB_DIR . DS . 'simplehtmldom' . DS . 'simple_html_dom.php';
     $conn = Gio_Db_Connection::getConnection();
     $articleAutoDao = new Modules_News_Models_Mysql_Articleauto();
     $articleAutoDao->setConnection($conn);
     $numArticles = 30;
     $articlesAuto = $articleAutoDao->find($numArticles);
     $articleDao = new Modules_News_Models_Mysql_Article();
     $articleDao->setConnection($conn);
     /**
      * Auto Tags
      */
     $autoTag = false;
     $allTags = array();
     if ($autoTag) {
         //			$tagDao = new Admin_Modules_News_Models_Mysql_Tag();
         //			$tagDao->setConnection($conn);
         //			$allTags = $tagDao->getAllTags();
     }
     if ($articlesAuto) {
         foreach ($articlesAuto as $index => $articleAuto) {
             $categories = explode('-', $articleAuto['category_ids']);
             $article = array('title' => trim($articleAuto['title']), 'slug' => trim($articleAuto['slug']), 'created_date' => $articleAuto['created_date'], 'category_id' => $categories[0], 'status' => 'active', 'description' => trim($articleAuto['description']), 'article_hot' => $index % 5 == 0 ? 1 : 0, 'article_sticky' => $index % 3 != 0 ? 1 : 0, 'link_source' => $articleAuto['link_source'], 'image_url' => $articleAuto['image_url'], 'web_id' => $articleAuto['website'], 'article_photo' => $articleAuto['article_photo'], 'article_video' => $articleAuto['article_video'], 'language' => 'vi_VN');
             $existsArticle = $articleDao->getByLink($article['link_source']);
             $articleAutoDao->delete($articleAuto['auto_id']);
             if (null == $existsArticle) {
                 switch ($articleAuto['website']) {
                     case 'vtc':
                         $article = $this->_vtc($article);
                         break;
                     case 'vnexpress':
                         $article = $this->_vnexpress($article);
                         break;
                     case 'dantri':
                         $article = $this->_dantri($article);
                         break;
                     case 'thethaovanhoa':
                         $article = $this->_thethaovanhoa($article);
                         break;
                     case 'zing':
                         $article = $this->_zing($article);
                         break;
                     case 'megafun':
                         $article = $this->_megafun($article);
                         break;
                     case 'kenh14':
                         $article = $this->_kenh14($article);
                         break;
                     case 'ngoisao':
                         $article = $this->_ngoisao($article);
                         break;
                     case 'haitugio':
                         $article = $this->_haitugio($article);
                         break;
                     case 'tuoitre':
                         $article = $this->_tuoitre($article);
                         break;
                     case 'thanhnien':
                         $article = $this->_thanhnien($article);
                         break;
                     case 'nguoilaodong':
                         $article = $this->_nguoilaodong($article);
                         break;
                     case 'haisao':
                         $article = $this->_haisao($article);
                         break;
                     case 'autopro':
                         $article = $this->_autopro($article);
                         break;
                     case 'bongda':
                         $article = $this->_bongda($article);
                         break;
                     case 'tintuconline':
                         $article = $this->_tintuconline($article);
                         break;
                 }
                 if ($article['title'] && $article['description'] && $article['content']) {
                     $articleId = $articleDao->add($article);
                     if ($articleId) {
                         /**
                          * Add to article category assoc
                          */
                         $articleDao->addToCategories($articleId, $categories);
                     }
                 }
             }
         }
     }
 }