public function processAction() { $form = new Admin_Form_AddBlog(); if (!$this->getRequest()->isPost()) { return $this->_forward('admin/index'); } $flashMessenger = $this->_helper->getHelper('FlashMessenger'); if (!$form->isValid($_POST)) { $flashMessenger->addMessage('Form data invalid: recheck details and try again.'); $flashMessenger->addMessage('error'); $this->_redirect('/admin/blog/create'); } $values = $form->getValues(); $blog = new Zfplanet_Model_Blog(); $blog->contactName = $values['contactName']; if (isset($values['contactEmail'])) { $blog->contactEmail = $values['contactEmail']; } $blog->uri = $values['uri']; try { $data = Zend_Feed_Reader::import($values['feedUri']); } catch (Exception $e) { $flashMessenger->addMessage('Problem fetching feed: ' . $e->getMessage()); $flashMessenger->addMessage('error'); $this->_redirect('/admin/blog/create'); } $blog->feedId = $data->getId(); $feed = new Zfplanet_Model_Feed(); $feedMeta = new Zfplanet_Model_FeedMeta(); $feed->id = $data->getId(); $feed->uri = $data->getFeedLink(); if (isset($feed->uri)) { $feed->uri = $values['feedUri']; } $feed->blogId = $blog->id; $feed->title = Zfplanet_Model_Feed::getHtmlPurifier()->purify($data->getTitle()); $feed->type = $this->_getFeedVersion($data->getType()); $feed->isActive = 1; $feedMeta->feedId = $data->getId(); $feedMeta->title = $data->getTitle(); $feedMeta->description = $data->getDescription(); $feedMeta->link = $data->getLink(); $feedMeta->feedLink = $data->getFeedLink(); $blog->save(); $feed->save(); $feedMeta->save(); $this->_checkPubsubEnabled($data); $flashMessenger->addMessage('Blog successfully added!'); $flashMessenger->addMessage('success'); $this->_redirect('/admin/blog/create'); }
public static function getHtmlPurifier() { if (isset(self::$_htmlPurifier)) { return self::$_htmlPurifier; } $config = self::_getHtmlPurifierConfig(); self::$_htmlPurifier = new HTMLPurifier($config); return self::$_htmlPurifier; }