public function addEntry($photo, $path, $enclosure, $content = "") { $entry = new Zend_Feed_Builder_Entry($photo->title, $this->_link . $path, $photo->description); $entry->setId($photo->id); $entry->setContent($content); $date = new Zend_Date($photo->created_on); $entry->setLastUpdate($date->get(Zend_Date::TIMESTAMP)); $entry->addEnclosure($this->_link . $enclosure, 'image/jpeg'); // TODO: Fix types $this->_entries[] = $entry; return $this; }
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(); }
/** * Create the array of article entries * * @param array $data * @throws Zend_Feed_Builder_Exception * @return void */ protected function _createEntries(array $data) { foreach ($data as $row) { $mandatories = array('title', 'link', 'description'); foreach ($mandatories as $mandatory) { if (!isset($row[$mandatory])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("{$mandatory} key is missing"); } } $entry = new Zend_Feed_Builder_Entry($row['title'], $row['link'], $row['description']); if (isset($row['author'])) { $entry->setAuthor($row['author']); } if (isset($row['guid'])) { $entry->setId($row['guid']); } if (isset($row['content'])) { $entry->setContent($row['content']); } if (isset($row['lastUpdate'])) { $entry->setLastUpdate($row['lastUpdate']); } if (isset($row['comments'])) { $entry->setCommentsUrl($row['comments']); } if (isset($row['commentRss'])) { $entry->setCommentsRssUrl($row['commentRss']); } if (isset($row['source'])) { $mandatories = array('title', 'url'); foreach ($mandatories as $mandatory) { if (!isset($row['source'][$mandatory])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("{$mandatory} key of source property is missing"); } } $entry->setSource($row['source']['title'], $row['source']['url']); } if (isset($row['category'])) { $entry->setCategories($row['category']); } if (isset($row['enclosure'])) { $entry->setEnclosures($row['enclosure']); } $this->_entries[] = $entry; } }
/** * getEntries * @author Daniel Rotter <*****@*****.**> * @version 1.0 */ public function getEntries() { $objBlogEntries = $this->getModelBlogEntries()->getBlogEntries($this->objWidget->getWidgetInstanceId(), false, $this->intCount, 0, null, $this->objWidget); $arrEntry = array(); foreach ($objBlogEntries as $objBlogEntry) { $feedUrl = $objBlogEntry->rooturl . '/' . $this->objWidget->getLanguageCode() . '/' . $objBlogEntry->url; $objEntry = new Zend_Feed_Builder_Entry($objBlogEntry->title, 'http://' . $feedUrl, $objBlogEntry->text); $objEntry->setLastUpdate($objBlogEntry->created_ts); $arrEntry[] = $objEntry; } return $arrEntry; }