/**
  * @return ViewableData_Customised
  */
 protected function templateData()
 {
     // If no data is defined, set some default
     if (!$this->template_data) {
         $this->template_data = $this->customise(array('IsEmail' => true));
     }
     // Infos set by Silverstripe
     $originalInfos = array("To" => $this->to, "Cc" => $this->cc, "Bcc" => $this->bcc, "From" => $this->from, "Subject" => $this->subject, "Body" => $this->body, "BaseURL" => $this->BaseURL(), "IsEmail" => true);
     // Infos injected from the models
     $modelsInfos = array('CurrentMember' => Member::currentUser(), 'CurrentSiteConfig' => SiteConfig::current_site_config(), 'CurrentController' => Controller::curr());
     if ($this->to_member) {
         $modelsInfos['Recipient'] = $this->to_member;
     } else {
         $member = new Member();
         $member->Email = $this->to;
         $modelsInfos['Recipient'] = $member;
     }
     if ($this->from_member) {
         $modelsInfos['Sender'] = $this->from_member;
     } else {
         $member = new Member();
         $member->Email = $this->from;
         $modelsInfos['Sender'] = $member;
     }
     // Template specific variables
     $templatesInfos = array('Image' => $this->image, 'Callout' => $this->callout, 'Sidebar' => $this->sidebar);
     // Theme options
     $themesInfos = array('HeaderColor' => $this->header_color, 'HeaderFontColor' => $this->header_font_color, 'FooterColor' => $this->footer_color, 'FooterFontColor' => $this->footer_font_color, 'PanelColor' => $this->panel_color, 'PanelBorderColor' => $this->panel_border_color, 'PanelFontColor' => $this->panel_font_color);
     $allInfos = array_merge($modelsInfos, $templatesInfos, $themesInfos, $originalInfos);
     return $this->template_data->customise($allInfos);
 }
 /**
  * Command execute
  *
  * Perform the request command. Creates a XML request based on the given
  * XML request parameter and the search term. This request is used to create
  * OGC compliant search requests and can be extended.
  *
  * @return string - XML CSW requests which can be used to access an OGC CSW 2.0.1 web service.
  */
 public function execute()
 {
     $data = $this->getParameters();
     if (!isset($data['startPosition'])) {
         $data['startPosition'] = 0;
     }
     if (!isset($data['maxRecords'])) {
         $data['maxRecords'] = 10;
     }
     if (!isset($data['searchterm'])) {
         throw new CreateRequestCommand_Exception('Exception: Undefined searchTerm');
     }
     if (!isset($data['requestxml'])) {
         throw new CreateRequestCommand_Exception('Exception: Undefined requestxml');
     }
     if (!isset($data['sortBy'])) {
         $data['sortBy'] = 'title';
     }
     if (!isset($data['sortOrder'])) {
         $data['sortOrder'] = 'asc';
     }
     if (!isset($data['bboxUpper'])) {
         $data['bboxUpper'] = '';
     }
     if (!isset($data['bboxLower'])) {
         $data['bboxUpper'] = '';
         $data['bboxLower'] = '';
     }
     $requestXML = $data['requestxml'];
     $searchTerm = $data['searchterm'];
     $startPosition = $data['startPosition'];
     $maxRecords = $data['maxRecords'];
     $sortBy = $data['sortBy'];
     $sortOrder = $data['sortOrder'];
     $bboxUpper = $data['bboxUpper'];
     $bboxLower = $data['bboxLower'];
     $WordsToSearchFor = array();
     if ($searchTerm) {
         // if we have a searchterm
         // split it by any number of commas or space characters,
         // which include " ", \r, \t, \n and \f
         $WordsToSearchFor = preg_split("/[\\s,]+/", $searchTerm, -1, PREG_SPLIT_NO_EMPTY);
     }
     $DOB = new ArrayList();
     foreach ($WordsToSearchFor as $word) {
         $DOB->push(new ArrayData(array("word" => $word)));
     }
     // retrieve as Dublin-Core/ISO 19139 metadata schema
     $obj = new ViewableData();
     $fields = array("searchTerm" => $searchTerm, "startPosition" => $startPosition, "maxRecords" => $maxRecords, "WordsToSearchFor" => $DOB, "sortBy" => $sortBy, "sortOrder" => $sortOrder, "bboxUpper" => $bboxUpper, "bboxLower" => $bboxLower);
     $obj->customise($fields);
     // render XML request
     $requestXML = $obj->renderWith($requestXML);
     return $requestXML->value;
 }
 /**
  * Command execute
  *
  * Perform the request command. Creates a XML request based on the given
  * XML request parameter and fileIdentifier. This request is used to create
  * OGC compliant search requests and can be extended.
  *
  * @return string - XML CSW requests which can be used to access an OGC CSW 2.0.1 web service.
  */
 public function execute()
 {
     $data = $this->getParameters();
     $requestXML = $data['requestxml'];
     $fileIdentifier = $data['fileIdentifier'];
     // retrieve as Dublin-Core metadata schema
     $obj = new ViewableData();
     $fields = array("fileIdentifier" => $fileIdentifier);
     $obj->customise($fields);
     $data = $obj->renderWith($requestXML);
     return $data->value;
 }
 /**
  * Command execute
  *
  * Perform the request command. Creates a XML request based on the given
  * XML request parameter and the metadata data. This request is used to insert new
  * Metadata records into GeoNetwork.
  */
 public function execute()
 {
     $data = $this->getParameters();
     $fileIdentifier = $data['MDMetadata']->fileIdentifier;
     $cmd = $this->getController()->getCommand(self::$schema_command_name, $data);
     $xml = $cmd->execute();
     $requestXML = self::$templatename;
     $MDMetadataXML = $xml;
     $obj = new ViewableData();
     $obj->customise(array("MDMetadataXML" => $MDMetadataXML, "fileIdentifier" => $fileIdentifier));
     $data = $obj->renderWith($requestXML);
     return $data;
 }
 /**
  * Command execute
  *
  * Perform the request command. Creates a XML request based on the given
  * XML request parameter and the metadata data. This request is used to insert new
  * Metadata records into GeoNetwork.
  */
 public function execute()
 {
     $data = $this->getParameters();
     // generate xml file
     $cmd = $this->getController()->getCommand(self::$schema_name, $data);
     $xml = $cmd->execute();
     $requestXML = self::get_template_name();
     $MDMetadataXML = $xml;
     $obj = new ViewableData();
     $obj->customise(array("MDMetadataXML" => $MDMetadataXML));
     $data = $obj->renderWith($requestXML);
     return $data;
 }
 /**
  * Command execute
  *
  * Generate the ISO19139 metadata XML and return it.
  */
 public function execute()
 {
     $data = $this->getParameters();
     if (!isset($data['MDMetadata'])) {
         throw new GenerateISO19139XMLCommand_Exception("No data-object given");
     }
     $MDMetadata = $data['MDMetadata'];
     if (!is_a($MDMetadata, 'MDMetadata')) {
         throw new GenerateISO19139XMLCommand_Exception("data-object is not a MDMetadata");
     }
     $requestXML = self::$templatename;
     $obj = new ViewableData();
     $obj->customise($MDMetadata);
     $data = $obj->renderWith($requestXML);
     return $data;
 }
 /**
  * Command execute
  *
  * This method performs the action to parse an OGC CSW XML response and
  * create the MDMetadata structure.
  *
  * @throws ParseXMLCommand_Exception
  *
  * @return DataObjectSet
  */
 public function execute()
 {
     $data = $this->getParameters();
     // Throw exception on null-xml
     if (!isset($data['xml'])) {
         throw new ParseXMLCommand_Exception("Expected an XML string, but there is nothing given.");
     }
     // Return an empty DatasetObject with the defaults for paging if xml is empty
     if ($data['xml'] == '') {
         $result = new ViewableData();
         $resultItems = new ArrayList();
         return $result->customise(array('Items' => $resultItems, 'nextRecord' => 0, 'numberOfRecordsMatched' => 0, 'numberOfRecordsReturned' => 0));
     }
     $result = $this->parseXML($data['xml']);
     return $result;
 }
