本文整理汇总了PHP中SSViewer类的典型用法代码示例。如果您正苦于以下问题:PHP SSViewer类的具体用法?PHP SSViewer怎么用?PHP SSViewer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SSViewer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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
示例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: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例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: 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
示例13: 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
示例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
示例16: createSlideshow
/**
* Only works on a functional newsrecord!
* This one isn't global, only works if controller is a NHP :D
* @param array $arguments null
* @return String Parsed for template.
*/
public static function createSlideshow($arguments)
{
if (Controller::curr() instanceof NewsHolderPage_Controller && ($record = Controller::curr()->getNews())) {
$SiteConfig = SiteConfig::current_site_config();
if ($SiteConfig->SlideshowInitial) {
$template = 'NewsSlideShowFirst';
} else {
$template = 'NewsSlideShowAll';
}
$record->Image = $record->SlideshowImages()->sort('SortOrder ASC');
$template = new SSViewer($template);
return $template->process($record);
}
}
开发者ID:MilesSummers,项目名称:silverstripe-newsmodule,代码行数:20,代码来源:ExtraShorctodeParser.php
示例17: run
/**
* @inheritdoc
*/
public function run($request)
{
/* Get the protocol and host */
list($protocol, $host) = explode('://', Director::absoluteBaseURL());
$host = trim($host, '/\\');
try {
/* Flush via SSViewer, this is a clean flush */
echo 'Flushing SSViewer caches<br />';
SSViewer::flush_template_cache();
/* Remove the entire cache directory forcefully. Hard, unclean flush */
echo 'Removing temp folder ' . TEMP_FOLDER . '<br />';
exec('rm -rf ' . TEMP_FOLDER);
if (!file_exists(TEMP_FOLDER)) {
/* Show a success-message if the TEMP_FOLDER is gone */
echo 'Succesfully purged the temporary folder. A rebuild of caches is necessary now.<br />';
}
/* Flush Varnish. If it isn't available, this _might_ crash. Previous statements have been executed though */
echo "Flushing Varnish cache for host {$host}<br />";
exec('flushvarnish -h ' . $host);
/* Be friendly to the user */
echo 'Done clearing caches, please reload your site: <a href="' . Director::absoluteBaseURL() . '">here</a><br />';
echo 'Please note, all protocols have the same cache, so not only ' . $protocol . 'is cleared';
} catch (Exception $e) {
/* When boom, error out */
echo 'Error while clearing caches: ' . $e->getMessage();
}
}
开发者ID:silverstripe-europe-meetup,项目名称:website-2015,代码行数:30,代码来源:FlushCaches.php
示例18: onBeforeSecurityLogin
/**
* Sets the theme to the current site theme
**/
function onBeforeSecurityLogin()
{
$site = Multisites::inst()->getCurrentSite();
if ($site && $site->Theme) {
SSViewer::set_theme($site->Theme);
}
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:10,代码来源:MultisitesSecurityExtension.php
示例19: BlockArea
/**
* Called from templates to get rendered blocks for the given area
* @param string $area
* @param integer $limit Limit the items to this number, or null for no limit
*/
public function BlockArea($area, $limit = null)
{
if ($this->owner->ID <= 0) {
return;
}
// blocks break on fake pages ie Security/login
$list = $this->getBlockList($area);
foreach ($list as $block) {
if (!$block->canView()) {
$list->remove($block);
}
}
if ($limit !== null) {
$list = $list->limit($limit);
}
$data['BlockArea'] = $list;
$data['AreaID'] = $area;
$data = $this->owner->customise($data);
$template[] = 'BlockArea_' . $area;
if (SSViewer::hasTemplate($template)) {
return $data->renderWith($template);
} else {
return $data->renderWith('BlockArea');
}
}
开发者ID:lilireece,项目名称:silverstripe-blocks,代码行数:30,代码来源:BlocksSiteTreeExtension.php
示例20: init
public function init()
{
parent::init();
$themeDir = SSViewer::get_theme_folder();
Requirements::javascript('framework/thirdparty/jquery/jquery.js');
if (Locator::getLocations()) {
Requirements::javascript('http://maps.google.com/maps/api/js?sensor=false');
Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
}
Requirements::css('locator/css/map.css');
$featured = Locator::getLocations(array('Featured' => 1))->count() > 0 ? 'featuredLocations: true' : 'featuredLocations: false';
// map config based on user input in Settings tab
// AutoGeocode or Full Map
$load = $this->data()->AutoGeocode ? 'autoGeocode: true, fullMapStart: false,' : 'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,';
$base = Director::baseFolder();
$themePath = $base . '/' . $themeDir;
$listTemplatePath = file_exists($themePath . '/templates/location-list-description.html') ? $themeDir . '/templates/location-list-description.html' : 'locator/templates/location-list-description.html';
$infowindowTemplatePath = file_exists($themePath . '/templates/infowindow-description.html') ? $themeDir . '/templates/infowindow-description.html' : 'locator/templates/infowindow-description.html';
// in page or modal
$modal = $this->data()->ModalWindow ? 'modalWindow: true' : 'modalWindow: false';
$kilometer = $this->data()->Unit == 'km' ? 'lengthUnit: "km"' : 'lengthUnit: "m"';
$link = $this->Link() . 'xml.xml';
// init map
if (Locator::getLocations()) {
Requirements::customScript("\n \$(function(\$) {\n \$('#map-container').storeLocator({\n " . $load . "\n dataLocation: '" . $link . "',\n listTemplatePath: '" . $listTemplatePath . "',\n infowindowTemplatePath: '" . $infowindowTemplatePath . "',\n originMarker: true,\n " . $modal . ',
' . $featured . ",\n slideMap: false,\n zoomLevel: 0,\n distanceAlert: 120,\n formID: 'Form_LocationSearch',\n inputID: 'Form_LocationSearch_address',\n categoryID: 'Form_LocationSearch_category',\n distanceAlert: -1,\n " . $kilometer . '
});
});
');
}
}
开发者ID:jeffwhitfield,项目名称:silverstripe-locator,代码行数:32,代码来源:Locator.php
注:本文中的SSViewer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论