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


PHP SSViewer::process方法代码示例

本文整理汇总了PHP中SSViewer::process方法的典型用法代码示例。如果您正苦于以下问题:PHP SSViewer::process方法的具体用法?PHP SSViewer::process怎么用?PHP SSViewer::process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SSViewer的用法示例。


在下文中一共展示了SSViewer::process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cwsShortCodeRandomImageHandler

 /**
  * Displays a random image with colorbox effect from a given assets subfolder
  * Uses template "csoft-shortcode/templates/Includes/RandomImage.ss" for output 
  * 
  * @param mixed $arguments (folder='subfolder_in_assets' align='left|right')
  * @param $content = null
  * @param $parser = null
  * @return processed template RandomImage.ss
  */
 public static function cwsShortCodeRandomImageHandler($arguments, $content = null, $parser = null)
 {
     // only proceed if subfolder was defined
     if (!isset($arguments['folder'])) {
         return;
     }
     // sanitize user inputs
     $folder = Convert::raw2sql($arguments['folder']);
     $align = isset($arguments['align']) ? strtolower(Convert::raw2xml($arguments['align'])) : '';
     // fetch all images in random order from the user defined folder
     $folder = Folder::get()->filter('Filename', "assets/{$folder}/")->First();
     $randomImage = $folder ? Image::get()->filter('ParentID', $folder->ID)->sort('RAND()') : false;
     // exit if user defined folder does not contain any image
     if (!$randomImage) {
         return;
     }
     // extract image caption from image filename
     $caption = $randomImage->Title;
     if (preg_match('#(\\d*-)?(.+)\\.(jpg|gif|png)#i', $caption, $matches)) {
         $caption = ucfirst(str_replace('-', ' ', $matches[2]));
     }
     // prepare data for output
     $data = array('RandomImage' => $randomImage->First(), 'Alignment' => $align, 'Caption' => $caption);
     // load template and process data
     $template = new SSViewer('RandomImage');
     return $template->process(new ArrayData($data));
 }
开发者ID:helpfulrobot,项目名称:cwsoft-silverstripe-shortcode,代码行数:36,代码来源:cwsShortCodeRandomImage.php

示例2: parse_flickr

 public static function parse_flickr($arguments, $caption = null, $parser = null)
 {
     // first things first, if we dont have a video ID, then we don't need to
     // go any further
     if (empty($arguments['id'])) {
         return;
     }
     $customise = array();
     /*** SET DEFAULTS ***/
     $fp = DataList::create('FlickrPhoto')->where('FlickrID=' . $arguments['id'])->first();
     if (!$fp) {
         return '';
     }
     $customise['FlickrImage'] = $fp;
     //set the caption
     if ($caption === null || $caption === '') {
         if (isset($arguments['caption'])) {
             $caption = $arguments['caption'];
         }
     }
     $customise['Caption'] = $caption ? Convert::raw2xml($caption) : $fp->Title;
     $customise['Position'] = !empty($arguments['position']) ? $arguments['position'] : 'center';
     $customise['Small'] = true;
     if ($customise['Position'] == 'center') {
         $customise['Small'] = false;
     }
     $fp = null;
     //overide the defaults with the arguments supplied
     $customise = array_merge($customise, $arguments);
     //get our YouTube template
     $template = new SSViewer('ShortCodeFlickrPhoto');
     //return the customised template
     return $template->process(new ArrayData($customise));
 }
开发者ID:gordonbanderson,项目名称:flickr-editor,代码行数:34,代码来源:FlickrPhotoShortCodeHandler.php