Пример #8
0
 public function ResponsiveImage($width, $height, $crop = 'fill', $gravity = 'faces')
 {
     $sizes = Config::inst()->get('CloudinaryImage', 'sizes');
     $bFirst = true;
     $base = $sizes[0];
     foreach ($sizes as $size) {
         if ($size >= $base && $size <= $width) {
             $base = $size;
         }
     }
     CloudinaryFile::get_api();
     $imageSizes = new ArrayList();
     $counter = 1;
     foreach ($sizes as $size) {
         $sizeWidth = (int) ($width / $base * $size);
         $sizeHeight = (int) ($height / $width * $sizeWidth);
         $options = array('width' => $sizeWidth, 'height' => $sizeHeight, 'crop' => $crop, 'quality' => 70, 'gravity' => $gravity, 'secure_distribution' => true, 'secure' => true);
         $cloudinaryID = CloudinaryFile::get_public_id($this->CloudinaryURL);
         $imgURL = Cloudinary::cloudinary_url($cloudinaryID . '.' . $this->Format, $options);
         $bLast = $counter == count($sizes) || $base <= $size;
         if ($bFirst) {
             $imageSizes->push(new ArrayData(array('URL' => $imgURL, 'MediaQuery' => '(max-width: ' . $sizes[1] . 'px)')));
         } else {
             if ($bLast) {
                 $imageSizes->push(new ArrayData(array('URL' => $imgURL, 'MediaQuery' => '(min-width: ' . ($size + 1) . 'px)')));
                 break;
             } else {
                 $imageSizes->push(new ArrayData(array('URL' => $imgURL, 'MediaQuery' => '(min-width: ' . ($size + 1) . 'px) and (max-width: ' . $sizes[$counter] . 'px)')));
             }
         }
         $bFirst = false;
         $counter += 1;
     }
     $vd = new ViewableData();
     return $vd->customise(new ArrayData(array('Options' => $imageSizes, 'Title' => $this->Title, 'Width' => $width, 'Height' => $height)))->renderWith('ResponsiveImage');
 }
 /**
  * Version select form. Main interface between selecting versions to view 
  * and comparing multiple versions.
  *  
  * Because we can reload the page directly to a compare view (history/compare/1/2/3)
  * this form has to adapt to those parameters as well. 
  *
  * @return Form
  */
 function VersionsForm()
 {
     $id = $this->currentPageID();
     $page = $this->getRecord($id);
     $versionsHtml = '';
     $action = $this->request->param('Action');
     $versionID = $this->request->param('VersionID');
     $otherVersionID = $this->request->param('OtherVersionID');
     $showUnpublishedChecked = 0;
     $compareModeChecked = $action == "compare";
     if ($page) {
         $versions = $page->allVersions();
         $versionID = !$versionID ? $page->Version : $versionID;
         if ($versions) {
             foreach ($versions as $k => $version) {
                 $active = false;
                 if ($version->Version == $versionID || $version->Version == $otherVersionID) {
                     $active = true;
                     if (!$version->WasPublished) {
                         $showUnpublishedChecked = 1;
                     }
                 }
                 $version->Active = $active;
             }
         }
         $vd = new ViewableData();
         $versionsHtml = $vd->customise(array('Versions' => $versions))->renderWith('CMSPageHistoryController_versions');
     }
     $fields = new FieldList(new CheckboxField('ShowUnpublished', _t('CMSPageHistoryController.SHOWUNPUBLISHED', 'Show unpublished versions'), $showUnpublishedChecked), new CheckboxField('CompareMode', _t('CMSPageHistoryController.COMPAREMODE', 'Compare mode (select two)'), $compareModeChecked), new LiteralField('VersionsHtml', $versionsHtml), $hiddenID = new HiddenField('ID', false, ""));
     $actions = new FieldList(new FormAction('doCompare', _t('CMSPageHistoryController.COMPAREVERSIONS', 'Compare Versions')), new FormAction('doShowVersion', _t('CMSPageHistoryController.SHOWVERSION', 'Show Version')));
     // Use <button> to allow full jQuery UI styling
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     $form = new Form($this, 'VersionsForm', $fields, $actions);
     $form->loadDataFrom($this->request->requestVars());
     $hiddenID->setValue($id);
     $form->unsetValidator();
     $form->addExtraClass('cms-versions-form')->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));
     return $form;
 }
