本文整理汇总了PHP中RSSFeed::outputToBrowser方法的典型用法代码示例。如果您正苦于以下问题:PHP RSSFeed::outputToBrowser方法的具体用法?PHP RSSFeed::outputToBrowser怎么用?PHP RSSFeed::outputToBrowser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSSFeed
的用法示例。
在下文中一共展示了RSSFeed::outputToBrowser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRenderWithTemplate
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);
}
示例2: rss
/**
* 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();
}
示例3: rss
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();
}
示例4: rss
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();
}
示例5: tag
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;
}
}
示例6: results
/**
* 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();
}
}
示例7: rss
/**
* 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();
}
}
示例8: rss
/**
* 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();
}
示例9: rss
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();
}
示例10: rss
public function rss()
{
$rss = new RSSFeed($this->Updates()->sort('Created DESC')->limit(20), $this->Link(), $this->getSubscriptionTitle());
$rss->setTemplate('NewsHolder_rss');
return $rss->outputToBrowser();
}
示例11: rss
public function rss()
{
$SiteConfig = SiteConfig::current_site_config();
$rss = new RSSFeed(NewsArticle::get(), $this->Link(), $SiteConfig->Title);
return $rss->outputToBrowser();
}
示例12: rss
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();
}
示例13: rss
/**
* 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();
}
示例14: rss
/**
* 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;
}
示例15: rss
/**
* 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 '';
}