当前位置: 首页>>代码示例>>PHP>>正文


PHP ViewableData类代码示例

本文整理汇总了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)));
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:38,代码来源:CodeBankShortCode.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-geocatalogue,代码行数:64,代码来源:CreateRequestCommand.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-geocatalogue,代码行数:21,代码来源:CreateRecordByIdRequestCommand.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-geocatalogue,代码行数:20,代码来源:CreateInsertCommand.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-geocatalogue,代码行数:20,代码来源:CreateUpdateCommand.php

示例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;
 }
开发者ID:newleeland,项目名称:silverstripe-globaltoolbar,代码行数:25,代码来源:GlobalNavSiteTreeExtension.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-geocatalogue,代码行数:26,代码来源:ParseXMLCommand.php

示例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();
 }
开发者ID:SpiritLevel,项目名称:silverstripe-framework,代码行数:13,代码来源:ViewableData_Customised.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-geocatalogue,代码行数:21,代码来源:GenerateISO19139XMLCommand.php

示例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);
 }
开发者ID:Olliepop,项目名称:silverstripe-mandrill,代码行数:34,代码来源:MandrillEmail.php

示例11: getCMSPreview

 public function getCMSPreview()
 {
     $html = ViewableData::renderWith('Icon_CMS_Preview');
     $obj = HTMLText::create();
     $obj->setValue($html);
     return $obj;
 }
开发者ID:helpfulrobot,项目名称:stephenjcorwin-silverstripe-icons,代码行数:7,代码来源:Icon.php

示例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);
 }
开发者ID:stojg,项目名称:silverstripe-globaltoolbar,代码行数:8,代码来源:GlobalNavSiteTreeExtension.php

示例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();
 }
开发者ID:helpfulrobot,项目名称:groupdocs-groupdocs-comparison,代码行数:7,代码来源:Result.php

示例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 &lt% cached List(Member).max(LastEdited) %&gt instead' . ' (check partial-caching.md documentation for more details.)');
     $this->type = $type;
     $this->filter = $filter;
     parent::__construct();
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:15,代码来源:Aggregate.php

示例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();
 }
开发者ID:NARKOZ,项目名称:silverstripe-doc-restructuring,代码行数:12,代码来源:RestfulService.php


注:本文中的ViewableData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。