Пример #10
0
 /**
  * @return Form
  */
 function VersionsForm()
 {
     $pageID = $this->request->requestVar('ID') ? $this->request->requestVar('ID') : $this->currentPageID();
     $page = $this->getRecord($pageID);
     if ($page) {
         $versions = $page->allVersions($this->request->requestVar('ShowUnpublished') ? "" : "\"SiteTree\".\"WasPublished\" = 1");
         // inject link to cms
         if ($versions) {
             foreach ($versions as $k => $version) {
                 $version->CMSLink = sprintf('%s/%s/%s', $this->Link('getversion'), $version->ID, $version->Version);
             }
         }
         $vd = new ViewableData();
         $versionsHtml = $vd->customise(array('Versions' => $versions))->renderWith('CMSMain_versions');
     } else {
         $versionsHtml = '';
     }
     $form = new Form($this, 'VersionsForm', new FieldSet(new CheckboxField('ShowUnpublished', _t('CMSMain_left.ss.SHOWUNPUB', 'Show unpublished versions')), new LiteralField('VersionsHtml', $versionsHtml), new HiddenField('ID', false, $pageID), new HiddenField('Locale', false, $this->Locale)), new FieldSet(new FormAction('versions', _t('CMSMain.BTNREFRESH', 'Refresh')), new FormAction('compareversions', _t('CMSMain.BTNCOMPAREVERSIONS', 'Compare Versions'))));
     $form->loadDataFrom($this->request->requestVars());
     $form->setFormMethod('GET');
     $form->unsetValidator();
     return $form;
 }
