Exemplo n.º 1
0
 /**
  * Get xml from feed data
  *
  * @codeCoverageIgnore due to static method call (\Zend_Feed::importArray)
  *
  * @param FeedInterface $feed
  * @return string
  */
 public function toXml(FeedInterface $feed)
 {
     $data = ['title' => $feed->getTitle(), 'link' => $feed->getLink(), 'charset' => 'UTF-8', 'description' => $feed->getDescription()];
     $rssFeedFromArray = $this->zendFeed->importArray($data, 'rss');
     $xml = $rssFeedFromArray->saveXML();
     return $xml;
 }
 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 />';
 }
Exemplo n.º 3
0
 /**
  * Zend_Feed_Entry_Abstract constructor
  *
  * The Zend_Feed_Entry_Abstract constructor takes the URI of the feed the entry
  * is part of, and optionally an XML construct (usually a
  * SimpleXMLElement, but it can be an XML string or a DOMNode as
  * well) that contains the contents of the entry.
  *
  * @param  string $uri
  * @param  SimpleXMLElement|DOMNode|string  $element
  * @return void
  */
 public function __construct($uri = null, $element = null)
 {
     if (!$element instanceof DOMElement) {
         if ($element) {
             // Load the feed as an XML DOMDocument object
             @ini_set('track_errors', 1);
             $doc = new DOMDocument();
             $success = @$doc->loadXML($element);
             @ini_restore('track_errors');
             if (!$success) {
                 throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
             }
             $element = $doc->getElementsByTagName($this->_rootElement)->item(0);
             if (!$element) {
                 throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
             }
         } else {
             $doc = new DOMDocument('1.0', 'utf-8');
             if ($this->_rootNamespace !== null) {
                 $element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
             } else {
                 $element = $doc->createElement($this->_rootElement);
             }
         }
     }
     parent::__construct($element);
 }
Exemplo n.º 4
0
 private function _getFeedXml()
 {
     $host = isset($_SERVER['HTTP_HOST']) ? 'http://' . $_SERVER['HTTP_HOST'] : '';
     $feedArray = array('title' => $this->_getRssTitle(), 'link' => $host . $this->getUrl(), 'charset' => 'utf-8', 'description' => '', 'copyright' => Zend_Registry::get('config')->application->name, 'generator' => 'Koala Framework', 'language' => $this->getData()->getLanguage(), 'entries' => $this->_getRssEntries());
     $feed = Zend_Feed::importArray($feedArray, 'rss');
     return $feed->saveXml();
 }
Exemplo n.º 5
0
 function recentlyAdded()
 {
     // redirect user if not logged in
     if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn() || $this->request->config->get('show_bristol_only') && !$this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form"));
     } elseif ($this->request->config->get('show_bristol_only') && $this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, "bristol", "Show", "Index"));
     }
     $t_object = new ca_objects();
     if (($vn_num_items = (int) $this->request->config->get('rss_number_of_items')) <= 0) {
         $vn_num_items = 10;
     }
     $va_recently_added_objects = $t_object->getRecentlyAddedItems($vn_num_items, array('checkAccess' => caGetUserAccessValues($this->request)));
     $va_entries = array();
     $va_object_ids = array();
     foreach ($va_recently_added_objects as $va_object) {
         $va_object_ids[] = $va_object['object_id'];
     }
     $qr_res = $t_object->makeSearchResult('ca_objects', $va_object_ids);
     $vs_description_bundle = $this->request->config->get('rss_description');
     while ($qr_res->nextHit()) {
         $vn_object_id = $qr_res->get('ca_objects.object_id');
         if (!($vn_creation_time = $t_object->getCreationTimestamp($vn_object_id, array('timestampOnly' => true)))) {
             $vn_creation_time = time();
         }
         if (!($vn_update_time = $t_object->getLastChangeTimestamp($vn_object_id, array('timestampOnly' => true)))) {
             $vn_update_time = time();
         }
         $va_entries[] = array('title' => $qr_res->get('ca_objects.preferred_labels.name'), 'link' => $vs_link = $this->request->config->get('site_host') . caNavUrl($this->request, '', 'Detail/Object', 'Index', array('object_id' => $vn_object_id)), 'guid' => $vs_link, 'lastUpdate' => $vn_update_time, 'description' => $vs_description_bundle ? $qr_res->getMediaTag("ca_object_representations.media", "preview") . "\n" . $qr_res->get($vs_description_bundle) : '', 'pubDate' => $vn_creation_time);
     }
     $va_feed_data = array('title' => _t('Recently added'), 'link' => $this->request->getRequestUrl(true), 'charset' => 'UTF-8', 'entries' => $va_entries);
     $o_feed = Zend_Feed::importArray($va_feed_data, 'rss');
     $this->view->setVar('feed', $o_feed);
     $this->render('Feed/feed_recently_added_xml.php');
 }
