本文整理汇总了PHP中ViewableData::renderWith方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewableData::renderWith方法的具体用法?PHP ViewableData::renderWith怎么用?PHP ViewableData::renderWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewableData
的用法示例。
在下文中一共展示了ViewableData::renderWith方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parses the snippet short code
* @example [snippet id=123]
* @example [snippet id=123 version=456]
*/
public static function parse($arguments, $content = null, $parser = null)
{
//Ensure ID is pressent in the arguments
if (!array_key_exists('id', $arguments)) {
return '<p><b><i>' . _t('CodeBankShortCode.MISSING_ID_ATTRIBUTE', '_Short Code missing the id attribute') . '</i></b></p>';
}
//Fetch Snippet
$snippet = Snippet::get()->byID(intval($arguments['id']));
if (empty($snippet) || $snippet === false || $snippet->ID == 0) {
return '<p><b><i>' . _t('CodeBankShortCode.SNIPPET_NOT_FOUND', '_Snippet not found') . '</i></b></p>';
}
//Fetch Text
$snippetText = $snippet->SnippetText;
//If the version exists fetch it, and replace the text with that of the version
if (array_key_exists('version', $arguments)) {
$version = $snippet->Version(intval($arguments['version']));
if (empty($version) || $version === false || $version->ID == 0) {
$snippetText = $version->Text;
}
}
//Load CSS Requirements
Requirements::css(CB_DIR . '/javascript/external/syntaxhighlighter/themes/shCore.css');
Requirements::css(CB_DIR . '/javascript/external/syntaxhighlighter/themes/shCoreDefault.css');
Requirements::css(CB_DIR . '/javascript/external/syntaxhighlighter/themes/shThemeDefault.css');
//Load JS Requirements
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(CB_DIR . '/javascript/external/syntaxhighlighter/brushes/shCore.js');
Requirements::javascript(CB_DIR . '/javascript/external/syntaxhighlighter/brushes/' . self::getBrushName($snippet->Language()->HighlightCode) . '.js');
Requirements::javascriptTemplate(CB_DIR . '/javascript/CodeBankShortCode.template.js', array('ID' => $snippet->ID), 'snippet-highlightinit-' . $snippet->ID);
//Render the snippet
$obj = new ViewableData();
return $obj->renderWith('CodeBankShortCode', array('ID' => $snippet->ID, 'Title' => $snippet->getField('Title'), 'Description' => $snippet->getField('Description'), 'SnippetText' => DBField::create_field('Text', $snippetText), 'HighlightCode' => strtolower($snippet->Language()->HighlightCode)));
}
示例2: getCMSPreview
public function getCMSPreview()
{
$html = ViewableData::renderWith('Icon_CMS_Preview');
$obj = HTMLText::create();
$obj->setValue($html);
return $obj;
}
示例3: 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;
}
示例4: 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;
}
示例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();
$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;
}
示例6: 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;
}
示例7: 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;
}
示例8: RenderStyleSheet
public function RenderStyleSheet()
{
$html = ViewableData::renderWith($this->ClassName . '_Style');
return $html;
}
示例9: 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();
}
示例10: renderClusterInformationBubble
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');
}