/** * * @param $streamEntries * @param $format * @return Zend_Feed_Abstract */ public function streamFeed($streamEntries, $format = 'atom') { $entries = array(); foreach ($streamEntries as $entry) { $updatedAt = $this->view->date($entry->updated_at); $entry = array('title' => $entry->title, 'link' => $this->view->appUrl() . $this->view->url(array('action' => 'show', 'id' => $entry->id, 'format' => null)), 'description' => $entry->title, 'guid' => $entry->id, 'lastUpdate' => $updatedAt->get(Zend_Date::TIMESTAMP), 'source' => array('title' => $entry->title, 'url' => $entry->url)); $entries[] = $entry; } //$entry = $this->entries->getItem(0); //$updatedAt = $this->date($entry->updated_at); //$createdAt = $this->date($entry->created_at); $data = array('title' => 'My Lifestream', 'link' => $this->view->appUrl(), 'charset' => 'utf-8', 'generator' => 'PHP Lifestream', 'language' => 'language the feed is written in', 'ttl' => '5', 'entries' => $entries); $feedBuilder = new Zend_Feed_Builder($data); return Zend_Feed::importBuilder($feedBuilder, $format); }
public function fetch() { if (!$this->loadFeeds()) { throw new Exception('Failed to load feeds'); } $mergedFeedEntries = new RssMergedEntryList(); foreach ($this->feeds as $feed) { foreach ($feed as $entry) { $toMergeEntry = new Zend_Feed_Builder_Entry($entry->title(), $entry->link(), $entry->description()); $toMergeEntry->setLastUpdate(strtotime($entry->pubDate())); $mergedFeedEntries->insert($toMergeEntry); } } $header = new Zend_Feed_Builder_Header($this->getTitle(), $this->getLink()); $rssBuilder = new RssFeedBuilder($header, iterator_to_array($mergedFeedEntries)); $mergedFeed = Zend_Feed::importBuilder($rssBuilder); return $mergedFeed->saveXml(); }
/** * The default action for the rss controller * Which shows the rss document */ public function indexAction() { $blog_mapper = new Application_Model_EntryMapper(); $blogs = $blog_mapper->findAll(10); //Create an array for our rss $feedData = array(); //Seting up the head information of the rss $feedData['title'] = $this->message_details['blog'] . ' - The Blog'; $feedData['link'] = $this->baseUrl(); $feedData['published'] = time(); //Set the published date to now $feedData['charset'] = 'utf-8'; $feedData['language'] = 'en'; $feedData['logo'] = $this->baseUrl() . '/images/logo.png'; $feedData['entries'] = array(); //Looping through the news to add them to the 'entries' array. foreach ($blogs as $blog) { $entry = array(); //Container for the entry before we add it on $entry['title'] = $blog->title; //The title of the news $entry['link'] = $this->baseUrl() . $this->view->EntryUrl($blog); $entry['description'] = $blog->description; //a brief of the news //$entry['content'] = $blog->content; //details of the news $entry['lastUpdate'] = $blog->published_date; $feedData['entries'][] = $entry; } // create our feed object and import the data $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($feedData), 'rss'); //disabling the layout and the rendering $this->getHelper('layout')->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); //printing the rss feed to standard output $feed->saveXML(); //sending the HTTP headers and output the rss feed $feed->send(); }
/** * Test the return of a link() call (atom) */ public function testAtomGetLink() { $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($this->_getFullArray()), 'atom'); $this->assertTrue($feed instanceof Zend_Feed_Atom); $feed = Zend_Feed::importString($feed->saveXML()); $this->assertTrue($feed instanceof Zend_Feed_Atom); $href = $feed->link('self'); $this->assertTrue($href == 'http://www.example.com'); }
/** * Test the return of a link() call (atom) */ public function testAtomGetLink() { $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($this->_getFullArray()), 'atom'); $this->assertType('Zend_Feed_Atom', $feed); $feed = Zend_Feed::importString($feed->saveXml()); $this->assertType('Zend_Feed_Atom', $feed); $href = $feed->link('self'); $this->assertEquals('http://www.example.com', $href); }
/** * rssAction * @author Daniel Rotter <*****@*****.**> * @version 1.0 */ public function rssAction() { header('Content-type: application/rss+xml'); $this->blnRenderMaster = false; require_once dirname(__FILE__) . '/../helpers/FeedBuilder.php'; $objFeed = Zend_Feed::importBuilder(new Blog_FeedBuilder(Zend_Registry::get('Widget')), 'rss'); $this->view->assign('text', $objFeed->saveXml()); }