/** * @return string * @throws Zend_Exception * @throws Zend_Feed_Exception * * @see XenForo_ViewPublic_Forum_View::renderRss */ public function renderRss() { if (is_callable(array('parent', 'renderRss'))) { return call_user_func(array('parent', 'renderRss')); } $tag = $this->_params['tag']; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); if (!empty($tag['tinhte_xentag_title'])) { $feed->setTitle($tag['tinhte_xentag_title']); } else { $feed->setTitle($tag['tag']); } if (!empty($tag['tinhte_xentag_description'])) { $feed->setDescription($tag['tinhte_xentag_description']); } else { $feed->setDescription(strval(new XenForo_Phrase('tinhte_xentag_all_contents_tagged_x', array('board_title' => XenForo_Application::get('options')->get('boardTitle'), 'tag_text' => $tag['tag'])))); } $feed->setLink(XenForo_Link::buildPublicLink('canonical:tags', $tag)); if (!$this->_Tinhte_XenTag_isBuggyXmlNamespace()) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:tags.rss', $tag), 'rss'); } $feed->setDateModified($tag['last_use_date']); $feed->setLastBuildDate(XenForo_Application::$time); if (XenForo_Application::get('options')->boardTitle) { $feed->setGenerator(XenForo_Application::get('options')->boardTitle); } foreach ($this->_params['results']['results'] as $result) { $entry = $this->_Tinhte_XenTag_prepareRssEntry($result, $feed); if ($entry !== false) { $feed->addEntry($entry); } } return $feed->export('rss'); }
/** * @param $data array * @param format string, either rss or atom */ protected function createFeed($data, $format = 'rss') { $feed = new \Zend_Feed_Writer_Feed(); $feed->setTitle($data['title']); $feed->setLink($data['link']); $feed->setFeedLink($data['link'], 'rss'); $feed->addAuthor(['name' => 'ZeroCMS', 'email' => 'email!']); $feed->setDateModified(time()); $feed->setDescription('RSS feed from query'); // Add one or more entries. Note that entries must be manually added once created. foreach ($data['documents'] as $document) { $entry = $feed->createEntry(); $entry->setTitle($document['title']); $entry->setLink($document['url']); $entry->addAuthor(['name' => $document['author']]); $entry->setDateModified($document['dateUpdated']->getTimestamp()); $entry->setDateCreated($document['dateCreated']->getTimestamp()); if (isset($document['summary'])) { $entry->setDescription($document['summary']); } $entry->setContent($document['body']); $feed->addEntry($entry); } return $feed->export($format); }
/** Display the index page of comments. * @todo this sucks * @access public * @return void */ public function indexAction() { $comments = $this->getComments()->getCommentsToFinds($this->getParam('page')); $context = $this->_helper->contextSwitch()->getCurrentContext(); if (in_array($context, array('rss', 'atom'))) { $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle('All published comments on finds records'); $feed->setLink($this->view->serverUrl()); $feed->setFeedLink($this->view->CurUrl(), $context); $feed->addAuthor(array('name' => 'The Portable Antiquities Scheme', 'email' => '*****@*****.**', 'uri' => $this->view->serverUrl())); $feed->setDateModified(time()); $feed->addHub('http://pubsubhubbub.appspot.com/'); $feed->setDescription('This feed contains all published comments on the Scheme\'s database'); /** * Add one or more entries. Note that entries must * be manually added once created. */ foreach ($comments as $comment) { $entry = $feed->createEntry(); $entry->setTitle('Comment entered on ' . $comment['old_findID']); $entry->setLink($this->view->serverUrl() . '/database/artefacts/record/id/' . $comment['id'] . '#comm'); $entry->addAuthor(array('name' => $comment['comment_author'], 'email' => null, 'uri' => $comment['comment_author_url'])); $entry->setDateModified(time()); $entry->setDateCreated(time()); $entry->setDescription('Comment regarding ' . $comment['old_findID']); $entry->setContent(strip_tags($comment['comment_content'])); $feed->addEntry($entry); } $out = $feed->export($context); echo $out; $this->getResponse()->setHeader('Content-type', $context . '+xml'); } else { $this->view->comments = $comments; } }
public function renderRss() { $forum = $this->_params['forum']; $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24'; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); $feed->setTitle($forum['title']); $feed->setDescription($forum['description'] ? $forum['description'] : $forum['title']); $feed->setLink(XenForo_Link::buildPublicLink('canonical:forums', $forum)); if (!$buggyXmlNamespace) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:forums.rss', $forum), 'rss'); } $feed->setDateModified(XenForo_Application::$time); $feed->setLastBuildDate(XenForo_Application::$time); if (XenForo_Application::get('options')->boardTitle) { $feed->setGenerator(XenForo_Application::get('options')->boardTitle); } foreach ($this->_params['threads'] as $thread) { // TODO: add contents of first post in future // TODO: wrap in exception handling down the line $entry = $feed->createEntry(); $entry->setTitle($thread['title']); $entry->setLink(XenForo_Link::buildPublicLink('canonical:threads', $thread)); $entry->setDateCreated(new Zend_Date($thread['post_date'], Zend_Date::TIMESTAMP)); $entry->setDateModified(new Zend_Date($thread['last_post_date'], Zend_Date::TIMESTAMP)); if (!$buggyXmlNamespace) { $entry->addAuthor(array('name' => $thread['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread))); if ($thread['reply_count']) { $entry->setCommentCount($thread['reply_count']); } } $feed->addEntry($entry); } return $feed->export('rss'); }
/** * Erstellt den Feed und gibt diesen zurück * @param string $format * @return DragonX_Homepage_Feed */ public function getFeed($format) { if (!in_array($format, array('rss', 'atom'))) { throw new Dragon_Application_Exception_User('incorrect format', array('format' => $format)); } $feed = new Zend_Feed_Writer_Feed(); $configApplication = new Dragon_Application_Config('dragon/application/application'); $feed->setTitle($configApplication->name); $feed->setDescription($configApplication->name . ' ' . $configApplication->version . ' ' . $configApplication->copyright); $feed->setLink(BASEURL); $feed->setFeedLink(BASEURL . 'feed.php?format=' . $format, $format); $configImprint = new Dragon_Application_Config('dragonx/homepage/imprint'); $feed->addAuthor(array('name' => $configImprint->webmaster, 'email' => $configImprint->mailingaddress, 'uri' => BASEURL)); $configNews = new Dragon_Application_Config('dragonx/homepage/news'); if (count($configNews->news) > 0) { $feed->setDateModified($configNews->news->{0}->timestamp); foreach ($configNews->news as $news) { $entry = $feed->createEntry(); $entry->setTitle($news->title); $entry->setLink(BASEURL); $entry->addAuthor(array('name' => $configImprint->webmaster, 'email' => $configImprint->mailingaddress, 'uri' => BASEURL)); $entry->setDateModified($news->timestamp); $entry->setDateCreated($news->timestamp); $entry->setDescription($news->content); $feed->addEntry($entry); } } else { $feed->setDateModified(0); } return $feed->export($format); }
protected function _generateFeedContainer() { $entries = Doctrine_Query::create()->from('Zfplanet_Model_Entry')->orderBy('publishedDate DESC')->limit(20)->execute(); $now = new Zend_Date(); $feed = new Zend_Feed_Writer_Feed(); // TODO: Extract site info to config file and detect feed DATA $feed->setTitle('ZF Planet'); $feed->setDescription('Zend Framework Blog Planet'); $feed->setDateModified($now); $feed->setLink($this->_getBaseUri()); $feed->setFeedLink($this->_getBaseUri() . 'feed/atom', 'atom'); $feed->setFeedLink($this->_getBaseUri() . 'feed/rss', 'rss'); $feed->addHubs(array('http://pubsubhubbub.appspot.com/')); foreach ($entries as $data) { $entry = $feed->createEntry(); $entry->setTitle($data->title); $entry->addAuthor(array('name' => $data->author)); if (!empty($data->description)) { $entry->setDescription($data->description); } $entry->setLink($data->uri); $entry->setContent($data->content); $publishedDate = new Zend_Date($data->publishedDate, Zend_Date::ISO_8601); $entry->setDateCreated($publishedDate); $updatedDate = new Zend_Date($data->updatedDate, Zend_Date::ISO_8601); $entry->setDateModified($updatedDate); $feed->addEntry($entry); $source = $entry->createSource(); $source->setTitle($data->Feed->FeedMeta->title); if (isset($data->Feed->FeedMeta->description) && !empty($data->Feed->FeedMeta->description)) { $source->setDescription($data->Feed->FeedMeta->description); } $source->setLink($data->Feed->FeedMeta->link); $source->setFeedLink($data->Feed->FeedMeta->feedLink, 'atom'); $updatedDate = new Zend_Date($data->Feed->lastSynchronised, Zend_Date::ISO_8601); $source->setDateModified($updatedDate); $entry->setSource($source); } return $feed; }
/** * Retrieve the items array * * @return array */ public function getFeedWriter() { $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($this->getTitle()); $feed->setLink($this->getLink()); $feed->setDescription($this->getDescription()); $feed->setFeedLink($this->getFeedLink(), 'atom'); $feed->setDateModified(time()); $feed->setLanguage($this->getLanguage()); $feed->setGenerator($this->getGenerator()); $this->_addEntriesToFeed($feed); return $feed; }
/** * Export the products by the Google Product Atom Export * @author Shine Software * @return xml */ public function googleproductsAction() { // Calling Google Product Extension Zend_Feed_Writer::addPrefixPath('Shineisp_Feed_Writer_Extension_', 'Shineisp/Feed/Writer/Extension/'); Zend_Feed_Writer::registerExtension('Google'); $isp = Shineisp_Registry::get('ISP'); $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($isp->company); $feed->setLink($isp->website); $feed->setFeedLink($isp->website . '/atom/products', 'atom'); $feed->addAuthor(array('name' => $isp->manager, 'email' => $isp->email, 'uri' => $isp->website)); $feed->setDateModified(time()); $feed->setGenerator("ShineISP Atom Extension"); $products = Products::getAllRss(); // print_r($products); // die; foreach ($products as $product) { // Get the google categories $categories = ProductsCategories::getGoogleCategories($product['categories']); $cattype = Products::get_text_categories($product['categories']); // Create the product entries $entry = $feed->createEntry(); $entry->setTitle($product['ProductsData'][0]['name']); $entry->setProductType(Products::get_text_categories($product['categories'])); $entry->setBrand($isp->company); $entry->setAvailability(true); $entry->setLink($isp->website . "/" . $product['uri'] . ".html"); // Custom Attributes Google Product Extension if (!empty($product['ProductsMedia'][0]['path'])) { $entry->setImageLink($isp->website . str_replace(" ", "%20", $product['ProductsMedia'][0]['path'])); } if (!empty($product['uri'])) { $entry->setProductId($product['uri']); } if (!empty($categories[0]['googlecategs'])) { $entry->setCategory($categories[0]['googlecategs']); } $price = Products::getPriceSuggested($product['product_id'], true); $entry->setPrice($price); $entry->setCondition('new'); $entry->setDateModified(time()); $entry->setDescription(strip_tags($product['ProductsData'][0]['shortdescription'])); $feed->addEntry($entry); } $feed = $feed->export('atom'); // Feed Fixing for google products $feed = $this->googlefixes($feed); Shineisp_Commons_Utilities::writefile($feed, "documents", "googleproducts.xml"); die($feed); }
public function renderRss() { $xenOptions = XenForo_Application::getOptions(); if ($xenOptions->sonnbXG_enableRSS) { $title = new XenForo_Phrase('sonnb_xengallery'); $title = $title->render(); $description = new XenForo_Phrase('sonnb_xengallery_short_description', array('title' => $xenOptions->boardTitle)); $description = $description->render(); $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24'; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); $feed->setTitle($title); $feed->setDescription($description); $feed->setLink(XenForo_Link::buildPublicLink('canonical:gallery')); if (!$buggyXmlNamespace) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:gallery/index.rss'), 'rss'); } $feed->setDateModified(XenForo_Application::$time); $feed->setLastBuildDate(XenForo_Application::$time); $feed->setGenerator($title); $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text', array('view' => $this)); $parser = new XenForo_BbCode_Parser($formatter); foreach ($this->_params['albums'] as $album) { $albumDescription = $parser->render($album['description']); $entry = $feed->createEntry(); if (!empty($album['contents'])) { $albumDescription .= '<br /><br />'; foreach ($album['contents'] as $content) { $albumDescription .= '<a href="' . XenForo_Link::buildPublicLink('canonical:gallery/' . $content['content_type'] . 's', $content) . '"><img src="' . XenForo_Link::convertUriToAbsoluteUri($content['thumbnailUrl'], true) . '" /></a>'; } } if ($albumDescription) { $entry->setDescription($albumDescription); } $entry->setTitle($album['title'] ? $album['title'] : $album['title'] . ' '); $entry->setLink(XenForo_Link::buildPublicLink('canonical:gallery/albums', $album)); $entry->setDateCreated(new Zend_Date($album['album_date'], Zend_Date::TIMESTAMP)); $entry->setDateModified(new Zend_Date($album['album_updated_date'], Zend_Date::TIMESTAMP)); if (!$buggyXmlNamespace) { $entry->addAuthor(array('name' => $album['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:gallery/authors', $album))); if ($album['comment_count']) { $entry->setCommentCount($album['comment_count']); $entry->setCommentLink(XenForo_Link::buildPublicLink('canonical:gallery/albums', $album) . '#album-' . $album['album_id']); } } $feed->addEntry($entry); } return $feed->export('rss'); } }
public function renderRss() { $options = XenForo_Application::get('options'); $title = $options->boardTitle ? $options->boardTitle : XenForo_Link::buildPublicLink('canonical:index'); $description = $options->boardDescription ? $options->boardDescription : $title; $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24'; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); $feed->setTitle($title); $feed->setDescription($description); $feed->setLink(XenForo_Link::buildPublicLink('canonical:index')); if (!$buggyXmlNamespace) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:forums/-/index.rss'), 'rss'); } $feed->setDateModified(XenForo_Application::$time); $feed->setLastBuildDate(XenForo_Application::$time); $feed->setGenerator($title); $bbCodeSnippetParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_Clean', false)); $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this))); $rendererStates = array('disableProxying' => true); foreach ($this->_params['threads'] as $thread) { $entry = $feed->createEntry(); $entry->setTitle($thread['title'] ? $thread['title'] : $thread['title'] . ' '); $entry->setLink(XenForo_Link::buildPublicLink('canonical:threads', $thread)); $entry->setDateCreated(new Zend_Date($thread['post_date'], Zend_Date::TIMESTAMP)); $entry->setDateModified(new Zend_Date($thread['last_post_date'], Zend_Date::TIMESTAMP)); if (!empty($thread['canViewContent']) && !empty($thread['message']) && XenForo_Application::getOptions()->discussionRssContentLength) { $snippet = $bbCodeSnippetParser->render(XenForo_Helper_String::wholeWordTrim($thread['message'], XenForo_Application::getOptions()->discussionRssContentLength), $rendererStates); if ($snippet != $thread['message']) { $snippet .= "\n\n[url='" . XenForo_Link::buildPublicLink('canonical:threads', $thread) . "']" . $thread['title'] . '[/url]'; } $content = trim($bbCodeParser->render($snippet, $rendererStates)); if (strlen($content)) { $entry->setContent($content); } } if (!$buggyXmlNamespace) { $entry->addAuthor(array('name' => $thread['username'], 'email' => '*****@*****.**', 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread))); if ($thread['reply_count']) { $entry->setCommentCount($thread['reply_count']); } } $feed->addEntry($entry); } return $feed->export('rss'); }
/** * Create a RSS file with the CMS pages and Products */ public function indexAction() { $out = ""; try { $ISP = Shineisp_Registry::get('ISP'); $ns = new Zend_Session_Namespace(); $localeID = $ns->idlang; $locale = $ns->lang; $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($ISP->company); $feed->setLink($ISP->website); $feed->setFeedLink('http://' . $_SERVER['HTTP_HOST'] . '/rss', 'atom'); $feed->addAuthor(array('name' => $ISP->company, 'email' => $ISP->email, 'uri' => $ISP->website)); $feed->setEncoding('UTF8'); $feed->setDateModified(time()); $feed->addHub($ISP->website); // Get all the cms pages $records = CmsPages::getRssPages($locale); foreach ($records as $record) { $link = 'http://' . $_SERVER['HTTP_HOST'] . '/cms/' . $record['var'] . '.html'; self::createEntry($feed, $record['title'], $record['body'], $link); } // Get all the products $records = Products::getAllHighlighted($localeID); foreach ($records as $record) { $title = $record['ProductsData'][0]['name']; $descritption = strip_tags($record['ProductsData'][0]['shortdescription']); $inserted_at = !empty($record['inserted_at']) ? strtotime($record['inserted_at']) : null; $updated_at = !empty($record['updated_at']) ? strtotime($record['updated_at']) : null; $link = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $record['uri'] . '.html'; self::createEntry($feed, $title, $descritption, $link, $inserted_at, $updated_at); } /** * Render the resulting feed to Atom 1.0 and assign to $out. * You can substitute "atom" with "rss" to generate an RSS 2.0 feed. */ $out = $feed->export('atom'); } catch (Zend_Feed_Exception $e) { die($e->getMessage()); } die($out); }
public function renderRss() { // below lines of code are copied from XenForo_ViewPublic_Forum_View::renderRss $tag = $this->_params['tag']; $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24'; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); $feed->setTitle($tag['tag_text']); $feed->setDescription('' . new XenForo_Phrase('tinhte_xentag_all_contents_tagged_x', array('board_title' => XenForo_Application::get('options')->get('boardTitle'), 'tag_text' => $tag['tag_text']))); $feed->setLink(XenForo_Link::buildPublicLink('canonical:tags', $tag)); if (!$buggyXmlNamespace) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:tags.rss', $tag), 'rss'); } $feed->setDateModified(XenForo_Application::$time); $feed->setLastBuildDate(XenForo_Application::$time); if (XenForo_Application::get('options')->boardTitle) { $feed->setGenerator(XenForo_Application::get('options')->boardTitle); } foreach ($this->_params['results']['results'] as $result) { if ($result[XenForo_Model_Search::CONTENT_TYPE] == 'thread') { $thread = $result['content']; $entry = $feed->createEntry(); $entry->setTitle($thread['title']); $entry->setLink(XenForo_Link::buildPublicLink('canonical:threads', $thread)); $entry->setDateCreated(new Zend_Date($thread['post_date'], Zend_Date::TIMESTAMP)); $entry->setDateModified(new Zend_Date($thread['last_post_date'], Zend_Date::TIMESTAMP)); if (!$buggyXmlNamespace) { $entry->addAuthor(array('name' => $thread['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread))); if ($thread['reply_count']) { $entry->setCommentCount($thread['reply_count']); } } } else { $entry = $this->_prepareRssEntry($result, $feed); } if ($entry !== false) { $feed->addEntry($entry); } } return $feed->export('rss'); }
public function renderRss() { $options = XenForo_Application::getOptions(); $title = new XenForo_Phrase('xengallery_media'); $description = new XenForo_Phrase('xengallery_check_out_all_media_from_x', array('board' => $options->boardTitle)); $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24'; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); $feed->setTitle($title->render()); $feed->setDescription($description->render()); $feed->setLink(XenForo_Link::buildPublicLink('canonical:xengallery')); if (!$buggyXmlNamespace) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:xengallery.rss'), 'rss'); } $feed->setDateModified(XenForo_Application::$time); $feed->setLastBuildDate(XenForo_Application::$time); $feed->setGenerator($title->render()); $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this))); foreach ($this->_params['media'] as $media) { $entry = $feed->createEntry(); $entry->setTitle($media['media_title'] ? $media['media_title'] : $media['media_title'] . ' '); $entry->setLink(XenForo_Link::buildPublicLink('canonical:xengallery', $media)); $entry->setDateCreated(new Zend_Date($media['media_date'], Zend_Date::TIMESTAMP)); $entry->setDateModified(new Zend_Date($media['last_edit_date'], Zend_Date::TIMESTAMP)); if (!empty($media['media_description'])) { $entry->setDescription($media['media_description']); } XenGallery_ViewPublic_Helper_VideoHtml::addVideoHtml($media, $bbCodeParser); $content = $this->_renderer->createTemplateObject('xengallery_rss_content', array('media' => $media)); $entry->setContent($content->render()); if (!$buggyXmlNamespace) { $entry->addAuthor(array('name' => $media['username'], 'email' => '*****@*****.**', 'uri' => XenForo_Link::buildPublicLink('canonical:xengallery/users', $media))); if ($media['comment_count']) { $entry->setCommentCount($media['comment_count']); } } $feed->addEntry($entry); } return $feed->export('rss'); }
public function feedAction() { $model = $this->_owApp->selectedModel; $resource = $this->_owApp->selectedResource; $limit = 20; $rUri = (string) $resource; $rUriEncoded = urlencode($rUri); $mUri = (string) $model; $mUriEncoded = urlencode($mUri); $translate = $this->_owApp->translate; $store = $this->_erfurt->getStore(); $ac = $this->_erfurt->getAc(); $params = $this->_request->getParams(); if (!$model || !$resource) { throw new Ontowiki_Exception('need parameters m and r'); } $versioning = $this->_erfurt->getVersioning(); $versioning->setLimit($limit); if (!$versioning->isVersioningEnabled()) { throw new Ontowiki_Exception('versioning disabled in config'); } $title = $resource->getTitle(); if (null == $title) { $title = OntoWiki_Utils::contractNamespace($resource->getIri()); } $feedTitle = sprintf($translate->_('Versions for %1$s'), $title); $historyArray = $versioning->getHistoryForResource((string) $resource, (string) $model, 1); $idArray = array(); $userArray = $this->_erfurt->getUsers(); $titleHelper = new OntoWiki_Model_TitleHelper(); // Load IDs for rollback and Username Labels for view foreach ($historyArray as $key => $entry) { $idArray[] = (int) $entry['id']; // if(!$singleResource){ // $historyArray[$key]['url'] = $this->_config->urlBase . "view?r=" . urlencode($entry['resource']); // $titleHelper->addResource($entry['resource']); // } if ($entry['useruri'] == $this->_erfurt->getConfig()->ac->user->anonymousUser) { $userArray[$entry['useruri']] = 'Anonymous'; } elseif ($entry['useruri'] == $this->_erfurt->getConfig()->ac->user->superAdmin) { $userArray[$entry['useruri']] = 'SuperAdmin'; } elseif (is_array($userArray[$entry['useruri']]) && array_key_exists('userName', $userArray[$entry['useruri']])) { $userArray[$entry['useruri']] = $userArray[$entry['useruri']]['userName']; } } $linkUrl = $this->_config->urlBase . "history/list?r={$rUriEncoded}&mUriEncoded"; $feedUrl = $this->_config->urlBase . "history/feed?r={$rUriEncoded}&mUriEncoded"; $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($feedTitle); $feed->setLink($linkUrl); $feed->setFeedLink($feedUrl, 'atom'); //$feed->addHub("http://pubsubhubbub.appspot.com/"); $feed->addAuthor(array('name' => 'OntoWiki', 'uri' => $feedUrl)); $feed->setDateModified(time()); foreach ($historyArray as $historyItem) { $title = $translate->_('HISTORY_ACTIONTYPE_' . $historyItem['action_type']); $entry = $feed->createEntry(); $entry->setTitle($title); $entry->setLink($this->_config->urlBase . 'view?r=' . $rUriEncoded . "&id=" . $historyItem['id']); $entry->addAuthor(array('name' => $userArray[$historyItem['useruri']], 'uri' => $historyItem['useruri'])); $entry->setDateModified($historyItem['tstamp']); $entry->setDateCreated($historyItem['tstamp']); $entry->setDescription($title); $content = ''; $result = $this->getActionTriple($historyItem['id']); $content .= json_encode($result); $entry->setContent(htmlentities($content)); $feed->addEntry($entry); } $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $this->getResponse()->setHeader('Content-Type', 'application/atom+xml'); $out = $feed->export('atom'); $pattern = '/updated>\\n(.+?)link rel="alternate"/'; $replace = "updated>\n\$1link"; $out = preg_replace($pattern, $replace, $out); echo $out; return; // Do we need this stuff below? // ---------------------------- /* $this->view->userArray = $userArray; $this->view->idArray = $idArray; $this->view->historyArray = $historyArray; $this->view->singleResource = $singleResource; $this->view->titleHelper = $titleHelper; if (empty($historyArray)) { $this->_owApp->appendMessage( new OntoWiki_Message( 'No matches.', OntoWiki_Message::INFO ) ); } if ($this->_erfurt->getAc()->isActionAllowed('Rollback')) { $this->view->rollbackAllowed = true; // adding submit button for rollback-action $toolbar = $this->_owApp->toolbar; $toolbar->appendButton( OntoWiki_Toolbar::SUBMIT, array('name' => $translate->_('Rollback changes'), 'id' => 'history-rollback') ); $this->view->placeholder('main.window.toolbar')->set($toolbar); } else { $this->view->rollbackAllowed = false; } // paging $statusBar = $this->view->placeholder('main.window.statusbar'); // the normal page_param p collides with the generic-list param p OntoWiki_Pager::setOptions(array('page_param'=>'page')); $statusBar->append(OntoWiki_Pager::get($count,$limit)); // setting view variables $url = new OntoWiki_Url(array('controller' => 'history', 'action' => 'rollback')); $this->view->placeholder('main.window.title')->set($windowTitle); $this->view->formActionUrl = (string) $url; $this->view->formMethod = 'post'; // $this->view->formName = 'instancelist'; $this->view->formName = 'history-rollback'; $this->view->formEncoding = 'multipart/form-data'; */ }
/** * Post forum rss * * @todo should return comments of topic * @throws Zend_Controller_Action_Exception */ public function postAction() { if (!($postId = $this->_getParam('id'))) { throw new Zend_Controller_Action_Exception('Topic not found'); } $posts = new Forum_Model_Post_Table(); if (!($row = $posts->getByid($postId))) { throw new Zend_Controller_Action_Exception('Topic not found'); } $url = $this->_helper->url; $serverUrl = $this->_request->getScheme() . '://' . $this->_request->getHttpHost(); $title = $row->title . " // Comments RSS Feed"; $link = $url->url(array('id' => $row->id), 'forumpost'); $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($title); $feed->setLink($serverUrl . $link); $feed->setDescription($row->getTeaser()); $feed->setFeedLink($serverUrl . $url->url(array('module' => 'forum')), 'atom'); $feed->addAuthor(array('name' => 'Forum Owner Name', 'email' => null, 'uri' => $serverUrl)); $feed->setDateModified(time()); echo $feed->export('atom'); }
public function run() { $this->view = null; $config = Zend_Registry::get('config'); // This does not make a db connection. Must be done later using $db->getConnection(); Zend_Registry::set('db', Zend_Db::factory($config->database)); $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'rss'; $job_id = isset($_REQUEST['job_id']) ? $_REQUEST['job_id'] : false; if (!($format == 'atom' || $format == 'rss')) { $format = 'rss'; } $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : 'completed'; // Connect to db try { $db = Zend_Registry::get('db'); $db->getConnection(); } catch (Zend_Db_Adapter_Exception $e) { // failed login, db not running } catch (Zend_Exception $e) { // factory() failed load of mysqli } switch ($name) { case 'priority': $name = 'priority'; $title = 'Worklist Top Priority Bidding Jobs'; $projects = isset($_REQUEST['projects']) ? preg_split('/,/', $_REQUEST['projects']) : array(); $description = 'Worklist, highest priority jobs Bidding'; $entryDescription = 'Worklist priority item'; $cond = "w.status = 'Bidding' AND w.is_internal = 0"; $limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit'] : 20; if (!empty($projects)) { $projectList = ''; foreach ($projects as $project) { $projectList .= (strlen($projectList) > 0 ? ',' : '') . "'" . addslashes($project) . "'"; } $cond .= ' AND p.name IN (' . $projectList . ')'; } $query = "\n SELECT\n w.id as worklist_id, \n u1.nickname as author, \n username as email, \n summary as title, \n notes as content\n FROM " . WORKLIST . " w\n JOIN " . USERS . " u1 ON u1.id = w.creator_id\n JOIN " . PROJECTS . " p ON p.project_id = w.project_id \n WHERE " . $cond . "\n ORDER BY priority \n LIMIT " . $limit; break; case 'comments': $name = 'comments'; if (isset($job_id) && $job_id) { $where = "WHERE worklist_id IN\n (SELECT id FROM " . WORKLIST . " WHERE is_internal = 0 AND id = " . $job_id . ")"; $title = 'Worklist - Comments for Job #' . $job_id; $description = 'Worklist, latest Comments for Job #' . $job_id; $entryDescription = 'Worklist latest Comments for Job #' . $job_id; } else { $where = ""; $title = 'Worklist Latest Comments'; $description = 'Worklist, latest comments'; $entryDescription = 'Worklist latest comments'; } $query = "\n SELECT \n c.id AS comment_id, \n c.worklist_id AS worklist_id,\n c.date AS timestamp,\n c.comment AS summary,\n c.comment AS content,\n u.nickname as author, \n u.username as email\n FROM " . COMMENTS . " c\n JOIN " . USERS . " u on u.id = c.user_id\n " . $where . "\n ORDER BY timestamp DESC LIMIT 20"; break; case 'completed': default: $name = 'completed'; $title = 'Worklist most Recent completed jobs'; $description = 'Worklist, Most recent completed Jobs'; $entryDescription = 'Worklist priority item'; $query = "SELECT w.id as worklist_id, u1.nickname as author, username as email, summary as title, notes as content\n FROM " . WORKLIST . " w\n JOIN " . USERS . " u1 ON u1.id = w.creator_id AND w.status = 'Done' AND w.is_internal = 0\n ORDER BY created DESC LIMIT 20"; } $url = WORKLIST_URL; $link = $url . "feed?name={$name}&format={$format}"; $writer = new Zend_Feed_Writer_Feed(); $writer->setTitle($title); $writer->setLink(WORKLIST_URL); $writer->setFeedLink($link, $format); $writer->setDescription($description); $writer->setDateModified(time()); //Atom needs this $this->loadFeed($writer, $query, $entryDescription); echo $writer->export($format); }
public function feedAction() { $data = $this->_request->getParams(); $this->prefix = "Default_"; $config = $this->config; $this->setupCache('default'); //$this->totpl('theInclude','list'); if ($data['lib']) { $feedtype = $data['type']; if (!($out = $this->loadCache('feed_' . $data['lib'] . "_" . $feedtype))) { //we have a lib... now get the content for this lib $type = $this->getContentTypeByLib($data['lib']); //some admins think it is a good thing to add more than one content type for each lib ;S if ($type['title']) { $content = $this->getRecent($type['title'], 10); } else { foreach ($type as $o => $s) { $content[] = $this->getRecent($s['title'], 5); } } //get recent items if (count($content) > 0) { $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($config->site->frontend_title . " " . $data['lib'] . " feed"); $feed->setLink($this->http_location); $feed->setCopyright($this->t($config->site->feed_copyright)); $feed->setGenerator($config->site->feed_generator); $feed->setFeedLink($this->http_location . "/" . $data['lib'], 'atom'); $feed->setFeedLink($this->http_location . "/" . $data['lib'] . "?type=rss", 'rss'); $feed->addAuthor(array('name' => $config->site->feed_author_name, 'email' => $config->site->feed_author_email, 'uri' => $this->http_location)); $feed->setImage(array('uri' => $config->site->feed_logo_image)); $feed->setDateModified(time()); $feed->addHub('http://pubsubhubbub.appspot.com/'); //now we need to loop foreach ($content as $k => $v) { if ($v['title']) { $entry = $feed->createEntry(); $entry->setTitle($v['title']); $entry->setLink($this->http_location . "/" . $data['lib'] . "/" . $v['slug']); $entry->setDateCreated($v['datestr']); $entry->setDateModified(time()); if ($v['content']) { $entry->setDescription(strip_tags(stripslashes(substr($v['content'], 0, 160)))); } $feed->addEntry($entry); } else { foreach ($v as $r) { $entry = $feed->createEntry(); $entry->setTitle($r['title']); $entry->setLink($this->http_location . "/" . $data['lib'] . "/" . $r['slug']); $entry->setDateCreated($r['datestr']); $entry->setDateModified(time()); if ($r['content']) { $entry->setDescription(strip_tags(stripslashes(substr($r['content'], 0, 160)))); } $feed->addEntry($entry); } } } $out = $feed->export($feedtype); } $this->cacheData($out, 'feed_' . $data['lib'] . "_" . $feedtype); } header("Content-type: text/xml"); echo $out; die; } }
public function testSetsFeedLinkThrowsExceptionOnInvalidUri() { $writer = new Zend_Feed_Writer_Feed(); try { $writer->setFeedLink('http://', 'rss'); $this->fail(); } catch (Zend_Feed_Exception $e) { } }
/** * Generate a feed (ATOM 1.0 or RSS 2.0 using Zend_Feed_Writer_Feed * * @param string $section Tiki feature the feed is related to * @param string $uniqueid * @param string $feed_version DEPRECATED * @param array $changes the content that will be used to generate the feed * @param string $itemurl base url for items (e.g. "tiki-view_blog_post.php?postId=%s") * @param string $urlparam * @param string $id name of the id field used to identify each feed item (e.g. "postId") * @param string $title title for the feed * @param string $titleId name of the key in the $changes array with the title of each item * @param string $desc description for the feed * @param string $descId name of the key in the $changes array with the description of each item * @param string $dateId name of the key in the $changes array with the date of each item * @param string $authorId name of the key in the $changes array with the author of each item * @param bool $fromcache if true recover the feed from cache * * @return array the generated feed */ function generate_feed($section, $uniqueid, $feed_version, $changes, $itemurl, $urlparam, $id, $title, $titleId, $desc, $descId, $dateId, $authorId, $fromcache = false) { global $tikilib, $tiki_p_admin, $prefs, $userlib, $prefs, $smarty; // both title and description fields cannot be null if (empty($title) || empty($desc)) { $msg = tra('The fields title and description are mandatory to generate a feed.'); if ($tiki_p_admin) { $msg .= ' ' . tra('To fix this error go to Admin -> Feeds.'); } else { $msg .= ' ' . tra('Please contact the site administrator and ask him to fix this error'); } $smarty->assign('msg', $msg); $smarty->display('error.tpl'); die; } $feed_format = $this->get_current_feed_format(); $feed_format_name = $this->get_current_feed_format_name(); if ($prefs['feed_cache_time'] < 1) { $fromcache = false; } // only get cache data if rss cache is enabled if ($fromcache) { $output = $this->get_from_cache($uniqueid, $feed_format); if ($output['data'] != 'EMPTY') { return $output; } } $urlarray = parse_url($_SERVER["REQUEST_URI"]); $rawPath = str_replace('\\', '/', dirname($urlarray["path"])); $URLPrefix = $tikilib->httpPrefix() . $rawPath; if ($rawPath != "/") { $URLPrefix .= "/"; // Append a slash unless Tiki is in the document root. dirname() removes a slash except in that case. } if (isset($prefs['feed_' . $section . '_index']) && $prefs['feed_' . $section . '_index'] != '') { $feedLink = $prefs['feed_' . $section . '_index']; } else { $feedLink = htmlspecialchars($tikilib->httpPrefix() . $_SERVER["REQUEST_URI"]); } $img = htmlspecialchars($URLPrefix . $prefs['feed_img']); $title = htmlspecialchars($title); $desc = htmlspecialchars($desc); $read = $URLPrefix . $itemurl; $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($title); $feed->setDescription($desc); if (!empty($prefs['feed_language'])) { $feed->setLanguage($prefs['feed_language']); } $feed->setLink($tikilib->tikiUrl('')); $feed->setFeedLink($feedLink, $feed_format_name); $feed->setDateModified($tikilib->now); if ($feed_format_name == 'atom') { $author = array(); if (!empty($prefs['feed_atom_author_name'])) { $author['name'] = $prefs['feed_atom_author_name']; } if (!empty($prefs['feed_atom_author_email'])) { $author['email'] = $prefs['feed_atom_author_email']; } if (!empty($prefs['feed_atom_author_url'])) { $author['url'] = $prefs['feed_atom_author_url']; } if (!empty($author)) { if (empty($author['name'])) { $msg = tra('If you set feed author email or URL, you must set feed author name.'); $smarty->assign('msg', $msg); $smarty->display('error.tpl'); die; } $feed->addAuthor($author); } } else { $authors = array(); if (!empty($prefs['feed_rss_editor_email'])) { $authors['name'] = $prefs['feed_rss_editor_email']; } if (!empty($prefs['feed_rss_webmaster_email'])) { $authors['name'] = $prefs['feed_rss_webmaster_email']; } if (!empty($authors)) { $feed->addAuthors($authors); } } if (!empty($prefs['feed_img'])) { $image = array(); $image['uri'] = $tikilib->tikiUrl($prefs['feed_img']); $image['title'] = tra('Feed logo'); $image['link'] = $tikilib->tikiUrl(''); $feed->setImage($image); } foreach ($changes["data"] as $data) { $item = $feed->createEntry(); $item->setTitle($data[$titleId]); if (isset($data['sefurl'])) { $item->setLink($URLPrefix . $data['sefurl']); } elseif ($urlparam != '') { // 2 parameters to replace $item->setlink(sprintf($read, urlencode($data["{$id}"]), urlencode($data["{$urlparam}"]))); } else { $item->setLink(sprintf($read, urlencode($data["{$id}"]))); } if (isset($data[$descId]) && $data[$descId] != '') { $item->setDescription($data[$descId]); } $item->setDateCreated($data[$dateId]); $item->setDateModified($data[$dateId]); if ($authorId != '' && $prefs['feed_' . $section . '_showAuthor'] == 'y') { $author = $this->process_item_author($data[$authorId]); $item->addAuthor($author); } $feed->addEntry($item); } $data = $feed->export($feed_format_name); $this->put_to_cache($uniqueid, $feed_format, $data); $output = array(); $output["data"] = $data; $output["content-type"] = 'application/xml'; return $output; }
/** * Author's blog rss * * @throws Zend_Controller_Action_Exception */ public function authorAction() { $limit = 10; if (!($login = $this->_getParam('login'))) { throw new Zend_Controller_Action_Exception('Page not found'); } $users = new Users_Model_User_Table(); if (!($user = $users->getByLogin($login))) { throw new Zend_Controller_Action_Exception('Page not found'); } $url = $this->_helper->url; $serverUrl = $this->_request->getScheme() . '://' . $this->_request->getHttpHost(); $title = ucfirst($user->login) . "'s Blog Rss Feed"; $link = $url->url(array('login' => $user->login), 'blogauthor'); $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($title); $feed->setLink($serverUrl . $link); $feed->setFeedLink('http://www.example.com/atom', 'atom'); $feed->addAuthor(array('name' => 'Blog Owner Name', 'email' => $user->email, 'uri' => $serverUrl)); $posts = new Blog_Model_Post_Table(); $select = $posts->getSelect(null, $user->id); $feed->setDateModified(time()); foreach ($posts->fetchAll($select->limit($limit)) as $i => $row) { if (0 == $i) { $feed->setDateModified(strtotime($row->updated)); } $postUrl = $url->url(array('alias' => $row->alias), 'blogpost'); $entry = $feed->createEntry(); $entry->setTitle($row->title); $entry->setLink($serverUrl . $postUrl); $entry->addAuthor($row->login, null, null); $entry->setDateModified(strtotime($row->updated)); $entry->setDateCreated(strtotime($row->published)); $entry->setDescription($row->teaser); $feed->addEntry($entry); } echo $feed->export('atom'); }
/** * Create an RSS feed. */ public function rssAction() { $documents = $this->getPages($this->path, $this->limit, $this->offset); $description = $this->description; $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($this->defaultTitle); if (empty($this->description)) { $description = $this->defaultTitle; } $feed->setDescription($description); $feed->setLink($this->baseUrl . '/'); $feed->setFeedLink($this->baseUrl . $_SERVER['REQUEST_URI'], 'rss'); $feed->setId($this->baseUrl); $feed->addAuthor($this->author); $modDate = 0; foreach ($documents as $document) { if ($document->hasProperty('showInFeed') && !$document->getProperty('showInFeed')) { continue; } if ($document->getModificationDate() > $modDate) { $modDate = $document->getModificationDate(); } $content = trim(str_replace(' ', ' ', $document->elements[$this->documentBody]->text)); $descr = $document->getDescription(); $title = $document->title; if (empty($title)) { $title = $this->defaultTitle; } $entry = $feed->createEntry(); $entry->setTitle($title); $entry->setLink($this->baseUrl . $document->getFullPath()); $entry->setDateModified($document->getModificationDate()); $entry->setDateCreated($document->getCreationDate()); if (!empty($descr)) { $entry->setDescription($descr); } if (!empty($content)) { $entry->setContent($content); } $feed->addEntry($entry); } $feed->setDateModified($modDate); $this->getResponse()->setHeader('Content-Type', 'application/rss+xml; charset=utf-8'); echo $feed->export('rss'); exit; }
}); /** * RSS feed */ $app->get('/feed', function () use($app) { $request = $app['request']; $fuckups = ft_find_fuckups($app); require_once 'Zend/Feed/Writer/Feed.php'; $firstFuckup = current($fuckups); $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle('In FUCKTOWN'); $feed->setDescription('Holy shit dude! A website to anonymously post other ' . 'people's fuckups!'); $feed->setDateModified(strtotime($firstFuckup['date_created'])); $host = 'http://' . $request->getHost(); $feed->setLink($host); $feed->setFeedLink($host . '/feed', 'rss'); foreach ($fuckups as $fuckup) { $content = sprintf('%s %s in FUCKTOWN because %s', $fuckup['who'], $fuckup['verb'], $fuckup['fuckup']); $entry = $feed->createEntry(); $entry->setTitle(sprintf('%s is in FUCKTOWN', $fuckup['who'])); $entry->addAuthor('InFucktown'); $entry->setContent($content); $entry->setDateCreated(strtotime($fuckup['date_created'])); $entry->setLink('http://infucktown.com/fuckup/' . $fuckup['fuckup_id']); $feed->addEntry($entry); } $markup = $feed->export('rss'); return new Response($markup); }); /** * Homepage
public function rssAction() { $this->populateView(); // Basic information $url = $this->_request->getScheme() . "://" . $this->getRequest()->getHttpHost() . $this->getRequest()->getRequestUri(); $author = array('name' => 'GoDeploy RSS Generator', 'email' => '*****@*****.**', 'uri' => $url); // Disable Zend view rendering and set content type $this->_response->setHeader('Content-type', 'text/xml'); $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); // RSS/Atom header $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle('GoDeploy deployment history'); $feed->setDescription('GoDeploy deployment history'); $feed->setLink($url); $feed->setFeedLink($url, 'rss'); $feed->addAuthor($author); $feed->setDateModified(time()); if (is_array($this->view->deployments) && count($this->view->deployments) > 0) { foreach ($this->view->deployments as $deployment) { $content = "Deployed on: " . $deployment->getWhen("d/m/Y H:i:s") . "<br />"; $content .= "To Server: " . $deployment->getServer()->getDisplayName() . "<br />"; $content .= "From: " . substr($deployment->getFromRevision(), 0, 7) . "<br />"; $content .= "To: " . substr($deployment->getToRevision(), 0, 7) . "<br />"; $content .= "Comment: " . $deployment->getComment() . "<br />"; $content .= "Status: " . $deployment->getDeploymentStatus()->getShortName() . "<br />"; $entry = $feed->createEntry(); $entry->setTitle("Deployment " . $deployment->getWhen("d/m/Y H:i:s")); $entry->setLink(str_replace("/history/rss", "/deploy/result/" . $deployment->getId(), $url)); $entry->addAuthor($author); $entry->setDateModified(time()); $entry->setDateCreated(new Zend_Date($deployment->getWhen("Y-m-d H:i:s"), Zend_Date::ISO_8601)); $entry->setDescription('GoDeploy deployment ' . $deployment->getId()); $entry->setContent($content); $feed->addEntry($entry); } } echo $feed->export('rss'); }
/** * RSS feed action */ public function feedAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); /** * Create the parent feed */ $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($this->_application->get_name()); $feed->setLink($this->view->serverUrl()); $feed->setDescription($this->_application->get_name()); $feed->setFeedLink($this->view->serverUrl() . $this->view->url(array('module' => $this->getRequest()->getModuleName(), 'controller' => $this->getRequest()->getControllerName(), 'action' => $this->getRequest()->getActionName()), 'cms'), 'rss'); $feed->setDateModified(time()); $criteria = array('lang' => CURR_LANG, 'user_id' => $this->getRequest()->getParam("user_id"), 'category_id' => $this->getRequest()->getParam("category_id"), 'status' => 'published'); if (isset($this->_typeId)) { $criteria['type_id'] = $this->_typeId; } elseif (isset($this->_typeCode)) { $criteria['type_code'] = $this->_typeCode; } elseif (null != $this->getRequest()->getParam("type_id")) { $criteria['type_id'] = $this->getRequest()->getParam("type_id"); } elseif (null != $this->getRequest()->getParam("type_code")) { $criteria['type_code'] = $this->getRequest()->getParam("type_code"); } $this->_addEntries($feed, $criteria); $this->getResponse()->setHeader('Content-type', 'application/rss+xml; charset=UTF-8'); echo $feed->export('rss'); }
public function rssAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $news = $this->model->getAllActiveNews(); $url = $this->view->serverUrl(); $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle('PHPPlaneta'); $feed->setLink($url . '/'); $feed->setDescription('PHPPlaneta'); $feed->setFeedLink($url . '/news/rss', 'rss'); $feed->setDateModified(time()); $entry = null; foreach ($news as $n) { $entry = $feed->createEntry(); $entry->setTitle($n->title); $newsUrl = $url . $this->urlHelper->url(array('action' => 'view', 'controller' => 'news', 'slug' => $n->slug), 'news', true); $entry->setLink($newsUrl); $entry->setDateCreated(strtotime($n->datetime_added)); $entry->setContent($n->text); $feed->addEntry($entry); } $out = $feed->export('rss'); $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=utf-8'); echo $out; }
} // Verify we have a valid branch. $branch = trim($_GET['b']); if (!in_array($branch, $branches)) { echo 'no such branch "' . $branch . '"'; header('HTTP/1.1 404 Page Not Found'); exit; } // Create the feed object. set_include_path($cfg->zfPath); require_once 'Zend/Feed/Writer/Feed.php'; $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($repoName . ' commit log - ' . $branch); $feed->setDescription($repoDesc); $feed->setLink($cfg->viewGitUri); $feed->setFeedLink(($_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $cfg->type); $feed->addAuthor(array('name' => $cfg->authorName, 'email' => $cfg->authorEmail)); // We'll set the feed's modification date to the date of the most recent commit. $timeModified = 0; // Loop over the last N commits. foreach (proc("{$cfg->git} --git-dir={$repoPath} log {$branch} -{$cfg->numEntries} --format=format:'%H|%ct|%an|%ae|%s'") as $log) { list($commitId, $commitTime, $authorName, $authorEmail, $comment) = explode('|', $log, 5); // If this is the most recent commit, we'll use it for the feed's modification date. if ($commitTime > $timeModified) { $timeModified = $commitTime; } // We'll use the commit diff as the content. $diff = '<pre>' . htmlentities(proc("{$cfg->git} --git-dir={$repoPath} show --format={$cfg->format} {$commitId}", false)) . '</pre>'; // Build the entry for this commit. $entry = $feed->createEntry(); $entry->setTitle($authorName . ' : ' . $comment);