本文整理汇总了PHP中ViewableData::customise方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewableData::customise方法的具体用法?PHP ViewableData::customise怎么用?PHP ViewableData::customise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewableData
的用法示例。
在下文中一共展示了ViewableData::customise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templateData
/**
* @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);
}
示例2: execute
/**
* 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;
}
示例3: execute
/**
* 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;
}
示例4: execute
/**
* 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;
}
示例5: execute
/**
* 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;
}
示例6: execute
/**
* 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;
}
示例7: execute
/**
* 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: ResponsiveImage
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');
}
示例9: VersionsForm
/**
* 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: VersionsForm
/**
* @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: OrderDetailTable
/**
* Returns the order positions, shipping method, payment method etc. as
* HTML table.
*
* @return string
*
* @author Sascha Koehler <skoehler@pixeltricks.de>
* @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: customise
function customise($data)
{
if (is_array($data)) {
$this->extraData = array_merge($this->extraData, $data);
return $this;
} else {
return parent::customise($data);
}
}
示例13: printall
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: CustomHtmlFormErrorMessages
/**
* returns error message as HTML text
*
* @param string $template optional; rendering template's name
*
* @return string
*
* @author Sebastian Diel <sdiel@pixeltricks.de>,
* Sascha Koehler <skoehler@pixeltricks.de>
* @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;
}
示例15: doSendEmailToAdministrator
/**
* 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();
}