/** * 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))); }
/** * 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(); // 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 * * 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; }
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; }
public function __construct($width, $height, $guid_embed_redline) { $this->width = $width; $this->height = $height; $this->guid_embed_redline = $guid_embed_redline; parent::__construct(); }
/** * 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; }
/** * 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(); }
/** * 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(); }
/** * 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(); }
public function __construct($width, $height, $url) { $this->width = $width; $this->height = $height; $this->server_url = $url; parent::__construct(); }
/** * 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) */ public function __construct($base, $expiry = 3600) { $this->baseURL = $base; $this->cache_expire = $expiry; parent::__construct(); $this->proxy = $this->config()->default_proxy; }
/** * 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; }
/** * @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); }
function __construct($name) { parent::__construct(); if (preg_match('/^(\\w+)$/i', $name, $match)) { $this->Name = $match[1]; } }
public function __construct($width, $height, $guid) { $this->width = $width; $this->height = $height; $this->guid = $guid; parent::__construct(); }
/** * @param string $content */ public function __construct($content = null) { $this->document = new DOMDocument('1.0', 'UTF-8'); $this->document->scrictErrorChecking = false; $this->setContent($content); parent::__construct(); }
public function getCMSPreview() { $html = ViewableData::renderWith('Icon_CMS_Preview'); $obj = HTMLText::create(); $obj->setValue($html); return $obj; }
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); }
/** * 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) * @param int $timeout (Defaults to 5 s) */ function __construct($base, $expiry = 3600, $timeout = 5) { $this->baseURL = $base; $this->cache_expire = $expiry; $this->timeoutRequest = $timeout; $this->proxy = self::$default_proxy; parent::__construct(); }
public function __construct($data = array()) { parent::__construct(); if (is_array($data)) { foreach ($data as $k => $v) { $this->{$k} = $v; } } }
public function __construct() { parent::__construct(); $this->init(); foreach ($this->getClasses() as $class => $options) { SearchVariant::with($class, $options['include_children'])->call('alterDefinition', $class, $this); } $this->buildDependancyList(); }
public function __construct() { $this->brokenOnConstruct = false; // Check necessary to avoid class conflicts before manifest is rebuilt if (class_exists('NullHTTPRequest')) { $this->request = new NullHTTPRequest(); } parent::__construct(); }
/** * A wildcard method to handle calling specially named varchar fields, e.g. Email, URL. * @param string $method The method name * @return mixed */ public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null) { $varchar = DBField::create_field("Varchar", null, $fieldName); if ($data = $varchar->getDataByFieldName($this->getFaker())) { $varchar->setValue($data); return $varchar; } return parent::obj($fieldName); }
/** * @param string $field * @return string|null */ public function castingHelper($field) { $castings = $this->obj->getCastings(); if (isset($castings[$field])) { return $castings[$field]; } else { return parent::castingHelper($field); } }
/** * Construct a DataDifferencer to show the changes between $fromRecord and $toRecord. * If $fromRecord is null, this will represent a "creation". * * @param DataObject (Optional) * @param DataObject */ function __construct($fromRecord, DataObject $toRecord) { if (!$toRecord) { user_error("DataDifferencer constructed without a toRecord", E_USER_WARNING); } $this->fromRecord = $fromRecord; $this->toRecord = $toRecord; parent::__construct(); }
function __construct($id) { parent::__construct(); if (preg_match('/^(\\w+)\\.(\\w+)$/i', $id, $match)) { $this->Table = $match[1]; $this->Label = $match[2]; } else { $this->Label = $id; } }
public function __get($property) { if ($this->hasMethod($method = "get{$property}")) { return $this->{$method}(); } elseif (isset($this->data[strtolower($property)])) { return $this->data[strtolower($property)]; } else { return parent::__get($property); } }
function __get($name) { if (isset(self::$registered_handlers[$name])) { $collectionClass = self::$registered_handlers[$name]; $res = new $collectionClass(); $res->parent = $this; $res->linkFragment = $name; return $res; } return parent::__get($name); }