Пример #11
0
 /**
  * Returns the order positions, shipping method, payment method etc. as
  * HTML table.
  * 
  * @return string
  *
  * @author Sascha Koehler <*****@*****.**>
  * @since 25.01.2012
  */
 public function OrderDetailTable()
 {
     $viewableData = new ViewableData();
     $template = '';
     if ($this->IsPriceTypeGross()) {
         $template = $viewableData->customise($this)->renderWith('SilvercartOrderDetailsGross');
     } else {
         $template = $viewableData->customise($this)->renderWith('SilvercartOrderDetailsNet');
     }
     return $template;
 }
Пример #12
0
 function customise($data)
 {
     if (is_array($data)) {
         $this->extraData = array_merge($this->extraData, $data);
         return $this;
     } else {
         return parent::customise($data);
     }
 }
Пример #13
0
 function printall()
 {
     Requirements::clear();
     Requirements::css('cms/css/typography.css');
     Requirements::css('cms/css/cms_right.css');
     Requirements::css('sapphire/css/TableListField_print.css');
     $vd = new ViewableData();
     return $vd->customise(array('Content' => $this->customise(array('Print' => true))->renderWith($this->template)))->renderWith('TableListField_printable');
 }
Пример #14
0
 /**
  * returns error message as HTML text
  *
  * @param string $template optional; rendering template's name
  *
  * @return string
  *
  * @author Sebastian Diel <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 13.01.2015
  */
 public function CustomHtmlFormErrorMessages($template = 'CustomHtmlFormErrorMessages')
 {
     global $project;
     $data = array('errorMessages' => new ArrayList($this->errorMessages), 'messages' => new ArrayList($this->messages));
     $templates = array($project . '/templates/forms/' . $template . '.ss', $project . '/templates/Layout/' . $template . '.ss', THEMES_DIR . '/' . SSViewer::current_theme() . '_customhtmlform/templates/forms/' . $template . '.ss', THEMES_DIR . '/' . SSViewer::current_theme() . '_customhtmlform/templates/Layout/' . $template . '.ss', THEMES_DIR . '/' . SSViewer::current_theme() . '/templates/forms/' . $template . '.ss', THEMES_DIR . '/' . SSViewer::current_theme() . '/templates/Layout/' . $template . '.ss', 'customhtmlform/templates/forms/' . $template . '.ss');
     foreach ($templates as $templatePath) {
         if (Director::fileExists($templatePath)) {
             $templatePathRel = '/' . $templatePath;
             break;
         }
     }
     $templatePathAbs = Director::baseFolder() . $templatePathRel;
     $viewableObj = new ViewableData();
     $output = $viewableObj->customise($data)->renderWith($templatePathAbs);
     return $output;
 }
 /**
  *	doSendEmailToAdministrator(array $values, string $template)
  *
  * @param 	array $values is used for rendering the email via $template
  *			and some fields for the email itself, which are:
  *			'SendEmailSubject' is the subject of the mail and defaults to $template
  *			'SendEmailFrom' is the email address shown in the FROM field of the email defaults to the 
  *							admin email-address of the silverstripe installation
  *  		'SendEmailTo' is the email-address where the mail is sended to (mandatory)
  * @param	string $template is the name of the template to be used for rendering the email
  *			
  * @return 	boolean true on success, otherwise false 
  */
 function doSendEmailToAdministrator($customFields, $templateName = 'ConfirmationEMail')
 {
     //checks
     if (!isset($customFields['SendEmailSubject']) || $customFields['SendEmailSubject'] == "") {
         $customFields['SendEmailSubject'] = $templateName;
     }
     $emailObj = new ViewableData();
     $emailObj->customise($customFields);
     // Render the text
     $emailText = $emailObj->renderWith($templateName);
     // Send an email to the administrator
     $email = new Email($customFields['SendEmailFrom'], $customFields['SendEmailTo'], $customFields['SendEmailSubject'], $emailText);
     return $email->send();
 }
 public function renderClusterInformationBubble($stationIDList, $extraParam = null, $templateName = '')
 {
     // multiple stations, render list
     $obj = new ArrayList();
     $obj = $this->getFeature($stationIDList, $extraParam);
     foreach ($obj as $item) {
         $item->classname = "content_" . str_replace('.', '_', $item->FeatureID);
     }
     $data = new ArrayData(array("items" => $obj, "count" => $obj->Count()));
     if ($this->UseTemplateForPopupWindow) {
         $template = $this->Popup_ClusterInformation;
         $viewer = SSViewer::fromString($template);
         return $viewer->process($data);
     }
     // @to2: deprecate this
     $listItemTemplate = 'Station: $FeatureID';
     if ($this->ClusterAttributes) {
         $listItemTemplate = $this->ClusterAttributes;
     }
     // 1st partial template: create template for content area
     $template = '<% loop items %>';
     $template .= sprintf('<li><a onClick="multipleStationSelect(\'$FeatureID\');return false;">%s</a></li><div class=\'$classname\'></div>', $listItemTemplate);
     $template .= '<%  end_loop %>';
     // 2nd partial template: create template for header area
     $header = 'There are $count Items.';
     if ($this->ClusterPopupHeader) {
         $header = $this->ClusterPopupHeader;
     }
     // render partial tempates
     $viewer = SSViewer::fromString($header);
     $clusterPopupHeader = $viewer->process($data);
     $viewer = SSViewer::fromString($template);
     $stationListTemplate = $viewer->process($data);
     // render combined tempate
     $out = new ViewableData();
     $out->customise(array("stationList" => $stationListTemplate, "PopupHeader" => $clusterPopupHeader));
     return $out->renderWith('MapPopup_List');
 }