/**
  * 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));
 }
 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));
 }
 /**
  * 
  * @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;
 }
 /**
  * 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))))));
 }
 /**
  * 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));
 }
 public function augmentSidebarContent(&$content)
 {
     if ($this->owner->DateTime()->LocationID) {
         $location = $this->owner->DateTime()->Location();
         $viewer = new SSViewer('EventLocationSidebarContent');
         $content .= $viewer->process($location);
     }
 }
 /**
  * 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)));
 }
 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())));
 }
 /**
  * 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))));
 }
예제 #10
0
 /**
  * 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;
 }
 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);
 }
 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;
         }
     }
 }
예제 #13
0
 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));
 }
 /**
  * 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))))));
 }
 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);
 }
 /**
  * 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);
     }
 }
 /**
  * Parse the shortcode and render as a string, probably with a template
  * @param array $arguments the list of attributes of the shortcode
  * @param string $content the shortcode content
  * @param ShortcodeParser $parser the ShortcodeParser instance
  * @param string $shortcode the raw shortcode being parsed
  * @return String
  **/
 public static function parse_shortcode($arguments, $content, $parser, $shortcode)
 {
     if (empty($arguments['id'])) {
         return;
     }
     if (array_key_exists('id', $arguments) && $arguments['id']) {
         $explanation = Explanation::get()->byID($arguments['id']);
     }
     if (!$explanation) {
         return;
     }
     if (array_key_exists('title', $arguments) && $arguments['title']) {
         $explanation->Title = $arguments['title'];
     }
     $template = new SSViewer('ExplanationShortcode');
     return $template->process($explanation);
 }
 public static function parse_googlestreetview($arguments, $caption = null, $parser = null)
 {
     // each of latitude, longitude and heading are required at a bare minimum
     if (!isset($arguments['latitude'])) {
         return '';
     }
     if (!isset($arguments['longitude'])) {
         return '';
     }
     if (!isset($arguments['heading'])) {
         return '';
     }
     // defaults - these can be overriden by using zoom and pitch in the shortcode
     $defaults = array('Zoom' => 1, 'Pitch' => 0);
     // ensure JavaScript for the map service is only downloaded once
     $arguments['DownloadJS'] = !MapUtil::get_map_already_rendered();
     MapUtil::set_map_already_rendered(true);
     // convert parameters to CamelCase as per standard template conventions
     $arguments['Latitude'] = $arguments['latitude'];
     $arguments['Longitude'] = $arguments['longitude'];
     $arguments['Heading'] = $arguments['heading'];
     // optional parameter caption
     if (isset($arguments['caption'])) {
         $arguments['Caption'] = $arguments['caption'];
     }
     // optional parameter pitch
     if (isset($arguments['pitch'])) {
         $arguments['Pitch'] = $arguments['pitch'];
     }
     // optional parameter zoom
     if (isset($arguments['zoom'])) {
         $arguments['Zoom'] = $arguments['zoom'];
     }
     // the id of the dom element to be used to render the street view
     $arguments['DomID'] = 'google_streetview_' . self::$gsv_ctr;
     // incrememt the counter to ensure a unique id for each map canvas
     self::$gsv_ctr++;
     // merge defaults and arguments
     $customised = array_merge($defaults, $arguments);
     // Include google maps JS at the end of the page
     Requirements::javascriptTemplate("mappable/javascript/google/streetview.google.template.js", $customised);
     //get streetview template template
     $template = new SSViewer('GoogleStreetView');
     //return the template customised with the parmameters
     return $template->process(new ArrayData($customised));
 }
 /**
  *	Parses a {@link SiteMapPage}'s shortcode
  *
  *	Sitemap css and javascript can be selected using
  *	the SiteMapPage:Themes option in the config.yml.
  *
  *	Reads from {$themename}SiteMap.ss template, falling back to
  *	default SiteMap.ss
  *
  *	@param $arguments array Arguments to the shortcode
  *  @param $content string Content of the returned link (optional)
  *  @param $parser object Specify a parser to parse the content (see {@link ShortCodeParser})
  *  @return string SiteMap template render
  */
 public static function SiteMapShortCodeHandler($arguments, $caption = null, $parser = null)
 {
     // Are we on a SiteMap page? If not, return.
     if (Controller::curr()->ClassName != "SiteMapPage") {
         return;
     }
     $theme = Config::inst()->get('SiteMapPage', 'theme');
     Requirements::css(SITEMAP3_DIR . "/themes/" . $theme . "/css/" . $theme . ".css");
     Requirements::javascript(SITEMAP3_DIR . "/themes/" . $theme . "/javascript/" . $theme . ".js");
     $data = self::getSiteMap(0);
     //Slickmap column generation etc
     $TotalColumns = count($data) - 1;
     //if (($TotalColumns - 1) < 11 ) { /* remove home page from count */
     //	$TotalColumns = $totalItems - 1;
     //} else { $slickmapWidth = "col10"; }
     $template = new SSViewer(array($theme . 'SiteMap', 'SiteMap'));
     return $template->process(new ArrayData(array('CurrentPage' => Controller::curr(), 'SiteMapTree' => $data, 'TotalColumns' => $TotalColumns)));
 }
 /**
  * Adds the part for 'download search' to the breadcrumbs. Sets the link for
  * The default action in breadcrumbs.
  *
  * @param int  $maxDepth       maximum levels
  * @param bool $unlinked       link breadcrumbs elements
  * @param bool $stopAtPageType name of PageType to stop at
  * @param bool $showHidden     show pages that will not show in menus
  * 
  * @return string
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 27.06.2011
  */
 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;
     }
     if (Controller::curr()->getAction() == 'results') {
         $title = new Text();
         $title->setValue(_t('SilvercartDownloadPageHolder.SearchResults'));
         array_unshift($pages, new ArrayData(array('MenuTitle' => $title, 'Title' => $title, 'Link' => '')));
     }
     $template = new SSViewer('BreadcrumbsTemplate');
     return $template->process($this->customise(new ArrayData(array('Pages' => new ArrayList(array_reverse($pages))))));
 }
 public static function parse_googlemap($arguments, $caption = null, $parser = null)
 {
     // each of latitude and longitude are required at a bare minimum
     if (!isset($arguments['latitude'])) {
         return '';
     }
     if (!isset($arguments['longitude'])) {
         return '';
     }
     // defaults - can be overriden by using zoom and FIXME in the shortcode
     $defaults = array('Zoom' => 5, 'MapType' => 'road');
     // ensure JavaScript for the map service is only downloaded once
     $arguments['DownloadJS'] = !MapUtil::get_map_already_rendered();
     MapUtil::set_map_already_rendered(true);
     // convert parameters to CamelCase as per standard template conventions
     $arguments['Latitude'] = $arguments['latitude'];
     $arguments['Longitude'] = $arguments['longitude'];
     // optional parameter caption
     if (isset($arguments['caption'])) {
         $arguments['Caption'] = $arguments['caption'];
     }
     if (isset($arguments['maptype'])) {
         $arguments['MapType'] = $arguments['maptype'];
     }
     // optional parameter zoom
     if (isset($arguments['zoom'])) {
         $arguments['Zoom'] = $arguments['zoom'];
     }
     // the id of the dom element to be used to render the street view
     $arguments['DomID'] = 'google_sc_map_' . self::$gsv_ctr;
     // fullscreen
     $arguments['AllowFullScreen'] = Config::inst()->get('Mappable', 'allow_full_screen');
     // incrememt the counter to ensure a unique id for each map canvas
     self::$gsv_ctr++;
     // merge defaults and arguments
     $customised = array_merge($defaults, $arguments);
     // include JavaScript to be appended at the end of the page, namely params for map rendering
     Requirements::javascriptTemplate("mappable/javascript/google/map.google.template.js", $customised);
     //get map view template and render the HTML
     $template = new SSViewer('GoogleMapShortCode');
     //return the template customised with the parmameters
     return $template->process(new ArrayData($customised));
 }
 public static function VimeoShortCodeHandler($arguments, $caption = null, $parser = null)
 {
     if (empty($arguments['id'])) {
         return false;
     }
     $customise = array();
     /*** SET DEFAULTS ***/
     $customise['VimeoID'] = $arguments['id'];
     //play the video on page load
     $customise['Autoplay'] = false;
     //set the caption
     $customise['Caption'] = $caption ? Convert::raw2xml($caption) : false;
     //set dimensions
     $customise['Width'] = 480;
     $customise['Height'] = 320;
     //overide the defaults with the arguments supplied
     $customise = array_merge($customise, $arguments);
     //get our YouTube template
     $template = new SSViewer(array('Vimeo', SHORTCODES_DIR . '/templates/Vimeo.ss'));
     return $template->process(new ArrayData($customise));
 }
 /**
  * Implements the mailto handler to protect email addresses defined via [cwsHideMailto email='xxx']
  * Uses template "cwsoft-shortcode/templates/Includes/HideMailto.ss" for output
  * 
  * @param mixed $arguments (email='*****@*****.**' subject='mail subject')
  * @param $content = null
  * @param $parser = null
  * @return processed template HideMailto.ss
  */
 public static function cwsShortCodeHideMailtoHandler($arguments, $content = null, $parser = null)
 {
     // only proceed if a valid email was defined
     $email = isset($arguments['email']) ? Convert::raw2xml(trim($arguments['email'])) : '';
     if ($email == '') {
         return;
     }
     // make sure we have a mailto link description (replace @ by (at) and . by (dot))
     $description = trim($content) == '' ? $email : Convert::raw2xml($content);
     $description = str_replace(array('@', '.'), array('(at)', '(dot)'), $description);
     // get optional mail subject and mail link description
     $subject = isset($arguments['subject']) ? Convert::raw2xml(trim($arguments['subject'])) : '';
     if ($subject == '') {
         $subject = _t('cwsShortCodeHideMailto.SUBJECT', 'Subject');
     }
     // create a random key for the caesar cipher
     $key = mt_rand(1, 30);
     // prepare data for output
     $data = array('CryptedMailto' => self::caesar_cipher('mailto:' . $email, $key), 'Subject' => rawurldecode($subject . chr(64 + $key)), 'LinkText' => $description);
     // load template and process data
     $template = new SSViewer('HideMailto');
     return $template->process(new ArrayData($data));
 }
 public static function parse_youtube($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 ***/
     $customise['YouTubeID'] = $arguments['id'];
     //play the video on page load
     $customise['autoplay'] = false;
     //set the caption
     $customise['caption'] = $caption ? Convert::raw2xml($caption) : false;
     //set dimensions
     $customise['width'] = 640;
     $customise['height'] = 385;
     //overide the defaults with the arguments supplied
     $customise = array_merge($customise, $arguments);
     //get our YouTube template
     $template = new SSViewer('YouTube');
     //return the customised template
     return $template->process(new ArrayData($customise));
 }
 public static function parse_gallery_image($arguments, $caption = null, $parser = null)
 {
     // first things first, if we dont have an ID, then we don't need to
     // go any further
     if (empty($arguments['id'])) {
         return;
     }
     $customise = array();
     $galleryImage = DataObject::get_by_id('GalleryImage', $arguments['id']);
     if (!$galleryImage) {
         return 'image not found';
     }
     $customise['Image'] = $galleryImage->Image();
     $customise['Aperture'] = $galleryImage->Aperture;
     $customise['ShutterSpeed'] = $galleryImage->ShutterSpeed;
     //set the caption
     $customise['Title'] = $galleryImage->Title;
     //overide the defaults with the arguments supplied
     $customise = array_merge($customise, $arguments);
     //get our YouTube template
     $template = new SSViewer('ShortCodeGalleryImage');
     //return the customised template
     return $template->process(new ArrayData($customise));
 }
 public function getNavActionsExtensions(&$html)
 {
     $view = new SSViewer('EditProfilePage_ICLANav');
     $html .= $view->process($this->owner);
 }
