本文整理汇总了PHP中ViewableData类的典型用法代码示例。如果您正苦于以下问题:PHP ViewableData类的具体用法?PHP ViewableData怎么用?PHP ViewableData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewableData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
// 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;
}
示例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: get_navbar_html
public static function get_navbar_html($page = null)
{
// remove the protocol from the URL, otherwise we run into https/http issues
$url = self::remove_protocol_from_url(self::get_toolbar_hostname());
$static = true;
if (!$page instanceof SiteTree) {
$page = Director::get_current_page();
$static = false;
}
// In some cases, controllers are bound to "mock" pages, like Security. In that case,
// throw the "default section" as the current controller.
if (!$page instanceof SiteTree || !$page->isInDB()) {
$controller = ModelAsController::controller_for($page = SiteTree::get_by_link(Config::inst()->get('GlobalNav', 'default_section')));
} else {
// Use controller_for to negotiate sub controllers, e.g. /showcase/listing/slug
// (Controller::curr() would return the nested RequestHandler)
$controller = ModelAsController::controller_for($page);
}
// Ensure staging links are not exported to the nav
$origStage = Versioned::current_stage();
Versioned::reading_stage('Live');
$html = ViewableData::create()->customise(array('ToolbarHostname' => $url, 'Scope' => $controller, 'ActivePage' => $page, 'ActiveParent' => $page instanceof SiteTree && $page->Parent()->exists() ? $page->Parent() : $page, 'StaticRender' => $static, 'GoogleCustomSearchId' => Config::inst()->get('GlobalNav', 'google_search_id')))->renderWith('GlobalNavbar');
Versioned::reading_stage($origStage);
return $html;
}
示例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: __construct
/**
* Instantiate a new customised ViewableData object
*
* @param ViewableData $originalObject
* @param ViewableData $customisedObject
*/
public function __construct(ViewableData $originalObject, ViewableData $customisedObject)
{
$this->original = $originalObject;
$this->customised = $customisedObject;
$this->original->setCustomisedObj($this);
parent::__construct();
}
示例9: 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;
}
示例10: 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);
}
示例11: getCMSPreview
public function getCMSPreview()
{
$html = ViewableData::renderWith('Icon_CMS_Preview');
$obj = HTMLText::create();
$obj->setValue($html);
return $obj;
}
示例12: create_nav
public static function create_nav()
{
// remove the protocol from the URL, otherwise we run into https/http issues
$url = self::remove_protocol_from_url(self::get_toolbar_hostname());
$html = ViewableData::create()->customise(array('ToolbarHostname' => $url, 'Pages' => SiteTree::get()->filter(array('ParentID' => 0, 'ShowInGlobalNav' => true)), 'GoogleCustomSearchId' => Config::inst()->get('GlobalNav', 'google_search_id')))->renderWith('GlobalNavbar');
$path = Config::inst()->get('GlobalNav', 'snippet_path');
file_put_contents(BASE_PATH . $path, $html);
}
示例13: __construct
public function __construct($width, $height, $guid_embed_redline)
{
$this->width = $width;
$this->height = $height;
$this->guid_embed_redline = $guid_embed_redline;
parent::__construct();
}
示例14: __construct
/**
* Constructor
*
* @deprecated 3.1 Use DataList to aggregate data
*
* @param string $type The DataObject type we are building an aggregate for
* @param string $filter (optional) An SQL filter to apply to the selected rows before calculating the aggregate
*/
public function __construct($type, $filter = '')
{
Deprecation::notice('3.1', 'Call aggregate methods on a DataList directly instead. In templates' . ' an example of the new syntax is <% cached List(Member).max(LastEdited) %> instead' . ' (check partial-caching.md documentation for more details.)');
$this->type = $type;
$this->filter = $filter;
parent::__construct();
}
示例15:
/**
* Creates a new restful service.
* @param string $base Base URL of the web service eg: api.example.com
* @param int $expiry Set the cache expiry interva. Defaults to 1 hour (3600 seconds)
*/
function __construct($base, $expiry = 3600)
{
$this->baseURL = $base;
$this->cache_expire = $expiry;
$this->proxy = self::$default_proxy;
parent::__construct();
}