/** * Update feed * * @param string $feed feed url to update */ public function update($feed = null) { $this->_init(); require_once 'Ifphp/models/Feeds.php'; $feeds = new Feeds(); if ($feed) { $feed = $feeds->getBySiteUrl($feed); if (!$feed) { return; } else { $this->updateFeed($feed); } } else { $tfeeds = $feeds->fetchAll($feeds->select()); if ($this->_registry->getRequest()->isPretend()) { echo 'This would update ' . $tfeeds->count() . ' feeds'; exit; } foreach ($tfeeds as $feed) { $this->updateFeed($feed); } } }
/** * @todo Remove when done */ public function fixAction() { $posts = new Posts(); $tposts = $posts->fetchAll($posts->select()->where('id > 0')); $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()); foreach ($tposts as $post) { $post->title = $defaultFilterChain->filter($post->title); $post->description = $defaultFilterChain->filter($post->description); $post->feedId = $defaultFilterChain->filter($post->feedId); $post->link = $defaultFilterChain->filter($post->link); $post->publishDate = $post->publishDate; // Zend_Debug::dump($post->description); $post->save(); } $feeds = new Feeds(); $tfeeds = $feeds->fetchAll($feeds->select()->where('id > 0')); $inflector = new Zend_Filter_Inflector(':title'); $inflector->setRules(array(':title' => array('Word_SeparatorToDash', 'StringToLower', 'HtmlEntities'))); foreach ($tfeeds as $feed) { $feed->title = $defaultFilterChain->filter($feed->title); $feed->description = $defaultFilterChain->filter($feed->description); $feed->slug = $inflector->filter(array('title' => $feed->title)); $feed->save(); } die; }