/** * The private portal view */ public function publicAction() { // user information if (Zend_Auth::getInstance()->hasIdentity()) { $user = Zend_Auth::getInstance()->getIdentity(); } else { $user = null; } $this->view->user = $user; // get last newsletter $zpCache = Zend_Registry::get('daycache'); if (!($content = $zpCache->load('newsletter'))) { // get feed url $zpCfgFeeds = new Zend_Config_Ini('../config/zpfeeds.ini', 'public'); $url = $zpCfgFeeds->zend_newsletter; try { $feed = Zend_Feed::import($url); // take the first feed from feed item foreach ($feed as $entry) { $content = $entry->content(); $zpCache->save($content, 'newsletter'); break; } } catch (Exception $e) { $content = null; } } $this->view->entry = $content; }
public function indexAction() { $this->view->version = Application::VERSION; try { $feed = Zend_Feed::import('http://source.keyboard-monkeys.org/projects/communityid/news?format=atom'); } catch (Zend_Exception $e) { // feed import failed $obj = new StdClass(); $obj->link = array('href' => ''); $obj->title = $this->view->translate('Could not retrieve news items'); $obj->updated = ''; $obj->content = ''; $feed = array($obj); } $this->view->news = array(); $i = 0; foreach ($feed as $item) { if ($i++ >= self::NEWS_NUM_ITEMS) { break; } // ATOM uses <link href="foo" />, while RSS uses <link>foo</link> $item->link = $item->link['href'] ? $item->link['href'] : $item->link; if (strlen($item->content) > self::NEWS_CONTENT_MAX_LENGTH) { $item->content = substr($item->content, 0, self::NEWS_CONTENT_MAX_LENGTH) . '...<br /><a class="readMore" href="' . $item->link . '">' . $this->view->translate('Read More') . '</a>'; } $this->view->news[] = $item; } $this->_helper->actionStack('index', 'login', 'users'); }
function get() { require_once 'Zend/Feed.php'; try { $rss = Zend_Feed::import($this->url); } catch (Zend_Feed_Exception $e) { echo "Error while importing feed: {$e->getMessage()}\n"; exit; } $output = '<div style="padding:10px 15px;"><ul class="rss">'; $i = 0; foreach ($rss as $post) { $title = $post->title(); $date = strftime("%B %e, %Y", strtotime($post->pubDate())); $link = $post->link(); $output .= '<li><a class="rss-title" title="" href="' . $link . '">' . $title . '</a>' . '<span class="rss-date">' . $date . '</span>'; if ($this->showDescription) { $output .= '<div class="rss-description">' . $post->description() . '</div>'; } if ($this->showContent) { $output .= '<div class="rss-content">' . $post->content() . '</div>'; } $output .= '</li>'; if (++$i == $this->count) { break; } } $output .= '</ul></div>'; return $output; }
function index() { $this->load->library('zend', 'Zend/Feed'); $this->load->library('zend', 'Zend/Search/Lucene'); $this->load->library('zend'); $this->zend->load('Zend/Feed'); $this->zend->load('Zend/Search/Lucene'); //Create index. $index = new Zend_Search_Lucene('C:\\xampp\\xampp\\htdocs\\controle_frota\\lucene\\feeds_index', true); $feeds = array('http://oglobo.globo.com/rss.xml?limite=50'); //grab each feed. foreach ($feeds as $feed) { $channel = Zend_Feed::import($feed); echo $channel->title() . '<br />'; //index each item. foreach ($channel->items as $item) { if ($item->link() && $item->title() && $item->description()) { //create an index doc. $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('link', $this->sanitize($item->link()))); $doc->addField(Zend_Search_Lucene_Field::Text('title', $this->sanitize($item->title()))); $doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $this->sanitize($item->description()))); echo "\tAdding: " . $item->title() . '<br />'; $index->addDocument($doc); } } } $index->commit(); echo $index->count() . ' Documents indexed.<br />'; }
protected function loadFeed($rssUrl) { try { $feed = Zend_Feed::import($rssUrl); } catch (Zend_Feed_Exception $e) { return false; } return $feed; }
public static function import($uri) { $feed = new self(); $zend_feed = \Zend_Feed::import($uri); $feed->feed = $zend_feed; $feed->encoding = $feed->feed->getDOM()->ownerDocument->encoding; $feed->process(); return $feed; }
/** * */ public function renderWidget($ps_widget_id, &$pa_settings) { parent::renderWidget($ps_widget_id, $pa_settings); if ($pa_settings['feed_url']) { $vs_feed_url = $pa_settings['feed_url']; } else { $vs_feed_url = "http://icom.museum/rss.xml"; } $vs_feed_url_md5 = md5($vs_feed_url); if (ExternalCache::contains($vs_feed_url_md5, 'Meow')) { $feed = ExternalCache::fetch($vs_feed_url_md5, 'Meow'); } else { try { $feed = Zend_Feed::import($vs_feed_url); } catch (Exception $e) { return null; } ExternalCache::save($vs_feed_url_md5, $feed, 'Meow'); $feed->__wakeup(); } //A little style definition $rssViewContent = "" . "<STYLE type=\"text/css\">" . ".rssViewerWidgetContent, .rssViewerWidgetContent P, .rssViewerWidgetContent DIV, .rssViewerWidgetContent H1," . ".rssViewerWidgetContent H2" . " {margin:0px;padding:0px;margin-right:10px;padding-right:20px;}" . ".rssViewerWidgetContent H3 " . " {margin:0px;padding:0px;margin-right:10px;margin-top:10px;padding-right:20px;}" . "</STYLE>" . "<span class=\"rssViewerWidgetContent\">"; //Initializing count to the limit : number_of_feeds $vn_c = 0; //Initializing description variable to store description with or without images $description = ""; // Reading RSS feeds title, URL and description $this->opo_view->setVar('title', $feed->title()); $this->opo_view->setVar('description', $feed->description()); $this->opo_view->setVar('link', $feed->link()); $rssViewContent .= "<h1><a href=\"" . $feed->link() . "\" target=\"_blank\">" . $feed->title() . "</a></h1>\n" . $feed->description(); // Main loop : reading the items foreach ($feed as $item) { $vn_c++; if ($vn_c <= $pa_settings['number_of_feeds']) { // retrieve content $this->opo_view->setVar('item_title', $item->title()); $this->opo_view->setVar('item_description', $item->description()); $this->opo_view->setVar('item_link', $item->link()); $description = $item->description(); // when filtering images is on, remove IMG tags from description // when filtering HTML is on, remove all HTML tags if ($pa_settings['filter_html'] == 2) { $description = strip_tags($description); } elseif ($pa_settings['filter_html'] == 1) { $description = preg_replace("/<img[^>]+\\>/i", " ", $description); } // HTML generation of the content to display, 1 span surrounding each feed $rssViewContent .= "" . "<h3><a href=\"" . $item->link() . "\" target=\"blank\">" . $item->title() . "</a></h3>\n" . "" . $description . "\n"; } $rssViewContent .= "</span>"; } $this->opo_view->setVar('item_content', $rssViewContent); $this->opo_view->setVar('request', $this->getRequest()); return $this->opo_view->render('main_html.php'); }
public function indexAction() { // Zend_Feed required DOMDocument if (!class_exists('DOMDocument', false)) { $this->view->badPhpVersion = true; return; } // Get params $url = 'http://www.socialengine.com/blog/?feed=rss2'; if (!$url) { return $this->setNoRender(); } $this->view->url = $url; $this->view->max = $max = $this->_getParam('max', 4); $this->view->strip = $strip = $this->_getParam('strip', false); $cacheTimeout = 1800; // Cacheing $cache = Zend_Registry::get('Zend_Cache'); if ($cache instanceof Zend_Cache_Core && $cacheTimeout > 0) { $cacheId = get_class($this) . md5($url . $max . $strip); $channel = $cache->load($cacheId); if (!is_array($channel) || empty($channel)) { $channel = null; } else { if (time() > $channel['fetched'] + $cacheTimeout) { $channel = null; } } } else { $cacheId = null; $channel = null; } if (!$channel) { $rss = Zend_Feed::import($url); $channel = array('title' => $rss->title(), 'link' => $rss->link(), 'description' => $rss->description(), 'items' => array(), 'fetched' => time()); // Loop over each channel item and store relevant data $count = 0; foreach ($rss as $item) { if ($count++ >= $max) { break; } $channel['items'][] = array('title' => $item->title(), 'link' => $item->link(), 'description' => $item->description(), 'pubDate' => $item->pubDate(), 'guid' => $item->guid()); } $this->view->isCached = false; // Caching if ($cacheId && !empty($channel)) { $cache->save($channel, $cacheId); } } else { $this->view->isCached = true; } $this->view->channel = $channel; }
public function next() { if ($this->current_feed && $this->current_feed->valid()) { $this->current_feed->next(); } else { if (!isset($this->urls[$this->urls_i])) { $this->current_feed = null; } else { $this->current_feed = Zend_Feed::import($this->urls[$this->urls_i++]); $this->current_feed->rewind(); } } }
public function fetchEntries() { $entries = array(); try { $feed = Zend_Feed::import($this->_url); foreach ($feed as $item) { $entries[] = $this->_createEntry($item); } } catch (Zend_Exception $e) { throw new Ls_Aggregator_Exception('Failed to aggregate, ' . $e->getMessage()); } return $entries; }
public function updateData() { $username = $this->getProperty('username'); $feed_url = "http://feeds.launchpad.net/~{$username}/revisions.atom"; // Fetch the latest headlines from the feed try { $items = $feed = Zend_Feed::import($feed_url); return $this->processItems($items); } catch (Zend_Feed_Exception $e) { return; } // Mark as updated (could have been with errors) $this->markUpdated(); }
public function updateData() { $username = $this->getProperty('username'); $url = "http://rss.stumbleupon.com/user/{$username}/favorites"; // Fetch the latest headlines from the feed try { $items = Zend_Feed::import($url); return $this->processItems($items); } catch (Zend_Feed_Exception $e) { throw new Stuffpress_Exception("Stumbleupon - could not fetch feed at url {$url}", 0); } // Mark as updated (could have been with errors) $this->markUpdated(); }
public function importData() { $url = $this->getProperty('url'); $feeds = Zend_Feed::findFeeds($url); if (!$feeds) { $items = Zend_Feed::import($url); $feed_url = $url; } else { $items = $feeds[0]; $feed_url = Zend_Feed::getHttpClient()->getUri(true); } $this->setProperty('feed_url', $feed_url); $items = $this->processItems($items, 'published'); $this->setImported(true); return $items; }
function getNewsFeed() { $news = array(); require_once 'Zend/Feed.php'; $feed_url = 'http://helpdesk.blogs.plymouth.edu/category/its-helpdesk-news/feed'; try { $rss = Zend_Feed::import($feed_url); } catch (Zend_Feed_Exception $e) { return "Exception caught importing feed: {$e->getMessage()}\n"; } // end catch if (!$rss) { return 'There are no articles in this news feed'; } // end if $limit = 2; $count = 0; foreach ($rss as $item) { $article = array(); if ($count > $limit - 1) { break; } $count++; $article['link'] = $item->link; $emdash = chr(226) . chr(128) . chr(148); $apos = chr(226) . chr(128) . chr(153); $replace = array($emdash, $apos); $with = array('—', "'"); $title = str_replace($replace, $with, $item->title()); $article['title'] = $title; $pubdate = date('M jS, Y \\a\\t g:ia', strtotime($item->pubDate)); $article['date'] = $pubdate; $article['creator'] = $item->{'dc:creator'}; // iterate over all categories $all_categories = array(); foreach ($item->category as $category) { $all_categories[] = $category; } // end foreach // if there is only one category, Zend will not iterate over it, so we need to grab it individually $all_categories = count($all_categories) > 0 ? $all_categories : array($item->category); $article['category'] = implode(', ', $all_categories); $news[] = $article; } // end foreach return $news; }
public function importData() { $url = $this->getProperty('url'); $feeds = Zend_Feed::findFeeds($url); if (!$feeds) { $items = Zend_Feed::import($url); $feed_url = $url; } else { $feeds_uri = array_keys($feeds); $feed_url = $feeds_uri[0]; $items = $feeds[$feed_url]; } $this->setProperty('feed_url', $feed_url); $items = $this->processItems($items); $this->setImported(true); return $items; }
/** * */ public function renderWidget($ps_widget_id, &$pa_settings) { parent::renderWidget($ps_widget_id, $pa_settings); $vs_feed_url = 'http://feeds.feedburner.com/ICanHasCheezburger'; $vs_feed_url_md5 = md5($vs_feed_url); if (ExternalCache::contains($vs_feed_url_md5, 'Meow')) { $feed = ExternalCache::fetch($vs_feed_url_md5, 'Meow'); } else { try { $feed = Zend_Feed::import($vs_feed_url); } catch (Exception $e) { return null; } ExternalCache::save($vs_feed_url_md5, $feed, 'Meow'); $feed->__wakeup(); } $this->opo_view->setVar('title', $feed->title()); $vn_i = (int) rand(0, $feed->count() - 1); // pick a random cat $vn_c = 0; foreach ($feed as $item) { if ($vn_c < $vn_i) { $vn_c++; continue; // skip until we get to our random cat } $this->opo_view->setVar('item_title', $item->title()); $this->opo_view->setVar('item_description', $item->description()); $this->opo_view->setVar('item_link', $item->link()); // Find the image URL in the encoded HTML content... if (preg_match("!(https://i.chzbgr.com/maxW500/[^\"']+)!i", $item->encoded(), $va_matches)) { $vs_url = $va_matches[1]; $vn_width = 430; // force width of image to 430 pixels //$vn_height = floor($vn_width / 1.57); // assume aspect ratio is 1.57 (typical). This results is an occasional squished cat but who's counting? $this->opo_view->setVar('item_image', "<img src='{$vs_url}' width='{$vn_width}'/>"); break; } // if we fall through to here it means we couldn't find an image link in the encoded HTML content // so we just skip to the next one and see if there's a cat in there. $vn_c++; } $this->opo_view->setVar('request', $this->getRequest()); return $this->opo_view->render('main_html.php'); }
public function getFeed() { $feed = $this->getData('feed'); if ($feed) { return $feed; } $uri = $this->getUri(); if (!$uri) { return null; } try { $feed = Zend_Feed::import($uri); } catch (Exception $e) { return null; } $this->setFeed($feed); return $feed; }
/** * Displays the OntoWiki news feed */ public function newsAction() { $owFeed = null; $version = $this->_config->version; $this->view->placeholder('main.window.title')->set('News'); try { $url = 'http://blog.aksw.org/feed/?cat=5&client=' . urlencode($version->label) . '&version=' . urlencode($version->number) . '&suffix=' . urlencode($version->suffix); $owFeed = Zend_Feed::import($url); $this->view->feed = $owFeed; $this->view->title = $owFeed->title(); $this->view->link = $owFeed->link(); $this->view->description = $owFeed->description(); } catch (Exception $e) { $this->_owApp->appendMessage(new OntoWiki_Message('Error loading feed: ' . $url, OntoWiki_Message::WARNING)); $this->view->feed = array(); } OntoWiki::getInstance()->getNavigation()->disableNavigation(); }
public static function displayBlogContent() { if (SJB_System::getSettingByName('display_blog_on_homepage') && SJB_System::getSettingByName('rss_url_for_wordpress') !== '') { $url = SJB_System::getSettingByName('rss_url_for_wordpress'); try { $feed = Zend_Feed::import($url); } catch (Exception $ex) { $feed = array(); } $i18n = SJB_I18N::getInstance(); $items = array(); foreach ($feed as $feedItem) { $date = new Zend_Date($feedItem->pubDate(), DATE_RSS, 'en_US'); $item = array('date' => $feedItem->pubDate() ? $i18n->getDate($date->toString()) : '', 'title' => $feedItem->title(), 'description' => $feedItem->description(), 'link' => $feedItem->link()); $items[] = $item; } return $items; } }
/** * Returns the feed * * Tries to create the feed from the URI. * * @return Zend_Feed */ protected function getFeed() { $feed = $this->getData('feed'); if (is_null($feed)) { $uri = $this->getData('uri'); if (!is_null($uri)) { try { $feed = Zend_Feed::import($uri); $this->setData('feed', $feed); // update the cache tag $this->setCacheKey($uri); } catch (Zend_Http_Client_Exception $e) { Mage::logException($e); } catch (Zend_Feed_Exception $e) { Mage::logException($e); } } } return $feed; }
function writeResponse(DevblocksHttpResponse $response) { $tpl = DevblocksPlatform::getTemplateService(); $tpl_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/'; $sNewsRss = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_NEWS_RSS, ''); $aNewsRss = !empty($sNewsRss) ? unserialize($sNewsRss) : array(); $feeds = array(); // [TODO] Implement a feed cache so we aren't bombing out foreach ($aNewsRss as $title => $url) { $feed = null; try { $feed = Zend_Feed::import($url); } catch (Exception $e) { } if (!empty($feed) && $feed->count()) { $feeds[] = array('name' => $title, 'url' => $url, 'feed' => $feed); } } $tpl->assign('feeds', $feeds); $tpl->display("file:{$tpl_path}portal/sc/module/announcements/index.tpl"); }
function eventAjaxNumOfFeedsInWebPage(EventControler $evctl) { $do_contact_website = new ContactWebsite(); $do_contact_website->getId($evctl->idcontact_website); $website_type = $do_contact_website->website_type; $uri = $do_contact_website->website; if ($website_type == "RSS Feed") { //Feed from xml $feed = Zend_Feed::import($uri); $feed_count = $feed->count(); $this->updateFeedStatus($feed_count, $evctl->idcontact_website); $evctl->addOutputValue($feed_count); } else { //Feed from webpage $uri = (substr(ltrim($uri), 0, 7) != 'http://' ? 'http://' : '') . $uri; $arr_feeds = Zend_Feed::findFeeds($uri); $this->num_feeds = count($arr_feeds); $this->updateFeedStatus($this->num_feeds, $evctl->idcontact_website); $evctl->addOutputValue(count($arr_feeds)); } }
public function indexAction() { // Zend_Feed required DOMDocument // @todo add to sanity check if (!class_exists('DOMDocument', false)) { $this->view->badPhpVersion = true; return; //return $this->setNoRender(); } $rss = Zend_Feed::import('http://www.socialengine.net/news_rss.php'); $channel = array('title' => $rss->title(), 'link' => $rss->link(), 'description' => $rss->description(), 'items' => array()); $max = $this->_getParam('max', 4); $count = 0; // Loop over each channel item and store relevant data foreach ($rss as $item) { if ($count++ >= $max) { break; } $channel['items'][] = array('title' => $item->title(), 'link' => $item->link(), 'description' => $item->description(), 'pubDate' => $item->pubDate(), 'guid' => $item->guid()); } $this->view->channel = $channel; }
public function indexAction() { $url = $this->_getParam('url'); if (!$url) { return $this->setNoRender(); } $this->view->url = $url; // Zend_Feed requires DOMDocument if (!class_exists('DOMDocument', false)) { return $this->setNoRender(); } $rss = Zend_Feed::import($url); $channel = array('title' => $rss->title(), 'link' => $rss->link(), 'description' => $rss->description(), 'items' => array()); $max = $this->_getParam('max', 4); $count = 0; // Loop over each channel item and store relevant data foreach ($rss as $item) { if ($count++ >= $max) { break; } $channel['items'][] = array('title' => $item->title(), 'link' => $item->link(), 'description' => $item->description(), 'pubDate' => $item->pubDate(), 'guid' => $item->guid()); } $this->view->channel = $channel; }
public function updateData() { $feed_url = $this->getProperty('feed_url'); // Fetch the latest headlines from the feed try { $items = $feed = Zend_Feed::import($feed_url); return $this->processItems($items); } catch (Zend_Feed_Exception $e) { return; } // Mark as updated (could have been with errors) $this->markUpdated(); }
/** * Import an invalid feed */ protected function _importInvalid($filename) { $response = new Zend_Http_Response(200, array(), file_get_contents("$this->_feedDir/$filename")); $this->_adapter->setResponse($response); try { $feed = Zend_Feed::import('http://localhost'); } catch (Exception $e) { } $this->assertTrue($e instanceof Zend_Feed_Exception, 'Expected Zend_Feed_Exception to be thrown'); }
* Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category Zend * @package Zend_Feed * @subpackage Demos * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * Consume an RSS feed and display all of the titles and * associated links within. */ /** * @see Zend_Feed */ require_once 'Zend/Feed.php'; $feed = Zend_Feed::import('http://news.google.com/?output=rss'); foreach ($feed->items as $item) { echo "<p>" . $item->title() . "<br />"; echo $item->link() . "</p>"; }
protected function _importInvalid($filename) { $this->_client->setFilename("{$this->_feedDir}/{$filename}"); try { $feed = Zend_Feed::import('http'); } catch (Exception $e) { } $this->assertTrue($e instanceof Zend_Feed_Exception, 'Expected Zend_Feed_Exception to be thrown'); }
* @package Zend_Search_Lucene * @subpackage Demos * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Feed */ require_once 'Zend/Feed.php'; /** * @see Zend_Search_Lucene */ require_once 'Zend/Search/Lucene.php'; //create the index $index = new Zend_Search_Lucene('/tmp/feeds_index', true); // index each item $rss = Zend_Feed::import('http://feeds.feedburner.com/ZendDeveloperZone'); foreach ($rss->items as $item) { $doc = new Zend_Search_Lucene_Document(); if ($item->link && $item->title && $item->description) { $link = htmlentities(strip_tags($item->link())); $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $link)); $title = htmlentities(strip_tags($item->title())); $doc->addField(Zend_Search_Lucene_Field::Text('title', $title)); $contents = htmlentities(strip_tags($item->description())); $doc->addField(Zend_Search_Lucene_Field::Text('contents', $contents)); echo "Adding {$item->title()}...\n"; $index->addDocument($doc); } } $index->commit();
/** * Imports an invalid feed */ protected function _importInvalid($filename) { $response = new Zend_Http_Response(200, array(), file_get_contents("{$this->_feedDir}/{$filename}")); $this->_adapter->setResponse($response); try { $feed = Zend_Feed::import('http://localhost'); $this->fail('Expected Zend_Feed_Exception not thrown'); } catch (Zend_Feed_Exception $e) { $this->assertType('Zend_Feed_Exception', $e); } }