function generatePDF() { // tempfolder $tmpBaseFolder = TEMP_FOLDER . '/shopsystem'; $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site"; if (is_dir($tmpFolder)) { Filesystem::removeFolder($tmpFolder); } if (!file_exists($tmpFolder)) { Filesystem::makeFolder($tmpFolder); } $baseFolderName = basename($tmpFolder); //Get site Requirements::clear(); $link = Director::absoluteURL($this->pdfLink() . "/?view=1"); $response = Director::test($link); $content = $response->getBody(); $content = utf8_decode($content); $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html"; if (!file_exists($contentfile)) { // Write to file if ($fh = fopen($contentfile, 'w')) { fwrite($fh, $content); fclose($fh); } } return $contentfile; }
/** * Returns an instance of this class * * @param Controller $controller * @param string $name */ public function __construct($controller, $name) { $fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class))); $actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent('<span class="realme_button_padding">Login or register with RealMe<span class="realme_icon_new_window"></span> <span class="realme_icon_padlock"></span>')->setAttribute('class', 'realme_button'))); // Taken from MemberLoginForm if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } elseif (Session::get('BackURL')) { $backURL = Session::get('BackURL'); } if (isset($backURL)) { // Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } } // optionally include requirements {@see /realme/_config/config.yml} if ($this->config()->include_jquery) { Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js"); } if ($this->config()->include_javascript) { Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js"); } if ($this->config()->include_css) { Requirements::css(REALME_MODULE_PATH . "/css/realme.css"); } parent::__construct($controller, $name, $fields, $actions); }
function FieldHolder() { Requirements::javascript("sapphire/javascript/ReportField.js"); $headerHTML = $this->columnheaders(); $dataCellHTML = $this->datacells(); $id = $this->id() . '_exportToCSV'; if ($this->export) { $exportButton = <<<HTML <input name="{$id}" type="submit" id="{$id}" class="ReportField_ExportToCSVButton" value="Export to CSV" /> HTML; } else { $exportButton = ""; } // display the table of results $html = <<<HTML <div style="width: 98%; overflow: auto"> \t{$exportButton} <table class="ReportField" summary=""> \t<thead> \t\t{$headerHTML} \t</thead> \t<tbody> \t\t{$dataCellHTML} \t</tbody> </table> </div> HTML; return $html; }
/** * Gets the overview data from new relic */ public function overview_data() { //Purge Requirements Requirements::clear(); //If we're not configured properly return an error if (!$this->getIsConfigured()) { $msg = _t('NewRelicPerformanceReport.API_APP_CONFIG_ERROR', '_New Relic API Key or Application ID is missing, check configuration'); $e = new SS_HTTPResponse_Exception($msg, 400); $e->getResponse()->addHeader('Content-Type', 'text/plain'); $e->getResponse()->addHeader('X-Status', rawurlencode($msg)); throw $e; return; } //Build the base restful service object $service = new RestfulService('https://api.newrelic.com/v2/applications/' . Convert::raw2url($this->config()->application_id) . '/metrics/data.json', $this->config()->refresh_rate); $service->httpHeader('X-Api-Key:' . Convert::raw2url($this->config()->api_key)); //Perform the request $response = $service->request('', 'POST', 'names[]=HttpDispatcher&names[]=Apdex&names[]=EndUser/Apdex&names[]=Errors/all&names[]=EndUser&period=60'); //Retrieve the body $body = $response->getBody(); if (!empty($body)) { $this->response->addHeader('Content-Type', 'application/json; charset=utf-8'); return $body; } //Data failed to load $msg = _t('NewRelicPerformanceReport.DATA_LOAD_FAIL', '_Failed to retrieve data from New Relic'); $e = new SS_HTTPResponse_Exception($msg, 400); $e->getResponse()->addHeader('Content-Type', 'text/plain'); $e->getResponse()->addHeader('X-Status', rawurlencode($msg)); throw $e; }
public function FieldHolder($properties = array()) { Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css'); Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js'); if ($this->object && $this->object->ID) { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); if (strlen($this->object->SourceURL)) { $properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title')); $properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width')); $properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height')); $properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', ''); $properties['Type'] = HiddenField::create($this->getName() . '[type]', ''); $properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', ''); $properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description')); $properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class')); foreach ($properties as $key => $field) { if ($key == 'ObjectTitle') { $key = 'Title'; } elseif ($key == 'ObjectDescription') { $key = 'Description'; } $field->setValue($this->object->{$key}); } if ($this->object->ThumbURL) { $properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />'); } } } else { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); } $field = parent::FieldHolder($properties); return $field; }
function init() { parent::init(); Requirements::themedCSS("layout"); Requirements::themedCSS("typography"); Requirements::themedCSS("form"); }
function init() { parent::init(); Requirements::css('newsletter/css/SubscriptionPage.css'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/jquery.validate.min.js'); }
public function FieldHolder() { Requirements::javascript('dataobject_manager/javascript/jquery.wysiwyg.js'); Requirements::css('dataobject_manager/css/jquery.wysiwyg.css'); Requirements::customScript("\n\t\t\t\$(function() {\n\t\t\t\t\$('#{$this->id()}').wysiwyg({\n\t\t\t\t\t{$this->getConfig()}\n\t\t\t\t}).parents('.simplehtmleditor').removeClass('hidden');\n\t\t\t\t\n\t\t\t});\n\t\t"); return parent::FieldHolder(); }
function jsValidation() { $formID = $this->form->FormName(); $error = _t('EmailField.VALIDATIONJS', 'Please enter an email address.'); $jsFunc = <<<JS Behaviour.register({ \t"#{$formID}": { \t\tvalidateEmailField: function(fieldName) { \t\t\tvar el = _CURRENT_FORM.elements[fieldName]; \t\t\tif(!el || !el.value) return true; \t\t \tif(el.value.match(/^[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i)) { \t\t \t\treturn true; \t\t \t} else { \t\t\t\tvalidationError(el, "{$error}","validation"); \t\t \t\treturn false; \t\t \t} \t \t\t} \t} }); JS; //fix for the problem with more than one form on a page. Requirements::customScript($jsFunc, 'func_validateEmailField' . '_' . $formID); //return "\$('$formID').validateEmailField('$this->name');"; return <<<JS if(typeof fromAnOnBlur != 'undefined'){ \tif(fromAnOnBlur.name == '{$this->name}') \t\t\$('{$formID}').validateEmailField('{$this->name}'); }else{ \t\$('{$formID}').validateEmailField('{$this->name}'); } JS; }
public function onAfterInit() { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js'); Requirements::javascript("silverstripe-accordian-content/assets/javascript/main.js"); Requirements::css("silverstripe-accordian-content/assets/css/styles.css"); }
public function Field($properties = array()) { $content = ''; Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(FRAMEWORK_DIR . "/javascript/ToggleField.js"); if ($this->startClosed) { $this->addExtraClass('startClosed'); } $valforInput = $this->value ? Convert::raw2att($this->value) : ""; $rawInput = Convert::html2raw($valforInput); if ($this->charNum) { $reducedVal = substr($rawInput, 0, $this->charNum); } else { $reducedVal = DBField::create_field('Text', $rawInput)->{$this->truncateMethod}(); } // only create togglefield if the truncated content is shorter if (strlen($reducedVal) < strlen($rawInput)) { $content = <<<HTML \t\t\t<div class="readonly typography contentLess" style="display: none"> \t\t\t\t{$reducedVal} \t\t\t\t <a href="#" class="triggerMore">{$this->labelMore}</a> \t\t\t</div> \t\t\t<div class="readonly typography contentMore"> \t\t\t\t{$this->value} \t\t\t\t <a href="#" class="triggerLess">{$this->labelLess}</a> \t\t\t</div>\t \t\t\t<br /> \t\t\t<input type="hidden" name="{$this->name}" value="{$valforInput}" /> HTML; } else { $this->dontEscape = true; $content = parent::Field(); } return $content; }
/** * Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments. * @param GridField $gridField Grid Field Reference * @return Array Map where the keys are fragment names and the values are pieces of HTML to add to these fragments. */ public function getHTMLFragments($gridField) { $dataList = $gridField->getList(); if (class_exists('UnsavedRelationList') && $dataList instanceof UnsavedRelationList) { return array(); } $state = $gridField->State->GridFieldSortableRows; if (!is_bool($state->sortableToggle)) { $state->sortableToggle = false; } //Ensure user can edit if (!singleton($gridField->getModelClass())->canEdit()) { return array(); } //Sort order toggle $sortOrderToggle = GridField_FormAction::create($gridField, 'sortablerows-toggle', 'sorttoggle', 'sortableRowsToggle', null)->addExtraClass('sortablerows-toggle'); $sortOrderSave = GridField_FormAction::create($gridField, 'sortablerows-savesort', 'savesort', 'saveGridRowSort', null)->addExtraClass('sortablerows-savesort'); //Sort to Page Action $sortToPage = GridField_FormAction::create($gridField, 'sortablerows-sorttopage', 'sorttopage', 'sortToPage', null)->addExtraClass('sortablerows-sorttopage'); $data = array('SortableToggle' => $sortOrderToggle, 'SortOrderSave' => $sortOrderSave, 'SortToPage' => $sortToPage, 'Checked' => $state->sortableToggle == true ? ' checked = "checked"' : '', 'List' => $dataList); $forTemplate = new ArrayData($data); //Inject Requirements $custom = Config::inst()->get('GridFieldSortableRows', 'Base'); $base = $custom ?: SORTABLE_GRIDFIELD_BASE; Requirements::css($base . '/css/GridFieldSortableRows.css'); Requirements::javascript($base . '/javascript/GridFieldSortableRows.js'); $args = array('Colspan' => count($gridField->getColumns()), 'ID' => $gridField->ID(), 'DisableSelection' => $this->disable_selection); $fragments = array('header' => $forTemplate->renderWith('GridFieldSortableRows', $args)); if ($gridField->getConfig()->getComponentByType('GridFieldPaginator')) { $fragments['after'] = $forTemplate->renderWith('GridFieldSortableRows_paginator'); } return $fragments; }
function Dates() { Requirements::themedCSS('archivewidget'); $results = new DataObjectSet(); $container = BlogTree::current(); $ids = $container->BlogHolderIDs(); $stage = Versioned::current_stage(); $suffix = !$stage || $stage == 'Stage' ? "" : "_{$stage}"; $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")'; $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")'; if ($this->DisplayMode == 'month') { $sqlResults = DB::query("\n\t\t\t\tSELECT DISTINCT CAST({$monthclause} AS " . DB::getConn()->dbDataType('unsigned integer') . ") AS \"Month\", {$yearclause} AS \"Year\"\n\t\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\t\tORDER BY \"Year\" DESC, \"Month\" DESC;"); } else { $sqlResults = DB::query("\n\t\t\t\tSELECT DISTINCT {$yearclause} AS \"Year\" \n\t\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\t\tORDER BY \"Year\" DESC"); } if ($sqlResults) { foreach ($sqlResults as $sqlResult) { $isMonthDisplay = $this->DisplayMode == 'month'; $monthVal = isset($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1; $month = $isMonthDisplay ? $monthVal : 1; $year = $sqlResult['Year'] ? (int) $sqlResult['Year'] : date('Y'); $date = DBField::create('Date', array('Day' => 1, 'Month' => $month, 'Year' => $year)); if ($isMonthDisplay) { $link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal); } else { $link = $container->Link('date') . '/' . $sqlResult['Year']; } $results->push(new ArrayData(array('Date' => $date, 'Link' => $link))); } } return $results; }
/** * Taken from MemberLoginForm::__construct with minor changes */ public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { $customCSS = project() . '/css/member_login.css'; if (Director::fileExists($customCSS)) { Requirements::css($customCSS); } if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) { $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); $actions = new FieldList(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); } if (!$actions) { $actions = new FieldList(new FormAction('dologin', _t('GoogleAuthenticator.BUTTONLOGIN', "Log in with Google"))); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } // Allow GET method for callback $this->setFormMethod('GET', true); parent::__construct($controller, $name, $fields, $actions); }
/** * Renders the button, includes the JS and CSS * @param array $properties */ public function Field($properties = array()) { Requirements::css(BETTER_BUTTONS_DIR . '/css/dropdown_form_action.css'); Requirements::javascript(BETTER_BUTTONS_DIR . '/javascript/dropdown_form_action.js'); $this->setAttribute('data-form-action-dropdown', '#' . $this->DropdownID()); return parent::Field(); }
public function MarketPlaceReviewForm() { Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"); Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js"); Requirements::combine_files('marketplace_review_form.js', array("themes/openstack/javascript/jquery.validate.custom.methods.js", "marketplace/code/ui/frontend/js/star-rating.min.js", "marketplace/code/ui/frontend/js/marketplace.review.js")); $css_files = array("marketplace/code/ui/frontend/css/star-rating.min.css", "marketplace/code/ui/frontend/css/marketplace-review.css"); foreach ($css_files as $css_file) { Requirements::css($css_file); } $form = new MarketPlaceReviewForm($this, 'MarketPlaceReviewForm'); $data = Session::get("FormInfo.Form_MarketPlaceReviewForm.data"); $review = $this->review_repository->getReview($this->company_service_ID, Member::CurrentUserID()); if (is_array($data)) { //get data from cache $form->loadDataFrom($data); } elseif ($review) { // get submitted review $form->loadDataFrom($review); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } return $form; }
public function init() { parent::init(); Requirements::javascript(MCE_ROOT . "tiny_mce_src.js"); Requirements::javascript("jsparty/tiny_mce_improvements.js"); Requirements::javascript("jsparty/hover.js"); Requirements::javascript("jsparty/scriptaculous/controls.js"); Requirements::javascript("cms/javascript/SecurityAdmin.js"); Requirements::javascript("cms/javascript/LeftAndMain_left.js"); Requirements::javascript("cms/javascript/LeftAndMain_right.js"); Requirements::javascript("cms/javascript/CMSMain_left.js"); Requirements::javascript("cms/javascript/ReportAdmin_left.js"); Requirements::javascript("cms/javascript/ReportAdmin_right.js"); Requirements::css("cms/css/ReportAdmin.css"); // TODO Find a better solution to integrate optional Requirements in a specific order if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) { Requirements::css("ecommerce/css/DataReportCMSMain.css"); } if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) { Requirements::javascript("ecommerce/javascript/DataReport.js"); } if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) { Requirements::css(project() . "/css/DataReportCMSMain.css"); } if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) { Requirements::javascript(project() . "/javascript/DataReport.js"); } // We don't want this showing up in every ajax-response, it should always be present in a CMS-environment if (!Director::is_ajax()) { Requirements::javascriptTemplate("cms/javascript/tinymce.template.js", array("ContentCSS" => project() . "/css/editor.css", "BaseURL" => Director::absoluteBaseURL(), "Lang" => i18n::get_tinymce_lang())); } }
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null) { if (!$fields) { $helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'); $helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>'); $importer = new MemberCsvBulkLoader(); $importSpec = $importer->getImportSpec(); $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields']))); $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>'))); $fileField->getValidator()->setAllowedExtensions(array('csv')); } if (!$actions) { $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV')); $action->addExtraClass('ss-ui-button'); $actions = new FieldList($action); } if (!$validator) { $validator = new RequiredFields('CsvFile'); } parent::__construct($controller, $name, $fields, $actions, $validator); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js'); $this->addExtraClass('cms'); $this->addExtraClass('import-form'); }
public function initialize() { Requirements::javascript('jsparty/jquery/jquery.js'); Requirements::javascript('image_gallery/gallery_ui/prettyphoto/javascript/jquery.prettyPhoto.js'); Requirements::javascript('image_gallery/gallery_ui/prettyphoto/javascript/prettyphoto_init.js'); Requirements::css('image_gallery/gallery_ui/prettyphoto/css/prettyPhoto.css'); }
public function init() { if (!$this->currentDashboard) { Restrictable::set_enabled(false); if (Member::currentUserID()) { Restrictable::set_enabled(true); $this->currentDashboard = $this->getDashboard(); } Restrictable::set_enabled(true); } parent::init(); if ($this->currentDashboard && !$this->currentDashboard->checkPerm('View')) { if (!Member::currentUserID() && !$this->redirectedTo()) { Security::permissionFailure($this, "You must be logged in"); return; } } Requirements::block(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript('frontend-dashboards/javascript/jquery-1.10.2.min.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-form/jquery.form.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript('frontend-dashboards/thirdparty/jquery-cookie/jquery.cookie.js'); Requirements::javascript(FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js'); Requirements::javascript('frontend-dashboards/javascript/dashboards.js'); Requirements::javascript('frontend-dashboards/javascript/dashboard-dialogs.js'); Requirements::css('frontend-dashboards/css/dashboards.css'); Requirements::javascript('frontend-dashboards/javascript/jquery.gridster.js'); Requirements::css('frontend-dashboards/css/jquery.gridster.css'); // Requirements::javascript('frontend-dashboards/javascript/jquery.gridly.js'); // Requirements::css('frontend-dashboards/css/jquery.gridly.css'); }
function jsValidation() { $formID = $this->form->FormName(); $error = _t('DateField.VALIDATIONJS', 'Please enter a valid date format (DD/MM/YYYY).'); $jsFunc = <<<JS Behaviour.register({ \t"#{$formID}": { \t\tvalidateDate: function(fieldName) { \t\t\tvar el = _CURRENT_FORM.elements[fieldName]; \t\t\tvar value = \$F(el); \t\t\t \t\t\tif(value && value.length > 0 && !value.match(/^[0-9]{1,2}\\/[0-9]{1,2}\\/[0-90-9]{2,4}\$/)) { \t\t\t\tvalidationError(el,"{$error}","validation",false); \t\t\t\treturn false; \t\t\t} \t\t\treturn true; \t\t} \t} }); JS; Requirements::customScript($jsFunc, 'func_validateDate_' . $formID); // return "\$('$formID').validateDate('$this->name');"; return <<<JS if(\$('{$formID}')){ \tif(typeof fromAnOnBlur != 'undefined'){ \t\tif(fromAnOnBlur.name == '{$this->name}') \t\t\t\$('{$formID}').validateDate('{$this->name}'); \t}else{ \t\t\$('{$formID}').validateDate('{$this->name}'); \t} } JS; }
public function Field($properties = array()) { FormExtraJquery::include_jquery(); FormExtraJquery::include_accounting(); Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/AccountingField.js'); return parent::Field($properties); }
function init() { if (!Permission::check('ADMIN')) { Requirements::css('iq-security/css/iq-security.css'); } Requirements::javascript('iq-security/javascript/iq-security.js'); }
function Field() { Requirements::javascript("jsparty/calendar/calendar.js"); Requirements::javascript("jsparty/calendar/lang/calendar-en.js"); Requirements::javascript("jsparty/calendar/calendar-setup.js"); Requirements::css("sapphire/css/CalendarDateField.css"); Requirements::css("jsparty/calendar/calendar-win2k-1.css"); Requirements::javascript("sapphire/javascript/CalendarDateField.js"); $field = DateField::Field(); $id = $this->id(); $val = $this->attrValue(); if (preg_match('/^\\d{2}\\/\\d{2}\\/\\d{4}$/', $val)) { $dateArray = explode('/', $val); $val = $dateArray[2] . '-' . $dateArray[1] . '-' . $dateArray[0]; } $dateArray = explode('-', $val); $day = $dateArray[2]; $month = $dateArray[1]; $year = $dateArray[0]; preg_match('/(.*)[(.+)]$/', $this->name, $fieldNameParts); $fieldNamePrefix = $fieldNameParts[1]; $fieldName = $fieldNameParts[2]; return <<<HTML \t\t\t<div class="dmycalendardate"> \t\t\t\t<input type="hidden" id="{$id}" name="{$this->name}" value="{$val}" /> \t\t\t\t<input type="text" id="{$id}-day" class="day numeric" name="{$fieldNamePrefix}[{$fieldName}-Day]" value="{$day}" maxlength="2" />/ \t\t\t\t<input type="text" id="{$id}-month" class="month numeric" name="{$fieldNamePrefix}[{$fieldName}-Month]" value="{$month}" maxlength="2" />/ \t\t\t\t<input type="text" id="{$id}-year" class="year numeric" name="{$fieldNamePrefix}[{$fieldName}-Year]" value="{$year}" maxlength="4" /> \t\t\t\t<div class="calendarpopup" id="{$id}-calendar"></div> \t\t\t</div> HTML; }
function FieldHolder() { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js'); Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css'); return $this->renderWith("SelectionGroup"); }
public function Field($properties = array()) { if ($this->includeDefaultJS) { Requirements::javascriptTemplate(FRAMEWORK_DIR . '/javascript/InlineFormAction.js', array('ID' => $this->id())); } return "<input type=\"submit\" name=\"action_{$this->name}\" value=\"{$this->title}\" id=\"{$this->id()}\"" . " class=\"action{$this->extraClass}\" />"; }
function FieldHolder() { $ret = parent::FieldHolder(); Requirements::javascript(CMS_DIR . '/javascript/AssetTableField.js'); return $ret; }
/** * getCMSFields * Construct the FieldList used in the CMS. To provide a * smarter UI we don't use the scaffolding provided by * parent::getCMSFields. * * @return FieldList */ public function getCMSFields() { Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css'); //Create the FieldList and push the Root TabSet on to it. $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Currency"), CompositeField::create(DropdownField::create("Enabled", "Enable Currency?", array("1" => "Yes", "2" => "No"))->setRightTitle($this->SystemCreated == 1 ? "DISABLED: You can not disable the default currency." : "Select the country this zone applies to.")->setDisabled($this->SystemCreated == 1 ? true : false), TextField::create("Title", "Currency Name")->setRightTitle("i.e. Great British Pound."), TextField::create("Code", "Currency Code")->setRightTitle("i.e. GBP, USD, EUR."), TextField::create("ExchangeRate", "Exchange Rate")->setRightTitle("i.e. Your new currency is USD, a conversion rate of 1.53 may apply against the local currency."), TextField::create("Symbol", "Currency Symbol")->setRightTitle("i.e. £, \$, €."), DropdownField::create("SymbolLocation", "Symbol Location", array("1" => "On the left, i.e. \$1.00", "2" => "On the right, i.e. 1.00\$", "3" => "Display the currency code instead, i.e. 1 USD."))->setRightTitle("Where should the currency symbol be placed?"), TextField::create("DecimalSeperator", "Decimal Separator")->setRightTitle("What decimal separator does this currency use?"), TextField::create("ThousandsSeparator", "Thousands Separator")->setRightTitle("What thousands separator does this currency use?"), NumericField::create("DecimalPlaces", "Decimal Places")->setRightTitle("How many decimal places does this currency use?"))))); return $fields; }
function jsValidation() { $formID = $this->form->FormName(); $error = _t('EmailField.VALIDATIONJS', 'Please enter an email address.'); $jsFunc = <<<JS Behaviour.register({ \t"#{$formID}": { \t\tvalidateEmailField: function(fieldName) { \t\t\tvar el = _CURRENT_FORM.elements[fieldName]; \t\t\tif(!el || !el.value) return true; \t\t \tif(el.value.match(/^([a-zA-Z0-9_+\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)\$/)) { \t\t \t\treturn true; \t\t \t} else { \t\t\t\tvalidationError(el, "{$error}","validation"); \t\t \t\treturn false; \t\t \t} \t \t\t} \t} }); JS; Requirements::customScript($jsFunc, 'func_validateEmailField'); //return "\$('$formID').validateEmailField('$this->name');"; return <<<JS if(typeof fromAnOnBlur != 'undefined'){ \tif(fromAnOnBlur.name == '{$this->name}') \t\t\$('{$formID}').validateEmailField('{$this->name}'); }else{ \t\$('{$formID}').validateEmailField('{$this->name}'); } JS; }
public function index() { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::customCSS('#OrphanIDs .middleColumn {width: auto;}'); Requirements::customCSS('#OrphanIDs label {display: inline;}'); return $this->renderWith('BlankPage'); }