Exemplo n.º 6
0
 /**
  * Get a feed
  *
  * @param int $id
  * @return Feed
  */
 public function getFeed($url)
 {
     $feed = $this->dbService->getByField(array('url' => $url), 'Feed');
     $update = $feed == null || strtotime($feed->updated) < time() - 60 * 15;
     if ($feed == null) {
         $feed = new Feed();
     }
     if ($update) {
         $this->log->debug("Loading feed {$url}");
         // make the request!
         // $feed->content =
         $content = null;
         try {
             $client = Zend_Feed::getHttpClient();
             $client->setUri($url);
             $response = $client->request('GET');
             if ($response->getStatus() !== 200) {
                 throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus());
             }
             $content = $response->getBody();
         } catch (Exception $zfe) {
             $this->log->err("Failed loading feed from {$url}");
             return $content;
         }
         $feed->content = $content;
         $feed->url = $url;
         $this->dbService->saveObject($feed);
     }
     return $feed;
 }
Exemplo n.º 7
0
 /**
  * Gets the HTTP client object.
  *
  * @return Zend_Http_Client_Abstract
  */
 public static function getHttpClient()
 {
     if (!self::$_httpClient instanceof Zend_Http_Client_Abstract) {
         self::$_httpClient = new Zend_Http_Client();
     }
     return self::$_httpClient;
 }
 /**
  * Display RSS Data
  */
 public function displayRss($array, $type = 'rss')
 {
     $this->loadZend();
     $feed = Zend_Feed::importArray($array, $type);
     $feed->send();
     exit;
 }
Exemplo n.º 9
0
 /**
  * Feed constructor
  *
  * The Zend_Feed_Abstract constructor takes the URI of a feed or a
  * feed represented as a string and loads it as XML.
  *
  * @param  string $uri The full URI of the feed to load, or NULL if not retrieved via HTTP or as an array.
  * @param  string $string The feed as a string, or NULL if retrieved via HTTP or as an array.
  * @param  Zend_Feed_Builder_Interface $builder The feed as a builder instance or NULL if retrieved as a string or via HTTP.
  * @return void
  * @throws Zend_Feed_Exception If loading the feed failed.
  */
 public function __construct($uri = null, $string = null, Zend_Feed_Builder_Interface $builder = null)
 {
     if ($uri !== null) {
         // Retrieve the feed via HTTP
         $client = Zend_Feed::getHttpClient();
         $client->setUri($uri);
         $response = $client->request('GET');
         if ($response->getStatus() !== 200) {
             /**
              * @see Zend_Feed_Exception
              */
             #require_once 'Zend/Feed/Exception.php';
             throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus());
         }
         $this->_element = $response->getBody();
         $this->__wakeup();
     } elseif ($string !== null) {
         // Retrieve the feed from $string
         $this->_element = $string;
         $this->__wakeup();
     } else {
         // Generate the feed from the array
         $header = $builder->getHeader();
         $this->_element = new DOMDocument('1.0', $header['charset']);
         $root = $this->_mapFeedHeaders($header);
         $this->_mapFeedEntries($root, $builder->getEntries());
         $this->_element = $root;
         $this->_buildEntryCache();
     }
 }