예제 #27
0
 /**
  * Execute the given template, passing it the given data.
  * Used by the <% include %> template tag to process templates.
  */
 public static function execute_template($template, $data, $arguments = null)
 {
     $v = new SSViewer($template);
     return $v->process($data, $arguments);
 }
 /**
  * Return a breadcrumb trail to this page. Excludes "hidden" pages
  * (with ShowInMenus=0). Adds extra microdata compared to
  *
  * @param int $maxDepth The maximum depth to traverse.
  * @param boolean $unlinked Do not make page names links
  * @param string $stopAtPageType ClassName of a page to stop the upwards traversal.
  * @param boolean $showHidden Include pages marked with the attribute ShowInMenus = 0
  * @return string The breadcrumb trail.
  */
 public function SeoBreadcrumbs($separator = '&raquo;', $addhome = true, $maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false)
 {
     $page = $this->owner;
     $pages = array();
     while ($page && (!$maxDepth || count($pages) < $maxDepth) && (!$stopAtPageType || $page->ClassName != $stopAtPageType)) {
         if ($showHidden || $page->ShowInMenus || $page->ID == $this->owner->ID) {
             $pages[] = $page;
         }
         $page = $page->Parent;
     }
     // add homepage;
     if ($addhome) {
         $pages[] = $this->owner->getHomepageCurrLang();
     }
     $template = new SSViewer('SeoBreadcrumbsTemplate');
     return $template->process($this->owner->customise(new ArrayData(array('BreadcrumbSeparator' => $separator, 'AddHome' => $addhome, 'Pages' => new ArrayList(array_reverse($pages))))));
 }
예제 #29
0
 /**
  * Execute the given template, passing it the given data.
  * Used by the <% include %> template tag to process templates.
  * 
  * @param string $template Template name
  * @param mixed $data Data context
  * @param array $arguments Additional arguments
  * @return string Evaluated result
  */
 public static function execute_template($template, $data, $arguments = null, $scope = null)
 {
     $v = new SSViewer($template);
     $v->includeRequirements(false);
     return $v->process($data, $arguments, $scope);
 }
예제 #30
0
 /**
  * Renders a panel containing tools which apply to the currently displayed edit form.
  * The main difference to {@link Tools()} is that the panel is displayed within
  * the element structure of the form panel (rendered through {@link EditForm}).
  * This means the panel will be loaded alongside new forms, and refreshed upon save,
  * which can mean a performance hit, depending on how complex your panel logic gets.
  * Any form fields contained in the returned markup will also be submitted with the main form,
  * which might be desired depending on the implementation details.
  * 
  * @return String HTML
  */
 public function EditFormTools()
 {
     $templates = $this->getTemplatesWithSuffix('_EditFormTools');
     if ($templates) {
         $viewer = new SSViewer($templates);
         return $viewer->process($this);
     } else {
         return false;
     }
 }