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