/** * Add feed to system * * @param Feed $feed */ private function updateFeed(Feed $feed) { require_once 'Ifphp/models/Posts.php'; $feedSource = Zend_Feed_Reader::import($feed->url); $posts = new Posts(); $tdate = $feedSource->current()->getDateModified(); $tdate = new Zend_Date($tdate); while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) { $tdate = $feedSource->current()->getDateModified(); $tdate = new Zend_Date($tdate); $defaultFilterChain = new Zend_Filter(); $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean()); $defaultFilterChain->addFilter(new Zend_Filter_StringTrim()); $defaultFilterChain->addFilter(new Zend_Filter_StripTags()); $post = $posts->createRow(); $post->title = $defaultFilterChain->filter($feedSource->current()->getTitle()); $post->description = $defaultFilterChain->filter($feedSource->current()->getDescription()); $post->feedId = $defaultFilterChain->filter($feed->id); $post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink()); $post->publishDate = $tdate->toValue(); $post->save(); Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed); $feedSource->next(); } $feed->lastPing = time(); $feed->save(); }
/** * Get the latest posts from a feed * * @param Feed $feed */ protected function updateFeedPosts(Feed $feed) { $feedSource = Zend_Feed_Reader::import($feed->url); $posts = new Posts(); $tdate = $feedSource->current()->getDateModified(); $tdate = new Zend_Date($tdate); $defaultFilterChain = new Zend_Filter(); $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean()); $defaultFilterChain->addFilter(new Zend_Filter_StringTrim()); $defaultFilterChain->addFilter(new Zend_Filter_StripTags()); $defaultFilterChain->addFilter(new Zend_Filter_HtmlEntities(array('quotestyle' => ENT_QUOTES, 'charset' => 'UTF-8'))); $defaultFilterChain->addFilter(new Ifphp_Filter_HtmlEntityNames()); while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) { $tdate = $feedSource->current()->getDateModified(); $tdate = new Zend_Date($tdate); $post = $posts->createRow(); $post->title = $defaultFilterChain->filter($feedSource->current()->getTitle()); $post->description = $defaultFilterChain->filter($feedSource->current()->getDescription()); $post->feedId = $defaultFilterChain->filter($feed->id); $post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink()); $post->publishDate = $tdate->toValue(); $post->save(); Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed); $feedSource->next(); } $feed->lastPing = time(); $feed->save(); }