/** * @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(array('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(array('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); }
/** * Generate the entries and add them to the RSS feed * * @param Zend_Feed_Writer_Feed $feed * @return $this */ protected function _addEntriesToFeed($feed) { $posts = Mage::getSingleton('core/layout')->createBlock($this->getSourceBlock())->getPostCollection(); $this->_prepareItemCollection($posts); foreach ($posts as $post) { $entry = $feed->createEntry(); if (!$post->getPostTitle()) { continue; } if (!($postDate = strtotime($post->getData('post_date_gmt')))) { continue; } $entry->setDateModified($postDate); $entry->setTitle($post->getPostTitle()); $entry->setLink($post->getPermalink()); $_author = $post->getAuthor(); if ($_author->getUserEmail() && $_author->getDisplayName()) { $entry->addAuthor(array('name' => $_author->getDisplayName(), 'email' => $_author->getUserEmail())); } $description = $this->displayExceprt() ? $post->getPostExcerpt() : $post->getPostContent(); $entry->setDescription($description ? $description : ' '); foreach ($post->getParentCategories() as $category) { $entry->addCategory(array('term' => $category->getUrl())); } $feed->addEntry($entry); } return $this; }
protected function _Tinhte_XenTag_prepareRssEntry($result, Zend_Feed_Writer_Feed $feed) { $entry = false; 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)); $discussionRssContentLength = XenForo_Application::getOptions()->get('discussionRssContentLength'); if (!empty($thread['message']) && $discussionRssContentLength > 0) { $bbCodeParser = $this->_Tinhte_XenTag_getBbCodeParser('Base'); $bbCodeSnippetParser = $this->_Tinhte_XenTag_getBbCodeParser('XenForo_BbCode_Formatter_BbCode_Clean'); $rendererStates = array('disableProxying' => true); $wordTrimmed = XenForo_Helper_String::wholeWordTrim($thread['message'], $discussionRssContentLength); $snippet = $bbCodeSnippetParser->render($wordTrimmed, $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 (!$this->_Tinhte_XenTag_isBuggyXmlNamespace()) { $entry->addAuthor(array('name' => $thread['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread))); if ($thread['reply_count']) { $entry->setCommentCount($thread['reply_count']); } } } return $entry; }
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; }
/** * 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 rss($title = '', $fullUrl = '', $items = array(), $other_data = array()) { $feed = new Zend_Feed_Writer_Feed(); if ($title != '') { $feed->setTitle($title); $feed->setDescription($title); } if ($fullUrl != '') { $feed->setLink($fullUrl); } if (empty($other_data["author"]["name"])) { $other_data["author"]["name"] = " "; } if (empty($other_data["author"]["email"])) { $other_data["author"]["email"] = " "; } if (empty($other_data["author"]["url"])) { $other_data["author"]["url"] = " "; } $feed->addAuthor($other_data["author"]); $feed->setDateModified(time()); /** * Add one or more entries. Note that entries must * be manually added once created. */ if (is_array($items) && count($items) > 0) { foreach ($items as $item) { $entry = $feed->createEntry(); $entry->setTitle($item->get_title()); $entry->setLink($this->view->serverUrl() . $this->view->url(array('module' => $other_data["url_params"]["module"], 'controller' => $other_data["url_params"]["controller"], 'action' => $other_data["url_params"]["action"], 'url_id' => $item->get_url_id()))); $publish_date = $item->get_data("publish_date"); if ($publish_date != '') { $entry->setDateModified(strtotime($item->get_data("publish_date"))); } else { $entry->setDateModified(strtotime($item->get_posted())); } $entry->setDateCreated(HCMS_Utils_Time::timeMysql2Ts($item->get_posted())); $content = $item->get_content(); if ($content != '') { $entry->setContent($content); } $feed->addEntry($entry); } } /** * 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. */ return $feed->export('rss'); }
/** * Generate the entries and add them to the RSS feed * * @param Zend_Feed_Writer_Feed $feed * @return $this */ protected function _addEntriesToFeed($feed) { $comments = Mage::getResourceModel('wordpress/post_comment_collection')->addCommentApprovedFilter()->addOrderByDate('desc'); $this->_prepareItemCollection($comments); foreach ($comments as $comment) { $entry = $feed->createEntry(); if ($this->getSource()) { $entry->setTitle(Mage::helper('wordpress')->__('By: %s', $comment->getCommentAuthor())); } else { $entry->setTitle(Mage::helper('wordpress')->__('Comment on %s by %s', $comment->getPost()->getPostTitle(), $comment->getCommentAuthor())); } $entry->setLink($comment->getUrl()); if ($comment->getCommentAuthorEmail() && $comment->getCommentAuthor()) { $entry->addAuthor(array('name' => $comment->getCommentAuthor(), 'email' => $comment->getCommentAuthorEmail())); } $entry->setDescription($comment->getCommentContent()); $entry->setDateModified(strtotime($comment->getData('comment_date_gmt'))); $feed->addEntry($entry); } return $this; }
protected function _createFeed() { $config = $this->getInvokeArg('bootstrap')->getOption('configuration'); $markdown = new \Markdown\Adapter(); $feed = new \Zend_Feed_Writer_Feed(); $feed->setDateCreated(); $feed->setTitle($config['feed']['title']); $feed->setDescription($config['feed']['description']); $feed->setLink($this->serverUrl); $items = array_merge($this->newsRepository->fetchEntities(6), $this->eventRepository->fetchEntities(3)); foreach ($items as $item) { $entry = $feed->createEntry(); $entry->setTitle($item->headline); if ($item instanceof \Newsroom\Entity\News) { $entry->setLink($this->serverUrl . '/news/' . $item->url); } else { if ($item instanceof \Newsroom\Entity\Event) { $entry->setLink($this->serverUrl . '/event/' . $item->url); } } $author = isset($item->user->title) ? $item->user->title . ' ' : ''; $author .= $item->user->firstname; $author .= ' ' . $item->user->lastname; $entry->addAuthor($author); $entry->setContent($markdown->markdown($item->content)); $entry->setDateCreated($item->getCreate('U')); $entry->setDateModified($item->getUpdate('U')); $feed->addEntry($entry); } return $feed; }
/** * 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); }
private function getFeed() { $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle('My Blog'); $feed->setLink(Model_Post::getUrl()); $feed->setDateModified(time()); $feed->setDescription('this is my blog'); foreach (Model_Post::getPosts() as $post) { $entry = $feed->createEntry(); foreach ($post->getFieldsAsArray() as $field => $value) { $method = 'set' . ucfirst($field); $entry->{$method}($value); } $feed->addEntry($entry); } return $feed; }
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'); }
function generate_feed_from_data($data, $feed_descriptor) { require_once 'lib/smarty_tiki/modifier.sefurl.php'; $tikilib = TikiLib::lib('tiki'); $writer = new Zend_Feed_Writer_Feed(); $writer->setTitle($feed_descriptor['feedTitle']); $writer->setDescription($feed_descriptor['feedDescription']); $writer->setLink($tikilib->tikiUrl('')); $writer->setDateModified(time()); foreach ($data as $row) { $titleKey = $feed_descriptor['entryTitleKey']; $url = $row[$feed_descriptor['entryUrlKey']]; $title = $row[$titleKey]; if (isset($feed_descriptor['entryObjectDescriptors'])) { list($typeKey, $objectKey) = $feed_descriptor['entryObjectDescriptors']; $object = $row[$objectKey]; $type = $row[$typeKey]; if (empty($url)) { $url = smarty_modifier_sefurl($object, $type); } if (empty($title)) { $title = TikiLib::lib('object')->get_title($type, $object); } } $entry = $writer->createEntry(); $entry->setTitle($title ? $title : tra('Unspecified')); $entry->setLink($tikilib->tikiUrl($url)); $entry->setDateModified($row[$feed_descriptor['entryModificationKey']]); $writer->addEntry($entry); } return $writer; }
/** * 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; }
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 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; } }
/** * 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); }
// Get the branches for this repo. $branches = array(); foreach (proc("{$cfg->git} --git-dir={$repoPath} branch") as $branch) { array_push($branches, trim(substr($branch, 2))); } // 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.
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'); }
/** * 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'); }
/** * Generate our Feed */ protected function getFeed($type = null) { # Prepare $App = $this->getHelper('App'); $Identity = $App->getUser(); # -------------------------- # Fetch Content # Search $search = $App->fetchSearch(); $searchQuery = delve($search, 'query'); # Prepare Criteria $criteria = array('recent' => true, 'fetch' => 'list', 'status' => 'published', 'Identity' => $Identity, 'hydrationMode' => Doctrine::HYDRATE_ARRAY); # Criteria: SearchQuery if ($searchQuery) { $criteria['search'] = $searchQuery; } # Fetch $Contents = $App->fetchRecords('Content', $criteria); # -------------------------- # Generate Feed # Pepare Feed $feed = array('title' => $App->getConfig('site.title'), 'link' => $App->getBaseUrl(true), 'author' => $App->getConfig('site.author'), 'dateModified' => empty($Content[0]) ? time() : strtotime($Content->updated_at), 'description' => $App->getConfig('site.description', 'News Feed for ' . $App->getConfig('site.title')), 'categories' => prepare_csv_array($App->getConfig('site.keywords'))); # Create Feed $Feed = new Zend_Feed_Writer_Feed(); $Feed->setTitle($feed['title']); $Feed->setLink($feed['link']); $Feed->setDateModified($feed['dateModified']); $Feed->setDescription($feed['description']); $Feed->addAuthor($feed['author']['title'], $feed['author']['email'], $feed['author']['url']); $Feed->addHub('http://pubsubhubbub.appspot.com/'); # Apply Categories $categories = array(); foreach ($feed['categories'] as $tag) { $categories[] = array('term' => str_replace(' ', '-', $tag), 'label' => $tag); } $Feed->addCategories($categories); # Content Map $contentMap = array('title' => 'title', 'url' => 'link', 'updated_at' => 'dateModified', 'created_at' => 'dateCreated', 'description_rendered' => 'description', 'content_rendered' => 'content'); # Apply Content foreach ($Contents as $Content) { # Create Entry $Entry = $Feed->createEntry(); # Prepare Content $Content['url'] = $App->getUrl()->content($Content)->full()->toString(); $Content['updated_at'] = strtotime($Content['updated_at']); $Content['created_at'] = strtotime($Content['created_at']); # Apply Content foreach ($contentMap as $from => $to) { $method = 'set' . ucfirst($to); $value = delve($Content, $from); $Entry->{$method}($value); } # Apply Author if (empty($Content['Author']['website'])) { $Content['Author']['website'] = $App->getUrl()->user($Content['Author'])->full()->toString(); } $Entry->addAuthor($Content['Author']['displayname'], $Content['Author']['email'], $Content['Author']['website']); # Apply Categories $categories = array(); foreach ($Content['ContentTags'] as $Tag) { $categories[] = array('term' => str_replace(' ', '-', $Tag['name']), 'label' => $Tag['name']); } $Entry->addCategories($categories); # Add Entry $Feed->addEntry($Entry); } # -------------------------- # Done # Return Feed return $Feed; }
public function renderRss() { if (XenForo_Application::getOptions()->sonnbXG_enableRSS) { $album = $this->_params['album']; $title = $album['title']; $description = $album['description'] . ' '; $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24'; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); $feed->setTitle($title); if ($description) { $feed->setDescription($description); } $feed->setLink(XenForo_Link::buildPublicLink('canonical:gallery/albums', $album)); if (!$buggyXmlNamespace) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:gallery/albums/index.rss', $album), '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['contents'] as $content) { $photoDescription = $parser->render($content['description']); $entry = $feed->createEntry(); $photoDescription .= '<br /><br />'; $photoDescription .= '<a href="' . XenForo_Link::buildPublicLink('canonical:gallery/' . $content['content_type'] . 's', $content) . '"><img src="' . XenForo_Link::convertUriToAbsoluteUri($content['thumbnailUrl'], true) . '" /></a>'; if ($photoDescription) { $entry->setDescription($photoDescription); } $entry->setTitle(' '); $entry->setLink(XenForo_Link::buildPublicLink('canonical:gallery/photos', $content)); $entry->setDateCreated(new Zend_Date($content['content_date'], Zend_Date::TIMESTAMP)); $entry->setDateModified(new Zend_Date($content['content_updated_date'], Zend_Date::TIMESTAMP)); if (!$buggyXmlNamespace) { $entry->addAuthor(array('name' => $content['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:gallery/authors', $content))); if ($content['comment_count']) { $entry->setCommentCount($content['comment_count']); $entry->setCommentLink(XenForo_Link::buildPublicLink('canonical:gallery/' . $content['content_type'] . 's', $content) . '#content-' . $content['content_id']); } } $feed->addEntry($entry); } return $feed->export('rss'); } }
public function testAddsAndOrdersEntriesByDateIfRequested() { $writer = new Zend_Feed_Writer_Feed(); $entry = $writer->createEntry(); $entry->setDateCreated(1234567890); $entry2 = $writer->createEntry(); $entry2->setDateCreated(1230000000); $writer->addEntry($entry); $writer->addEntry($entry2); $writer->orderByDate(); $this->assertEquals(1230000000, $writer->getEntry(1)->getDateCreated()->get(Zend_Date::TIMESTAMP)); }
/** * Add entries * * @param array $criteria * @return array */ protected function _addEntries(Zend_Feed_Writer_Feed $feed, $criteria) { //always show 50 newest $paging = array('perPage' => 50, 'page' => 1); $orderBy = array('p.posted DESC'); $pages = Cms_Model_PageMapper::getInstance()->fetchAll($criteria, $orderBy, $paging); /*@var $page Cms_Model_Page */ foreach ($pages as $page) { if (null == $page->get_content() || '' == $page->get_content()) { continue; } $entry = $feed->createEntry(); $this->_populateFeedEntry($page, $entry); $feed->addEntry($entry); } }
/** * @expectedException Zend_Feed_Exception */ public function testSetSummaryThrowsExceptionWhenValueExceeds4000Chars() { $feed = new Zend_Feed_Writer_Feed(); $feed->setItunesSummary(str_repeat('a', 4001)); }
/** * @todo - VnE Thethao Rss Detail Page * @author HungNT1 */ public function detailAction() { //Set no view & no layout $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); header("Content-Type: application/xml; charset=utf-8"); //Auto refesh $this->view->headMeta()->appendHttpEquiv('refesh', '300'); $strCodeTinMoi = 'tin-moi-nhat'; $strCodeTinHot = 'tin-hot'; //Get cate_id $cate = $this->_request->getParam('cate'); if ($strCodeTinMoi !== $cate && $strCodeTinHot != $cate) { if ($cate == null) { $this->_redirect($this->view->configView['url']); } $category = Thethao_Model_Category::getInstance(); $result = $category->getCategoryByCode($cate); $cate_id = $result['category_id']; if ($cate_id < 0 || $cate_id == null) { $this->_redirect($this->view->configView['url']); } } //Get instance $modelNews = Thethao_Model_News::getInstance(); //Create parent feed $feed = new Zend_Feed_Writer_Feed(); $feed->setGenerator('Thehao.VnExpress.net:' . $this->view->configView['url'] . '/rss'); $feed->setDateModified(time()); $feed->setDescription('VNExpress Thể thao RSS'); if ($cate == $strCodeTinMoi) { //redirect to vne $this->_redirect($this->view->configView['url_vne'] . '/rss/the-thao.rss', array('code' => 301)); } elseif ($cate == $strCodeTinHot) { // Get lastest article in 1 days $arrParams = array('area' => array(0 => array('category_id' => SITE_ID, 'showed_area' => 'trangchu')), 'offset' => 0, 'limit' => 100); $arrLastestArticleID = $this->view->objArticle->getTopHotArticleByArr($arrParams); if (!empty($arrLastestArticleID[0])) { foreach ($arrLastestArticleID[0] as $val) { $val['article_id'] = intval($val['article_id']); $entry = $feed->createEntry(); $link = ''; $link .= $val['share_url']; if ($val['title'] != null) { $entry->setTitle($val['title']); } if ($val['share_url'] != null) { $entry->setLink($link); } if ($val['update_time'] > 0) { $entry->setDateModified($val['update_time']); } if ($val['publish_time'] > 0) { $entry->setDateCreated($val['publish_time']); } $val['lead'] != null ? $entry->setDescription('<a href="' . $link . '"><img width=130 height=100 src="' . $this->view->ImageurlArticle($val, 'size1') . '" ></a></br>' . $val['lead']) : $entry->setDescription('No Description'); $feed->addEntry($entry); } } $result['catename'] = 'Tin hot'; } else { // Get list article with rule 3 $arrPamram = array('category_id' => $cate_id, 'site_id' => SITE_ID, 'offset' => 0, 'limit' => 20); $arrTopArticleID = $modelNews->getListArticleIdsByRule3($arrPamram); //Add entry if (!empty($arrTopArticleID['data'])) { $this->view->objArticle->setIdBasic($arrTopArticleID['data']); foreach ($arrTopArticleID['data'] as $id) { $val = $this->view->objArticle->getArticleBasic($id); if (empty($val)) { continue; } $link = $val['share_url']; $entry = $feed->createEntry(); if ($val['title'] != null) { $entry->setTitle($val['title']); } if (!empty($link) && null != $link) { $entry->setLink($link); } if ($val['update_time'] != null) { $entry->setDateModified($val['update_time']); } if ($val['creation_time'] != null) { $entry->setDateCreated($val['creation_time']); } $val['lead'] != null ? $entry->setDescription('<a href="' . $link . '"><img width=130 height=100 src="' . $this->view->ImageurlArticle($val, 'size5') . '" ></a></br>' . $val['lead']) : $entry->setDescription('No Description'); $feed->addEntry($entry); } } } $feed->setTitle($result['catename'] . ' - VNExpress Thể thao RSS'); $feed->setLink('http://thethao.vnexpress.net/rss/' . $cate . '.rss'); //Create xml $out = $feed->export('rss'); echo $out; }
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'); }
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'); }
/** Display the index page of comments. */ public function indexAction() { $comments = new Comments(); $comments = $comments->getCommentsToFinds($this->_getParam('page')); $contextSwitch = Zend_Controller_Action_HelperBroker::getStaticHelper('ContextSwitch'); $context = $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('http://www.finds.org.uk'); $feed->setFeedLink($this->view->CurUrl(), $context); $feed->addAuthor(array('name' => 'The Portable Antiquities Scheme', 'email' => '*****@*****.**', 'uri' => 'http://www.finds.org.uk')); $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('http://www.finds.org.uk/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; } }
$client = $token->getHttpClient($config); $client->setUri('http://twitter.com/statuses/update.json'); $client->setMethod(Zend_Http_Client::POST); $client->setParameterPost('status', $statusMessage); $response = $client->request(); return new Symfony\Component\HttpFoundation\RedirectResponse($thisPage . '?msg=retweet'); }); /** * 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);