Beispiel #1
0
 public function addAction()
 {
     error_reporting(E_ALL);
     ini_set('display_errors', '0');
     $this->_helper->layout->disableLayout();
     $request = $this->getRequest();
     $form = new Application_Form_FeadAdd();
     if ($this->getParam('url')) {
         $feads = Application_Service_Fead::getInstance()->searchFead($this->getParam('url'));
         // no fead found
         if (is_null($feads)) {
             echo json_encode(['error' => $this->_translate->_('add_fead_error')]);
             // one fead found (add it)
         } else {
             if (1 === sizeof($feads)) {
                 $userId = $this->_session->getSessionId();
                 $fead = new Application_Model_Entity_Fead($feads[0]);
                 $id = Application_Model_FeadRepository::getInstance()->addFead($fead);
                 echo json_encode(['success' => $id]);
                 // more feads found (select one)
             } else {
                 echo json_encode(['feads' => $feads]);
             }
         }
     } else {
         $this->view->form = $form;
     }
 }
Beispiel #2
0
 public function addFead(Application_Model_Entity_Fead $fead)
 {
     $id = $this->urlExists($fead->getUrl());
     if (!$id) {
         $this->_db->insert($this->_table, ['title' => $fead->getTitle(), 'url' => $fead->getUrl()]);
         $id = $this->_db->lastInsertId($this->_table);
         Application_Service_Fead::getInstance()->updateFead($fead->getUrl(), $id);
     }
     Application_Model_UserFeadRepository::getInstance()->add($id);
     return $id;
 }
 public function addAction()
 {
     $this->_helper->layout->disableLayout();
     $url = $this->getParam('u');
     $status = 2;
     if (is_null($this->_session->getSessionId())) {
         $status = 3;
     } else {
         if ($url) {
             $feads = Application_Service_Fead::getInstance()->searchFead($url);
             if (is_null($feads) || 1 !== sizeof($feads)) {
                 $status = 2;
             } else {
                 $fead = new Application_Model_Entity_Fead($feads[0]);
                 $id = Application_Model_FeadRepository::getInstance()->addFead($fead);
                 $status = 1;
             }
         }
     }
     $this->redirect("/img/webimporter/{$status}.png");
 }