Exemplo n.º 10
0
 public function feedAction()
 {
     $woeid = $this->_request->getParam('woeid');
     $ad_type = $this->_request->getParam('ad_type');
     $status = $this->_request->getParam('status');
     $modelAd = new Model_Ad();
     $this->ads = $modelAd->getAdList($woeid, $ad_type, $status, 35);
     $rss['title'] = $this->view->translate($ad_type) . ' ' . $this->view->translate((string) $status) . ' - ' . $this->_helper->woeid->name($woeid, $this->lang) . ' | nolotiro.org';
     $rss['link'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang . '/rss/feed/woeid/' . $woeid . '/ad_type/' . $ad_type . '/status/' . $status;
     $rss['charset'] = 'utf-8';
     $rss['description'] = 'nolotiro.org - ' . $this->_helper->woeid->name($woeid, $this->lang);
     $rss['language'] = $this->lang;
     $rss['generator'] = 'nolotiro.org';
     $rss['entries'] = array();
     foreach ($this->ads as $value) {
         $entry = array();
         $entry['title'] = $value['title'];
         $entry['link'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->lang . '/ad/' . $value['id'] . '/' . $this->view->slugTitle($value['title']);
         $entry['description'] = $this->view->escapeEmail($value['body']);
         $entry['lastUpdate'] = strtotime($value['date_created']);
         $rss['entries'][] = $entry;
     }
     $feedObj = Zend_Feed::importArray($rss, 'rss');
     return $feedObj->send();
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 public static function feed()
 {
     $ncsu = new Tweetgater_Twitter();
     $down = false;
     try {
         $timeline = $ncsu->getTimeline();
     } catch (Exception $e) {
         $down = true;
     }
     $config = $ncsu->getConfigFile();
     $fa = array();
     $fa['title'] = $config->feed->title;
     $fa['link'] = $config->site->url . '/feed.php';
     $fa['charset'] = 'UTF-8';
     $fa['author'] = $config->feed->title;
     $entries = array();
     if (!$down) {
         foreach ($timeline as $t) {
             $temp = array();
             $temp['title'] = 'Tweet by @' . $t['user-screen_name'];
             $temp['link'] = 'http://www.twitter.com/' . $t['user-screen_name'] . '/status/' . $t['id'];
             $temp['description'] = $t['text'] . '<br /><br />Follow @<a href="http://www.twitter.com/' . $t['user-screen_name'] . '">' . $t['user-screen_name'] . '</a>';
             $temp['lastUpdate'] = strtotime($t['created_at']);
             $entries[] = $temp;
         }
     }
     $fa['entries'] = $entries;
     // importing a rss feed from an array
     $rssFeed = Zend_Feed::importArray($fa, 'rss');
     // send http headers and dump the feed
     $rssFeed->send();
 }
 public function rssAction()
 {
     $this->_helper->layout->setLayout('rss');
     //Create an array for our feed
     $feed = array();
     //Setup some info about our feed
     $feed['title'] = "IllustratedPortland.com RSS Feed";
     $feed['link'] = 'feed://illustratedportland.com/blog/rss';
     $feed['charset'] = 'utf-8';
     $feed['language'] = 'en-us';
     //$feed['published'] = time();
     $feed['entries'] = array();
     //Holds the actual items
     foreach ($this->blog_model->getAll() as $story) {
         $entry = array();
         //Container for the entry before we add it on
         $entry['title'] = $story['title'];
         //The title that will be displayed for the entry
         $entry['guide'] = $story['id'];
         $entry['published'] = $story['date'];
         $entry['link'] = 'http://illustratedportland.com/blog/single/id/' . $story['id'];
         //The url of the entry
         $entry['url'] = 'http://illustratedportland.com/blog/single/id/' . $story['id'];
         //The url of the entry
         $entry['description'] = $story['description'];
         //Short description of the entry
         $entry['content'] = $story['content'];
         //Long description of the entry
         $feed['entries'][] = $entry;
     }
     $feedObj = Zend_Feed::importArray($feed, 'rss');
     $this->view->feed = $feedObj->send();
 }
Exemplo n.º 14
0
 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');
 }
Exemplo n.º 15
0
 public function rssAction()
 {
     // build the feed array
     $feedArray = array();
     // the title and link are required
     $feedArray['title'] = 'Recent Pages';
     $feedArray['link'] = 'http://localhost';
     // the published timestamp is optional
     $feedArray['published'] = Zend_Date::now()->toString(Zend_Date::TIMESTAMP);
     // the charset is required
     $feedArray['charset'] = 'UTF8';
     // first get the most recent pages
     $mdlPage = new Model_Page();
     $recentPages = $mdlPage->getRecentPages();
     //add the entries
     if (is_array($recentPages) && count($recentPages) > 0) {
         foreach ($recentPages as $page) {
             // create the entry
             $entry = array();
             $entry['guid'] = $page->id;
             $entry['title'] = $page->headline;
             $entry['link'] = 'http://localhost/page/open/title/' . $page->name;
             $entry['description'] = $page->description;
             $entry['content'] = $page->content;
             // add it to the feed
             $feedArray['entries'][] = $entry;
         }
     }
     // create an RSS feed from the array
     $feed = Zend_Feed::importArray($feedArray, 'rss');
     // now send the feed
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $feed->send();
 }
Exemplo n.º 16
0
 public function indexAction()
 {
     $format = $this->_request->getParam('format');
     if (in_array($format, array('georss', 'rss', 'atom'))) {
         $news = new News();
         $news = $news->getNews();
         // prepare an array that our feed is based on
         $feedArray = array('title' => 'Latest news from the Portable Antiquities Scheme', 'link' => Zend_Registry::get('siteurl') . '/news/', 'charset' => 'utf-8', 'description' => 'The latest news stories published by the Portable Antiquities Scheme', 'author' => 'The Portable Antiquities Scheme', 'image' => Zend_Registry::get('siteurl') . '/images/logos/pas.gif', 'email' => '*****@*****.**', 'copyright' => 'Creative Commons Licenced', 'generator' => 'The Scheme database powered by Zend Framework and Dan\'s magic', 'language' => 'en', 'entries' => array());
         foreach ($news as $new) {
             $auth = Zend_Auth::getInstance();
             //$latlong = $new['declat'] .' ' .$new['declong'];
             $feedArray['entries'][] = array('title' => $new['title'], 'link' => Zend_Registry::get('siteurl') . '/news/story/id/' . $new['id'], 'guid' => Zend_Registry::get('siteurl') . '/news/story/id/' . $new['id'], 'description' => $this->EllipsisString($new['contents'], 200), 'lastUpdate' => strtotime($new['datePublished']));
             /*if($object['i'] != NULL) {
             		$feedArray['enclosure'][] = array(array(
             		'url' => 'http://www.findsdatabase.org.uk/view/thumbnails/pas/'.$object['i'].'.jpg',
             		'type' => 'image/jpeg' //always sets to jpeg as the thumbnails are derived from there.
             		));
             		}*/
         }
         $feed = Zend_Feed::importArray($feedArray, $format);
         $feed->send();
     } else {
         $this->_redirect('/news/');
     }
 }
Exemplo n.º 17
0
 function recentlyAdded()
 {
     // redirect user if not logged in
     if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn() || $this->request->config->get('show_bristol_only') && !$this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form"));
     } elseif ($this->request->config->get('show_bristol_only') && $this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, "bristol", "Show", "Index"));
     }
     $t_object = new ca_objects();
     $va_recently_added_objects = $t_object->getRecentlyAddedItems(25, array('checkAccess' => caGetUserAccessValues($this->request)));
     $va_entries = array();
     $va_object_ids = array();
     foreach ($va_recently_added_objects as $va_object) {
         $va_object_ids[] = $va_object['object_id'];
     }
     $va_labels = $t_object->getPreferredDisplayLabelsForIDs($va_object_ids);
     // TODO: Need to get object descriptions and last update times properly
     foreach ($va_labels as $vn_object_id => $vs_label) {
         $va_entries[] = array('title' => $vs_label, 'link' => $vs_link = $this->request->config->get('site_host') . caNavUrl($this->request, '', 'Detail/Object', 'Index', array('object_id' => $vn_object_id)), 'guid' => $vs_link, 'lastUpdate' => time(), 'description' => '', 'pubDate' => time());
     }
     $va_feed_data = array('title' => _t('Recently added'), 'link' => $this->request->getRequestUrl(true), 'charset' => 'UTF-8', 'entries' => $va_entries);
     $o_feed = Zend_Feed::importArray($va_feed_data, 'rss');
     $this->view->setVar('feed', $o_feed);
     $this->render('Feed/feed_recently_added_xml.php');
 }
