当前位置: 首页>>代码示例>>PHP>>正文


PHP RSSFeed::setTemplate方法代码示例

本文整理汇总了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);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:10,代码来源:RSSFeedTest.php

示例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();
 }
开发者ID:silverstripe-scienceninjas,项目名称:datedupdates,代码行数:6,代码来源:NewsHolder.php

示例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();
     }
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-express,代码行数:45,代码来源:ExpressHomePage.php

示例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();
    }
开发者ID:mandrew,项目名称:silverstripe-versionfeed,代码行数:52,代码来源:VersionFeed_Controller.php


注:本文中的RSSFeed::setTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。