public function testRenderWithTemplate() { $rssFeed = new RSSFeed(new ArrayList(), "", "", ""); $rssFeed->setTemplate('RSSFeedTest'); $content = $rssFeed->outputToBrowser(); $this->assertContains('<title>Test Custom Template</title>', $content); $rssFeed->setTemplate('RSSFeed'); $content = $rssFeed->outputToBrowser(); $this->assertNotContains('<title>Test Custom Template</title>', $content); }
/** * Return an RSS feed of comments for a given set of comments or all * comments on the website. * * To maintain backwards compatibility with 2.4 this supports mapping * of PageComment/rss?pageid= as well as the new RSS format for comments * of CommentingController/rss/{classname}/{id} * * @return RSS */ public function rss() { $link = $this->Link('rss'); $class = $this->urlParams['ID']; $id = $this->urlParams['OtherID']; if (isset($_GET['pageid'])) { $id = Convert::raw2sql($_GET['pageid']); $comments = Comment::get()->where(sprintf("BaseClass = 'SiteTree' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", $id)); $link = $this->Link('rss', 'SiteTree', $id); } else { if ($class && $id) { if (Commenting::has_commenting($class)) { $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class), Convert::raw2sql($id))); $link = $this->Link('rss', Convert::raw2xml($class), (int) $id); } else { return $this->httpError(404); } } else { if ($class) { if (Commenting::has_commenting($class)) { $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class))); } else { return $this->httpError(404); } } else { $comments = Comment::get(); } } } $title = _t('CommentingController.RSSTITLE', "Comments RSS Feed"); $feed = new RSSFeed($comments, $link, $title, $link, 'Title', 'Comment', 'AuthorName'); $feed->outputToBrowser(); }
public function rss() { $config = SiteConfig::current_site_config(); // Creates a new RSS Feed list $rss = new RSSFeed($list = NewsArticle::get(), $link = $this->Link("rss"), $title = $config->Title . " News", $description = "All the latest news from " . $config->Title . "."); // Outputs the RSS feed to the user. return $rss->outputToBrowser(); }
function rss() { $request = Controller::curr()->getRequest(); $foundation = $request->requestVar('foundation'); $jobs = $this->repository->getDateSortedJobs($foundation); $rss = new RSSFeed($jobs, $this->Link(), "OpenStack Jobs Feed"); $rss->outputToBrowser(); }
function tag() { $blogName = $this->owner->Title . " - " . ucwords($this->owner->request->latestParam('ID')); if ($this->owner->request->param('Action') == 'tag' && $this->owner->request->param('OtherID') == "rss") { $entries = $this->owner->Entries(20, Convert::raw2xml($this->owner->request->latestParam('ID'))); if ($entries) { $rss = new RSSFeed($entries, $this->owner->Link('rss'), $blogName, "", "Title", "RSSContent"); return $rss->outputToBrowser(); } } else { return $this->owner; } }
/** * Overrides the ContentControllerSearchExtension and adds snippets to results. */ function results($data, $form, $request) { $this->linkToAllSiteRSSFeed(); $results = $form->getResults(); $query = $form->getSearchQuery(); // Add context summaries based on the queries. foreach ($results as $result) { $contextualTitle = new Text(); $contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title); $result->ContextualTitle = $contextualTitle->ContextSummary(300, $query); if (!$result->Content && $result->ClassName == 'File') { // Fake some content for the files. $result->ContextualContent = "A file named \"{$result->Name}\" ({$result->Size})."; } else { $result->ContextualContent = $result->obj('Content')->ContextSummary(300, $query); } } $rssLink = HTTP::setGetVar('rss', '1'); // Render the result. $data = array('Results' => $results, 'Query' => $query, 'Title' => _t('SearchForm.SearchResults', 'Search Results'), 'RSSLink' => $rssLink); // Choose the delivery method - rss or html. if (!$this->owner->request->getVar('rss')) { // Add RSS feed to normal search. RSSFeed::linkToFeed($rssLink, "Search results for query \"{$query}\"."); return $this->owner->customise($data)->renderWith(array('Page_results', 'Page')); } else { // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context. $fullList = $results->getList()->sort('LastEdited', 'DESC'); // Get some descriptive strings $siteName = SiteConfig::current_site_config()->Title; $siteTagline = SiteConfig::current_site_config()->Tagline; if ($siteName) { $title = "{$siteName} search results for query \"{$query}\"."; } else { $title = "Search results for query \"{$query}\"."; } // Generate the feed content. $rss = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null); $rss->setTemplate('Page_results_rss'); return $rss->outputToBrowser(); } }
/** * Get the rss feed for this blog holder's entries */ function rss() { global $project; $blogName = $this->Name; $altBlogName = $project . ' blog'; $entries = $this->Entries(20); if($entries) { $rss = new RSSFeed($entries, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent"); $rss->outputToBrowser(); } }
/** * Generate a RSS feed of news page */ public function rss() { $siteConfig = SiteConfig::current_site_config(); $rss = new RSSFeed($this->NewsArticles()->filter(array('Date:LessThan' => $this->cur_time())), $this->Link(), $siteConfig->Title, null, 'Title', 'RssContent', null, 'Created'); return $rss->outputToBrowser(); }
public function rss($request, $limit = 10) { $addons = Addon::get()->sort('Released', 'DESC')->limit($limit); $rss = new RSSFeed($addons, $this->Link(), "Newest addons on addons.silverstripe.org", null, 'RSSTitle'); return $rss->outputToBrowser(); }
public function rss() { $rss = new RSSFeed($this->Updates()->sort('Created DESC')->limit(20), $this->Link(), $this->getSubscriptionTitle()); $rss->setTemplate('NewsHolder_rss'); return $rss->outputToBrowser(); }
public function rss() { $SiteConfig = SiteConfig::current_site_config(); $rss = new RSSFeed(NewsArticle::get(), $this->Link(), $SiteConfig->Title); return $rss->outputToBrowser(); }
function rss() { $feed = new RSSFeed( $this->dataRecord->Jobs(), $this->Link() . 'rss', "Jobs in {$this->dataRecord->Title}", "New Job Postings for SilverStripe Developers", 'Title', 'Description' ); return $feed->outputToBrowser(); }
/** * RSS feed */ public function rss() { $list = NewsPost::get()->filter('ParentID', $this->ID); $list = $list->Sort('DateTime DESC'); $this->extend('updateRSSItems', $list); $feed = new RSSFeed($list, $this->AbsoluteLink(), $this->Title); return $feed->outputToBrowser(); }
/** * Get the RSS feed * * This method will output the RSS feed with the last 50 posts to the * browser. */ function rss() { HTTP::set_cache_age(3600); // cache for one hour $threadID = null; $forumID = null; // optionally allow filtering of the forum posts by the url in the format // rss/thread/$ID or rss/forum/$ID if (isset($this->urlParams['ID']) && ($action = $this->urlParams['ID'])) { if (isset($this->urlParams['OtherID']) && ($id = $this->urlParams['OtherID'])) { switch ($action) { case 'forum': $forumID = (int) $id; break; case 'thread': $threadID = (int) $id; } } else { // fallback is that it is the ID of a forum like it was in // previous versions $forumID = (int) $action; } } $data = array('last_created' => null, 'last_id' => null); if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && !isset($_SERVER['HTTP_IF_NONE_MATCH'])) { // just to get the version data.. $this->getNewPostsAvailable(null, null, $forumID, $threadID, &$data); // No information provided by the client, just return the last posts $rss = new RSSFeed($this->getRecentPosts(50, $forumID, $threadID), $this->Link() . 'rss', sprintf(_t('Forum.RSSFORUMPOSTSTO'), $this->Title), "", "Title", "RSSContent", "RSSAuthor", $data['last_created'], $data['last_id']); $rss->outputToBrowser(); } else { // Return only new posts, check the request headers! $since = null; $etag = null; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { // Split the If-Modified-Since (Netscape < v6 gets this wrong) $since = explode(';', $_SERVER['HTTP_IF_MODIFIED_SINCE']); // Turn the client request If-Modified-Since into a timestamp $since = @strtotime($since[0]); if (!$since) { $since = null; } } if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && is_numeric($_SERVER['HTTP_IF_NONE_MATCH'])) { $etag = (int) $_SERVER['HTTP_IF_NONE_MATCH']; } if ($this->getNewPostsAvailable($since, $etag, $forumID, $threadID, $data)) { HTTP::register_modification_timestamp($data['last_created']); $rss = new RSSFeed($this->getRecentPosts(50, $forumID, $threadID, $etag), $this->Link() . 'rss', sprintf(_t('Forum.RSSFORUMPOSTSTO'), $this->Title), "", "Title", "RSSContent", "RSSAuthor", $data['last_created'], $data['last_id']); $rss->outputToBrowser(); } else { if ($data['last_created']) { HTTP::register_modification_timestamp($data['last_created']); } if ($data['last_id']) { HTTP::register_etag($data['last_id']); } // There are no new posts, just output an "304 Not Modified" message HTTP::add_cache_headers(); header('HTTP/1.1 304 Not Modified'); } } exit; }
/** * Output the RSS feed for items connected to the requested news holder * * @param SS_HTTPRequest $request * @return string */ function rss($request = null) { $namespace = $this->Namespace; $skip = 0; $limit = 20; if ($request) { if ($requestedNamespace = $request->param('ID')) { $namespace = trim($requestedNamespace); } if ($requestedLimit = $request->param('OtherID')) { $requestedLimit = explode(',', $requestedLimit); array_filter($requestedLimit); $limit = intval($requestedLimit[0]); if (count($requestedLimit) > 1) { $skip = intval($requestedLimit[1]); } } } if ($entries = NewsHelper::Entries($skip, $limit, $namespace)) { $rss = new RSSFeed($entries, $this->AbsoluteLink(), $this->RSSTitle); $xml = $rss->outputToBrowser(); return utf8_decode($xml); } return ''; }
function rss() { $parentcheck = isset($_REQUEST['pageid']) ? "ParentID = " . (int) $_REQUEST['pageid'] : "ParentID > 0"; $comments = DataObject::get("PageComment", "$parentcheck AND IsSpam=0", "Created DESC", "", 10); if(!isset($comments)) { $comments = new DataObjectSet(); } $rss = new RSSFeed($comments, "home/", "Page comments", "", "RSSTitle", "Comment", "Name"); $rss->outputToBrowser(); }
/** * Get the rss feed for this blog holder's entries */ function rss() { global $project_name; $blogName = $this->Name; $altBlogName = $project_name . ' blog'; $entries = $this->Entries(20); if ($entries) { $rss = new RSSFeed($entries, $this->Link('rss'), $blogName ? $blogName : $altBlogName, "", "Title", "RSSContent"); $rss->outputToBrowser(); } }
function rss() { $rss = new RSSFeed($this->Children(), $this->Link(), "OpenStack Event Updates RSS Feed", "This feed provides updates related to the OpenStack Spring 2012 Conference and Design Summit.", "Title", "Content"); $rss->outputToBrowser(); }
/** * Get all changes from the site in a RSS feed. */ public function allchanges() { // Check viewability of allchanges if (!Config::inst()->get('VersionFeed', 'allchanges_enabled') || !SiteConfig::current_site_config()->AllChangesEnabled) { return $this->owner->httpError(404, 'Global history not viewable'); } $limit = (int) Config::inst()->get('VersionFeed', 'allchanges_limit'); $latestChanges = DB::query(' SELECT * FROM "SiteTree_versions" WHERE "WasPublished" = \'1\' AND "CanViewType" IN (\'Anyone\', \'Inherit\') AND "ShowInSearch" = 1 AND ("PublicHistory" IS NULL OR "PublicHistory" = \'1\') ORDER BY "LastEdited" DESC LIMIT ' . $limit); $lastChange = $latestChanges->record(); $latestChanges->rewind(); if ($lastChange) { // Cache the diffs to remove DOS possibility. $key = 'allchanges' . preg_replace('#[^a-zA-Z0-9_]#', '', $lastChange['LastEdited']) . (Member::currentUserID() ?: 'public'); $changeList = $this->filterContent($key, function () use($latestChanges) { $changeList = new ArrayList(); $canView = array(); foreach ($latestChanges as $record) { // Check if the page should be visible. // WARNING: although we are providing historical details, we check the current configuration. $id = $record['RecordID']; if (!isset($canView[$id])) { $page = SiteTree::get()->byID($id); $canView[$id] = $page && $page->canView(new Member()); } if (!$canView[$id]) { continue; } // Get the diff to the previous version. $version = new Versioned_Version($record); if ($diff = $version->getDiff()) { $changeList->push($diff); } } return $changeList; }); } else { $changeList = new ArrayList(); } // Produce output $rss = new RSSFeed($changeList, $this->owner->request->getURL(), $this->linkToAllSitesRSSFeedTitle(), '', 'Title', '', null); $rss->setTemplate('Page_allchanges_rss'); return $rss->outputToBrowser(); }
/** * Output RSS feed */ public function rss() { $entries = $this->microBlogService->globalFeed(); $feed = new RSSFeed($entries, $this->Link('rss'), 'Global updates'); $feed->outputToBrowser(); }
public function rss() { $rss = new RSSFeed($this->Children(), $this->Link(), "The coolest news around"); return $rss->outputToBrowser(); }
function Rss() { $parent = $this->data()->ID; $objects = NewsArticle::get()->filter('ParentID', $parent)->sort('LastEdited DESC')->limit(10); $rss = new RSSFeed($objects, $this->data()->Link(), _t('News.RSSTITLE', "10 most recent news"), "", "Title", "Content"); $this->response->addHeader('Content-Type', 'application/rss+xml'); return $rss->outputToBrowser(); }
function rss() { $jobs = $this->DateSortedJobs(); $rss = new RSSFeed($jobs, $this->Link(), "OpenStack Jobs Feed"); $rss->outputToBrowser(); }
public function rss() { $rss = new RSSFeed($this->GetNewsPages(), $this->Link(), $this->SiteConfig->Title . " News", "RSS feed for the news from " . $this->SiteConfig->Title); return $rss->outputToBrowser(); }
function rss() { $parentcheck = isset($_REQUEST['pageid']) ? "\"ParentID\" = " . (int) $_REQUEST['pageid'] : "\"ParentID\" > 0"; $unmoderatedfilter = Permission::check('ADMIN') ? '' : "AND \"NeedsModeration\" = 0"; $comments = DataObject::get("PageComment", "{$parentcheck} AND \"IsSpam\" = 0 {$unmoderatedfilter}", "\"Created\" DESC", "", 10); if (!isset($comments)) { $comments = new DataObjectSet(); } $rss = new RSSFeed($comments, "home/", "Page comments", "", "RSSTitle", "Comment", "RSSName"); $rss->outputToBrowser(); }
function index($request) { // For 2.3 and 2.4 compatibility $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; BasicAuth::enable(); BasicAuth::requireLogin("CMS RSS feed access. Use your CMS login", "CMS_ACCESS_CMSMain"); $member = $this->getBasicAuthMember(); // Due to a bug in 2.3.0 we can't get the information that we need from $request $params = Director::urlParams(); // Default value if (!isset($params['Data']) || !$params['Data']) { $params['Data'] = 'all'; } switch ($params['Data']) { case 'all': $changes = $this->changes(); break; case 'page': if ((int) $params['PageID']) { $changes = $this->changes("{$bt}SiteTree{$bt}.{$bt}ID{$bt} = " . (int) $params['PageID']); } else { return new HTTPResponse("<h1>Bad Page ID</h1><p>Bad page ID when getting RSS feed of changes to a page.</p>", 400); } break; default: user_error("CMSChangeTracker Data param value '{$params['Data']}' not implemented; this is probably due to a bad URL rule.", E_USER_ERROR); } $processedChanges = new DataObjectSet(); foreach ($changes as $change) { if ($change->canEdit($member)) { $author = DataObject::get_by_id("Member", $change->AuthorID); $verbed = $change->Version == 1 ? "created" : "edited"; if ($author) { $changeTitle = "'{$change->Title}' {$verbed} by {$author->FirstName} {$author->Surname}"; $changeAuthor = "{$author->FirstName} {$author->Surname}"; $firstParagraph = "{$author->FirstName} {$author->Surname} (<a href=\"mailto:{$author->Email}\">{$author->Email}</a>) has {$verbed} the '{$change->Title}' page."; } else { $changeTitle = "'{$change->Title}' {$verbed}"; $changeAuthor = ""; $firstParagraph = "The '{$change->Title}' page has been {$verbed}."; } $actionLinks = ""; $cmsLink = Director::absoluteURL("admin/show/{$change->ID}"); $actionLinks .= "<li><a href=\"{$cmsLink}\">Edit in CMS</a></li>\n"; $page = DataObject::get_by_id('SiteTree', $change->ID); if ($page) { $link = $page->AbsoluteLink(); $actionLinks .= "<li><a href=\"{$link}\">See the page on site</a></li>\n"; } if ($change->Version > 1) { $prevVersion = $change->Version - 1; $diffLink = Director::absoluteURL("admin/compareversions/{$change->ID}/?From={$prevVersion}&To={$change->Version}"); $actionLinks .= "<li><a href=\"{$diffLink}\">See the changes in CMS</a></li>\n"; } $changeDescription = <<<HTML <p>{$firstParagraph}</p> <h3>Actions and links</h3> <ul> \t{$actionLinks} </ul> HTML; $processedChange = new CMSChangeTracker_Change(array("ChangeTitle" => $changeTitle, "Author" => $changeAuthor, "Content" => $changeDescription, "Link" => $change->Link() . "version/{$change->Version}")); $processedChanges->push($processedChange); } } $feed = new RSSFeed($processedChanges, Director::absoluteURL("admin/"), "SilverStripe Content Changes", "", "ChangeTitle"); return $feed->outputToBrowser(); }
/** * Renders RSS feed **/ public function rss() { $rss = new RSSFeed($this->data()->getArticleList()->limit(20), $this->Link(), $this->Title); return $rss->outputToBrowser(); }
public function rss() { $rss = new RSSFeed($this->Children(), $this->Link, SiteConfig::current_site_config()->Title . ' news'); return $rss->outputToBrowser(); }
public function rss() { $rss = new RSSFeed($list = MagnificGalleryItem::get()->sort('Created DESC')->limit(10)->toArray(), $link = Director::absoluteURL($this->RssLink()), $title = _t('MagnificGalleryPage.RSS_TITLE', 'Recent images from %s', array(Siteconfig::current_site_config()->Title)), $description = _t('MagnificGalleryPage.RSS_DESCRIPTION', 'Get recents images from our website')); // Outputs the RSS feed to the user. return $rss->outputToBrowser(); }