Exemplo n.º 18
0
 /**
  * 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;
 }
Exemplo n.º 19
0
 public function setUp()
 {
     if (!defined('TESTS_ZEND_FEED_IMPORT_ONLINE_BASEURI') || !constant('TESTS_ZEND_FEED_IMPORT_ONLINE_BASEURI')) {
         $this->markTestSkipped('ONLINE feed tests are not enabled');
     }
     $this->baseUri = rtrim(constant('TESTS_ZEND_FEED_IMPORT_ONLINE_BASEURI'), '/');
     Zend_Feed::setHttpClient(new Zend_Http_Client());
 }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 21
0
 public function createRssXml()
 {
     try {
         $rssFeedFromArray = Zend_Feed::importArray($this->getFeedArray(), 'rss');
         return $rssFeedFromArray->saveXML();
     } catch (Exception $e) {
         return Mage::helper('rss')->__('Error in processing xml. %s', $e->getMessage());
     }
 }
Exemplo n.º 22
0
 /**
  *
  */
 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');
 }
Exemplo n.º 23
0
 public function testUnset()
 {
     $feed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeed.xml');
     unset($feed['version']);
     $this->assertFalse(isset($feed['version']), 'Version should be unset');
     $this->assertEquals('', $feed['version'], 'Version should be equal to the empty string');
     $nsfeed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeedNamespaced.xml');
     unset($nsfeed['version']);
     $this->assertFalse(isset($nsfeed['version']), 'Version should be unset');
     $this->assertEquals('', $nsfeed['version'], 'Version should be equal to the empty string');
 }
