Example #1
0
 public function process()
 {
     $failed = array('code' => 0, 'msg' => 'NKORG_RSSIMPORT_IMPORTFAILED');
     $success = array('code' => 1, 'msg' => 'NKORG_RSSIMPORT_IMPORTSUCCESS');
     try {
         $xmlObj = simplexml_load_file($this->feedPath);
     } catch (Exception $e) {
         $this->response($failed);
     }
     if (!is_a($xmlObj, 'SimpleXMLElement')) {
         $this->response($failed);
     }
     $rss20 = new \fpcm\modules\nkorg\rssimport\model\rss20($xmlObj, $this->feedIds, $this->userId, $this->categories);
     if ($rss20->check() && $rss20->import()) {
         $this->response($success);
     }
     $atom = new \fpcm\modules\nkorg\rssimport\model\atom($xmlObj, $this->feedIds, $this->userId, $this->categories);
     if ($atom->check() && $atom->import()) {
         $this->response($success);
     }
     $this->response($failed);
 }
Example #2
0
 public function process()
 {
     $failed = array('code' => 0, 'msg' => 'nkorg_rssimport_checkfailed');
     $success = array('code' => 1, 'msg' => 'nkorg_rssimport_checkok');
     try {
         $xml = simplexml_load_file($this->feedPath);
     } catch (Exception $e) {
         $this->response($failed);
     }
     if (!is_a($xml, 'SimpleXMLElement')) {
         $this->response($failed);
     }
     $rss20 = new \fpcm\modules\nkorg\rssimport\model\rss20($xml);
     if ($rss20->check()) {
         $success['list'] = $rss20->getList();
         $this->response($success);
     }
     $atom = new \fpcm\modules\nkorg\rssimport\model\atom($xml);
     if ($atom->check()) {
         $success['list'] = $atom->getList();
         $this->response($success);
     }
     $this->response($failed);
 }