示例3: run

 /**
  * 
  * @param SS_HTTPRequest $request
  */
 public function run($request)
 {
     $cacheBaseDir = singleton('FilesystemPublisher')->getDestDir();
     // First generate the search file for the base site
     $viewer = new SSViewer(array('StaticSearchJSON'));
     $item = new ViewableData($this);
     $json = $viewer->process($this->getAllLivePages(0));
     $domain = Config::inst()->get('FilesystemPublisher', 'static_base_url');
     $urlFragments = parse_url($domain);
     $cacheDir = $cacheBaseDir . "/" . $urlFragments['host'];
     file_put_contents($cacheDir . '/search_index.html', $json);
     if (class_exists('Subsite')) {
         // Then generate the files for the subsites
         $subsites = Subsite::all_sites();
         foreach ($subsites as $subsite) {
             $viewer = new SSViewer(array('StaticSearchJSON'));
             $item = new ViewableData($this);
             $json = $viewer->process($this->getAllLivePages($subsite->ID));
             $domains = DataObject::get("SubsiteDomain")->filter(array("SubsiteID" => $subsite->ID));
             foreach ($domains as $domain) {
                 $urlFragments = parse_url($domain->Domain);
                 $cacheDir = $cacheBaseDir . "/" . $urlFragments['path'];
                 file_put_contents($cacheDir . '/search_index.html', $json);
             }
         }
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:adrexia-staticsearch,代码行数:32,代码来源:BuildStaticSearchIndexTask.php

示例4: Breadcrumbs

 /**
  * Modified version of Breadcrumbs, to cater for viewing items.
  */
 public function Breadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false)
 {
     $page = $this;
     $pages = array();
     while ($page && (!$maxDepth || count($pages) < $maxDepth) && (!$stopAtPageType || $page->ClassName != $stopAtPageType)) {
         if ($showHidden || $page->ShowInMenus || $page->ID == $this->ID) {
             $pages[] = $page;
         }
         $page = $page->Parent;
     }
     // Add on the item we're currently showing.
     $controller = Controller::curr();
     if ($controller) {
         $request = $controller->getRequest();
         if ($request->param('Action') == 'show') {
             $id = $request->param('ID');
             if ($id) {
                 $object = DataObject::get_by_id($this->getDataClass(), $id);
                 array_unshift($pages, $object);
             }
         }
     }
     $template = new SSViewer('BreadcrumbsTemplate');
     return $template->process($this->customise(new ArrayData(array('Pages' => new ArrayList(array_reverse($pages))))));
 }
开发者ID:helpfulrobot,项目名称:silverstripe-registry,代码行数:28,代码来源:RegistryPage.php

示例5: cwsShortCodeRandomQuoteHandler

 /**
  * Displays random quote from a CSV file located in a assets subfolder
  * Uses template "cwsoft-shortcode/templates/Includes/RandomQuote.ss" for output 
  * 
  * @param $arguments (csv_file = 'subfolder_in_assets/csv_file.csv')
  * @param $content = null
  * @param $parser = null
  * @return processed template RandomQuote.ss
  */
 public static function cwsShortCodeRandomQuoteHandler($arguments, $content = null, $parser = null)
 {
     // only proceed if a CSV file was specified
     if (!isset($arguments['csv_file'])) {
         return;
     }
     $data = array();
     // check if CSV file exists in assets folder
     $csvFile = ASSETS_DIR . '/' . Convert::raw2sql($arguments['csv_file']);
     if (Director::fileExists($csvFile)) {
         $csv = new CSVParser($filename = $csvFile, $delimiter = '|', $enclosure = '"');
         // iterate through imported Quotes|Author entries and store results in array
         $citations = array();
         foreach ($csv as $row) {
             // only store entries with two data fields (quotation and author)
             if (count($row) !== 2) {
                 continue;
             }
             $citations[] = $row;
         }
         // prepare data for output (randomize array and fetch first citation for output)
         shuffle($citations);
         $data = $citations[0];
     }
     // use default citation if CSV file does not exist or is invalid
     if (!(isset($data['Quote']) && isset($data['Author']))) {
         $data['Quote'] = _t('cwsShortCodeRandomQuote.DEFAULT_QUOTE', 'Only who puts his heart and soul in it, can ignite the fire in others.');
         $data['Author'] = _t('cwsShortCodeRandomQuote.DEFAULT_AUTHOR', 'Augustinus');
     }
     // load template and process data
     $template = new SSViewer('RandomQuote');
     return $template->process(new ArrayData($data));
 }
开发者ID:helpfulrobot,项目名称:cwsoft-silverstripe-shortcode,代码行数:42,代码来源:cwsShortCodeRandomQuote.php

示例6: augmentSidebarContent

 public function augmentSidebarContent(&$content)
 {
     if ($this->owner->DateTime()->LocationID) {
         $location = $this->owner->DateTime()->Location();
         $viewer = new SSViewer('EventLocationSidebarContent');
         $content .= $viewer->process($location);
     }
 }
开发者ID:nyeholt,项目名称:silverstripe-eventlocations,代码行数:8,代码来源:LocationDetailsExtension.php

示例7: render

 /**
  * Render a default template of results.
  * Note: You must have functions "AutoCompleteTitle()" and "AutoCompleteSummary"
  * defined on the returned objects.
  * @param DataObjectSet $results The results to render in the autocomplete box
  * @return SSViewer
  */
 public static function render($results)
 {
     if (!$results) {
         return false;
     }
     $template = new SSViewer('AutoComplete_default');
     return $template->process(new ArrayData(array('Results' => $results)));
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:15,代码来源:AutoCompleteField.php

示例8: ContactFormFunction

 public static function ContactFormFunction()
 {
     $template = new SSViewer('ContactTemplateProvider');
     $controller = new ContactController();
     $form = $controller->ContactForm();
     // a little bit all over the show but to ensure a slightly easier upgrade for users
     // return back the same variables as previously done in comments
     return $template->process(new ArrayData(array('AddContactForm' => $form, 'SuccessMessage' => $controller->SuccessMessage())));
 }
开发者ID:helpfulrobot,项目名称:thomaspaulson-sliverstripe-contactform,代码行数:9,代码来源:ContactTemplateProvider.php

示例9: SubscribeLink

 /**
  * print subscribe/unsubscribe link
  */
 public function SubscribeLink()
 {
     //Requirements::css('forum_subscribe/css/style.css');
     $interface = new SSViewer('ForumSubscribe');
     $controller = new SubscribeController();
     $loggedIn = Member::currentUser() ? true : false;
     $back_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false;
     return $interface->process(new ArrayData(array('LoggedIn' => $loggedIn, 'Subscribed' => $this->IsSubscribed(), 'Parent' => $this->owner, 'SubscribeLink' => $controller->Link('subscribe/' . $this->owner->ID), 'UnSubscribeLink' => $controller->Link('unsubscribe/' . $this->owner->ID), 'Settings' => $controller->Link('settings') . '?RedirectURL=' . urlencode($back_url))));
 }
开发者ID:liquidedge,项目名称:forum_subscribe,代码行数:12,代码来源:SubscribeExtension.php

示例10: forPDF

 /**
  * Render the object using SSViewer
  * @return string
  */
 public function forPDF($variables = array())
 {
     Config::nest();
     Config::inst()->update('Director', 'alternate_base_url', static::get_render_host());
     $file = $this->owner->getPDFTemplate();
     $viewer = new SSViewer($file);
     $output = $viewer->process($this->owner, $variables);
     Config::unnest();
     return $output;
 }
开发者ID:betterbrief,项目名称:silverstripe-pdf,代码行数:14,代码来源:PDFExtension.php

示例11: parse

 public static function parse($arguments, $content = null, $parser = null)
 {
     if (!array_key_exists('repo', $arguments) || empty($arguments['repo']) || strpos($arguments['repo'], '/') <= 0) {
         return '<p><i>GitHub repository undefined</i></p>';
     }
     //Get Config
     $config = Config::inst()->forClass('GitHubShortCode');
     $obj = new ViewableData();
     //Add the Respository Setting
     $obj->Repository = $arguments['repo'];
     //Add Layout
     if (array_key_exists('layout', $arguments) && ($arguments['layout'] == 'inline' || $arguments['layout'] == 'stacked')) {
         $obj->Layout = $arguments['layout'];
     } else {
         $obj->Layout = 'inline';
     }
     //Add the button config
     if (array_key_exists('show', $arguments) && ($arguments['show'] == 'both' || $arguments['show'] == 'stars' || $arguments['show'] == 'forks')) {
         $obj->ShowButton = $arguments['show'];
     } else {
         $obj->ShowButton = 'both';
     }
     //Retrieve Stats
     SS_Cache::set_cache_lifetime('GitHubShortCode', $config->CacheTime);
     $cacheKey = md5('GitHubShortCode_' . $arguments['repo']);
     $cache = SS_Cache::factory('GitHubShortCode');
     $cachedData = $cache->load($cacheKey);
     if ($cachedData == null) {
         $response = self::getFromAPI($arguments['repo'], $config);
         //Verify a 200, if not say the repo errored out and cache false
         if (empty($response) || $response === false || !property_exists($response, 'watchers') || !property_exists($response, 'forks')) {
             $cachedData = array('stargazers' => 'N/A', 'forks' => 'N/A');
         } else {
             if ($config->UseShortHandNumbers == true) {
                 $stargazers = self::shortHandNumber($response->stargazers_count);
                 $forks = self::shortHandNumber($response->forks);
             } else {
                 $stargazers = number_format($response->stargazers_count);
                 $forks = number_format($response->forks);
             }
             $cachedData = array('stargazers' => $stargazers, 'forks' => $forks);
         }
         //Cache response to file system
         $cache->save(serialize($cachedData), $cacheKey);
     } else {
         $cachedData = unserialize($cachedData);
     }
     $obj->Stargazers = $cachedData['stargazers'];
     $obj->Forks = $cachedData['forks'];
     //Init ss viewer and render
     Requirements::css(GITHUBSHORTCODE_BASE . '/css/GitHubButtons.css');
     $ssViewer = new SSViewer('GitHubButtons');
     return $ssViewer->process($obj);
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-githubshortcode,代码行数:54,代码来源:GitHubShortCode.php

示例12: checkMaintenance

 public function checkMaintenance()
 {
     $checkHomeForMaintenance = SiteConfig::current_site_config();
     if ($checkHomeForMaintenance->Maintenance == 1) {
         if ($this->owner->URLSegment != 'Security') {
             Requirements::clear();
             $view = new SSViewer(array('MaintenanceView'));
             echo $view->process(_t('Maintenance.MESSAGE', "Site under maintenance"));
             exit;
         }
     }
 }
开发者ID:helpfulrobot,项目名称:dospuntocero-litecms,代码行数:12,代码来源:LiteCMSMaintenance.php

示例13: IconShortCodeHandler

 public static function IconShortCodeHandler($arguments, $caption = null, $parser = null)
 {
     $customise = array();
     /*** SET DEFAULTS ***/
     $customise['type'] = 'fa-check';
     //overide the defaults with the arguments supplied
     $customise = array_merge($customise, $arguments);
     //get our Sched template
     $template = new SSViewer('Icon');
     //return the customized template
     return $template->process(new ArrayData($customise));
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:12,代码来源:Page.php

示例14: PerformantBreadcrumbs

 /**
  * Return a breadcrumb trail to this page. Excludes "hidden" pages (with ShowInMenus=0) by default.
  *
  * @param int         $maxDepth The maximum depth to traverse.
  * @param bool        $unlinked Do not make page names links
  * @param bool|string $stopAtPageType ClassName of a page to stop the upwards traversal.
  * @param bool        $showHidden Include pages marked with the attribute ShowInMenus = 0
  * @return HTMLText The breadcrumb trail.
  */
 public function PerformantBreadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false)
 {
     $page = $this->asDataNode();
     $pages = array();
     while ($page && (!$maxDepth || count($pages) < $maxDepth) && (!$stopAtPageType || $page->ClassName != $stopAtPageType)) {
         if ($showHidden || $page->ShowInMenus || $page->ID == $this->ID) {
             $pages[] = $page;
         }
         $page = $page->getParent();
     }
     $template = new SSViewer('BreadcrumbsTemplate');
     return $template->process($this->customise(new ArrayData(array('Pages' => new ArrayList(array_reverse($pages))))));
 }
开发者ID:nyeholt,项目名称:silverstripe-performant,代码行数:22,代码来源:PerformantPage.php

示例15: parse

 public static function parse($arguments, $content = null, $parser = null)
 {
     if (!array_key_exists('package', $arguments) || empty($arguments['package']) || strpos($arguments['package'], '/') <= 0) {
         return '<p><i>Packagist package undefined</i></p>';
     }
     //Get Config
     $config = Config::inst()->forClass('PackagistShortCode');
     $obj = new ViewableData();
     //Add the Respository Setting
     $obj->Package = $arguments['package'];
     //Add the button config
     if (array_key_exists('mode', $arguments) && ($arguments['mode'] == 'total' || $arguments['mode'] == 'monthly' || $arguments['mode'] == 'daily')) {
         $obj->DisplayMode = $arguments['mode'];
     } else {
         $obj->DisplayMode = 'total';
     }
     //Retrieve Stats
     SS_Cache::set_cache_lifetime('PackagistShortCode', $config->CacheTime);
     $cacheKey = md5('packagistshortcode_' . $arguments['package']);
     $cache = SS_Cache::factory('PackagistShortCode');
     $cachedData = $cache->load($cacheKey);
     if ($cachedData == null) {
         $response = self::getFromAPI($arguments['package']);
         //Verify a 200, if not say the repo errored out and cache false
         if (empty($response) || $response === false || !property_exists($response, 'package')) {
             $cachedData = array('total' => 'N/A', 'monthly' => 'N/A', 'daily' => 'N/A');
         } else {
             if ($config->UseShortHandNumbers == true) {
                 $totalDownloads = self::shortHandNumber($response->package->downloads->total);
                 $monthlyDownloads = self::shortHandNumber($response->package->downloads->monthly);
                 $dailyDownloads = self::shortHandNumber($response->package->downloads->daily);
             } else {
                 $totalDownloads = number_format($response->package->downloads->total);
                 $monthlyDownloads = number_format($response->package->downloads->monthly);
                 $dailyDownloads = number_format($response->package->downloads->daily);
             }
             $cachedData = array('total' => $totalDownloads, 'monthly' => $monthlyDownloads, 'daily' => $dailyDownloads);
         }
         //Cache response to file system
         $cache->save(serialize($cachedData), $cacheKey);
     } else {
         $cachedData = unserialize($cachedData);
     }
     $obj->TotalDownloads = $cachedData['total'];
     $obj->MonthlyDownloads = $cachedData['monthly'];
     $obj->DailyDownloads = $cachedData['daily'];
     //Init ss viewer and render
     Requirements::css(PACKAGISTSHORTCODE_BASE . '/css/PackagistButton.css');
     $ssViewer = new SSViewer('PackagistButton');
     return $ssViewer->process($obj);
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-packagistshortcode,代码行数:51,代码来源:PackagistShortCode.php


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