Exemplo n.º 24
0
 public function testContentEncodedNullIfEmpty()
 {
     $feed = Zend_Feed::importFile(dirname(__FILE__) . '/../_files/TestFeedEntryRssContentEncoded.xml');
     $this->assertType('Zend_Feed_Rss', $feed);
     $feed->next();
     $item = $feed->current();
     $this->assertType('Zend_Feed_Entry_Rss', $item);
     $this->assertFalse(isset($item->content));
     $this->assertNull($item->content());
     // $this->assertNull($item->content); // always return DOMElement Object
 }
Exemplo n.º 25
0
 public function render(array $records)
 {
     $entries = array();
     foreach ($records as $record) {
         $entries[] = $this->itemToRss($record);
         release_object($record);
     }
     $headers = $this->buildRSSHeaders();
     $headers['entries'] = $entries;
     $feed = Zend_Feed::importArray($headers, 'rss');
     return $feed->saveXML();
 }
Exemplo n.º 26
0
 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;
 }
Exemplo n.º 27
0
 public function feedAction()
 {
     $entries = $this->trackerService->getEntries(array(), 1, 50);
     $feedArray = array('title' => 'Relapse Updates', 'link' => za()->getConfig('site_domain') . za()->getConfig('site_context'), 'description' => 'Latest relapse updates', 'language' => 'en-us', 'charset' => 'utf-8', 'pubDate' => date(DATE_RFC822), 'generator' => 'Zend Framework Zend_Feed', 'entries' => array());
     foreach ($entries as $entry) {
         // we want to handle issue history stuff differently otherwise we end up with oto
         // much crap in the feed
         $desc = $entry->entrydata;
         $feedArray['entries'][] = array('title' => $entry->actionname . ':' . $entry->actionid, 'link' => $entry->url, 'guid' => $entry->id, 'description' => $desc, 'lastUpdate' => strtotime($entry->created));
     }
     $feed = Zend_Feed::importArray($feedArray, 'rss');
     $feed->send();
 }
Exemplo n.º 28
0
 protected function _generateFeed($news)
 {
     $this->_helper->layout->disableLayout();
     $settings = Zend_Registry::get('environmentSettings');
     $mailSettings = Zend_Registry::get('emailSettings');
     foreach ($news as $post) {
         $entries[] = array('title' => $post->title, 'link' => 'http://' . $_SERVER['HTTP_HOST'] . $this->view->baseUrl() . '/news/' . $post->getUrlParams(), 'description' => $post->text, 'content' => $this->view->textile($post->text), 'lastUpdate' => strtotime($post->updated_at));
     }
     // generate and render RSS feed
     $feed = Zend_Feed::importArray(array('title' => $settings->page->group->name, 'link' => 'http://' . $_SERVER['HTTP_HOST'] . $this->view->baseUrl() . '/news/feed', 'charset' => 'UTF-8', 'entries' => $entries, 'author' => $settings->page->group->name, 'email' => $mailSettings->email->admin), 'atom');
     $feed->send();
     die;
 }
Exemplo n.º 29
0
 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;
 }
Exemplo n.º 30
0
 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();
         }
     }
 }