public function getCMSFields() { $fieldBody = new TextareaField('Body', 'Inhoud'); $fieldBody->setRows(5); $oFields = new FieldList(new TextField('Header', 'Title'), $fieldBody, new TextField('FieldLabelName', 'Dummy text in name field'), new TextField('FieldLabelEmail', 'Dummy text in email field'), new TextField('BtnLabel', 'Button label')); if (Config::inst()->get(NewsLetterWidget_Name, NewsLetterWidget_Storage_Sys) == NewsLetterWidget_Storage_Sys_Mailchimp) { $fldTextFieldListId = new TextField('MailChimpListID', 'Mailchimp lijst id'); $sApiKey = Config::inst()->get(NewsLetterWidget_Name, NewsLetterWidget_Storage_Sys_Mailchimp_APIKey); if ($sApiKey == null || trim($sApiKey) == '') { $oFields->push($fldTextFieldListId); } else { // fetch lists $api = new MCAPI($sApiKey); $retval = $api->lists(); if ($api->errorCode) { //echo "Unable to load lists()!"; //echo "\n\tCode=".$api->errorCode; //echo "\n\tMsg=".$api->errorMessage."\n"; } else { //echo "Lists that matched:".$retval['total']."\n"; //echo "Lists returned:".sizeof($retval['data'])."\n"; $aOptions = array(); foreach ($retval['data'] as $list) { //echo "Id = ".$list['id']." - ".$list['name']."\n"; //echo "Web_id = ".$list['web_id']."\n"; $aOptions[$list['id']] = $list['name']; } $oFields->push(new DropdownField('MailChimpListID', 'Mailchimp lijst id', $aOptions)); } } } return $oFields; }
public function getCMSFields() { $fields = new FieldList(); $fields->push(new TabSet('Root', new Tab('Main', _t('SiteTree.TABMAIN', 'Main'), new TextField('Title', _t('UniadsObject.db_Title', 'Title'))))); if ($this->ID) { $previewLink = Director::absoluteBaseURL() . 'admin/' . UniadsAdmin::config()->url_segment . '/UniadsObject/preview/' . $this->ID; $fields->addFieldToTab('Root.Main', new ReadonlyField('Impressions', _t('UniadsObject.db_Impressions', 'Impressions')), 'Title'); $fields->addFieldToTab('Root.Main', new ReadonlyField('Clicks', _t('UniadsObject.db_Clicks', 'Clicks')), 'Title'); $fields->addFieldsToTab('Root.Main', array(DropdownField::create('CampaignID', _t('UniadsObject.has_one_Campaign', 'Campaign'), DataList::create('UniadsCampaign')->map())->setEmptyString(_t('UniadsObject.Campaign_none', 'none')), DropdownField::create('ZoneID', _t('UniadsObject.has_one_Zone', 'Zone'), DataList::create('UniadsZone')->map())->setEmptyString(_t('UniadsObject.Zone_select', 'select one')), new NumericField('Weight', _t('UniadsObject.db_Weight', 'Weight (controls how often it will be shown relative to others)')), new TextField('TargetURL', _t('UniadsObject.db_TargetURL', 'Target URL')), new Treedropdownfield('InternalPageID', _t('UniadsObject.has_one_InternalPage', 'Internal Page Link'), 'Page'), new CheckboxField('NewWindow', _t('UniadsObject.db_NewWindow', 'Open in a new Window')), $file = new UploadField('File', _t('UniadsObject.has_one_File', 'Advertisement File')), $AdContent = new TextareaField('AdContent', _t('UniadsObject.db_AdContent', 'Advertisement Content')), $Starts = new DateField('Starts', _t('UniadsObject.db_Starts', 'Starts')), $Expires = new DateField('Expires', _t('UniadsObject.db_Expires', 'Expires')), new NumericField('ImpressionLimit', _t('UniadsObject.db_ImpressionLimit', 'Impression Limit')), new CheckboxField('Active', _t('UniadsObject.db_Active', 'Active')), new LiteralField('Preview', '<a href="' . $previewLink . '" target="_blank">' . _t('UniadsObject.Preview', 'Preview this advertisement') . "</a>"))); $app_categories = File::config()->app_categories; $file->setFolderName($this->config()->files_dir); $file->getValidator()->setAllowedMaxFileSize(array('*' => $this->config()->max_file_size)); $file->getValidator()->setAllowedExtensions(array_merge($app_categories['image'], $app_categories['flash'])); $AdContent->setRows(10); $AdContent->setColumns(20); $Starts->setConfig('showcalendar', true); $Starts->setConfig('dateformat', i18n::get_date_format()); $Starts->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires->setConfig('showcalendar', true); $Expires->setConfig('dateformat', i18n::get_date_format()); $Expires->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires->setConfig('min', date('Y-m-d', strtotime($this->Starts ? $this->Starts : '+1 days'))); } $this->extend('updateCMSFields', $fields); return $fields; }
public function getFieldConfiguration() { $textAreaField = new TextareaField($this->getSettingName('Content'), "HTML"); $textAreaField->setRows(4); $textAreaField->setColumns(20); return new FieldList($textAreaField, new CheckboxField($this->getSettingName('HideFromReports'), _t('EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?'), $this->getSetting('HideFromReports'))); }
public function updateCMSFields(FieldList $fields) { /* ----------------------------------------- * Color Picker ------------------------------------------*/ Requirements::css('boilerplate/css/colorpicker.css'); Requirements::javascript('boilerplate/javascript/colorpicker.min.js'); Requirements::javascript('boilerplate/javascript/colorpicker.init.js'); /* ========================================= * Settings =========================================*/ if (!$fields->fieldByName('Root.Settings')) { $fields->addFieldToTab('Root', new TabSet('Settings')); } /* ----------------------------------------- * Images ------------------------------------------*/ $fields->findOrMakeTab('Root.Settings.Images', 'Images'); $fields->addFieldsToTab('Root.Settings.Images', array($logo = new UploadField('LogoImage', _t('BoilerplateConfig.LogoImageLabel', 'Logo')), $favicon = new UploadField('Favicon', _t('BoilerplateConfig.FaviconLabel', 'Favicon')))); $logo->setRightTitle('Choose an Image For Your Logo'); $favicon->setRightTitle('Choose an Image For Your Favicon (16x16)'); /* ----------------------------------------- * Company Details ------------------------------------------*/ $fields->findOrMakeTab('Root.Settings.Details', 'Details'); $fields->addFieldsToTab('Root.Settings.Details', array(new Textfield('Phone', _t('BoilerplateConfig.PhoneLabel', 'Phone Number')), new Textfield('Email', _t('BoilerplateConfig.EmailLabel', 'Public Email Address')), $PhysicalAddress = new HtmlEditorField('PhysicalAddress', _t('BoilerplateConfig.PhysicalAddressLabel', 'Physical Address')))); $PhysicalAddress->setRows(3); /* ----------------------------------------- * Tracking Code ------------------------------------------*/ $fields->findOrMakeTab('Root.Settings.TrackingCode', 'Tracking Code'); $fields->addFieldsToTab('Root.Settings.TrackingCode', array($trackingCode = new TextareaField('TrackingCode', _t('BoilerplateConfig.TrackingCodeLabel', 'Tracking Code')))); $trackingCode->setRows(20); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->replaceField('ItemTemplate', $ta = new TextareaField('ItemTemplate', _t('ListingTemplate.ITEM_TEMPLATE', 'Item Template (use the Items variable to iterate over)'))); $ta->setRows(20); $ta->setColumns(120); return $fields; }
public function getFieldConfiguration() { $customSettings = unserialize($this->CustomSettings); $content = isset($customSettings['Content']) ? $customSettings['Content'] : ''; $textAreaField = new TextareaField($this->getSettingName('Content'), "HTML", $content); $textAreaField->setRows(4); $textAreaField->setColumns(20); return new FieldList($textAreaField, new CheckboxField($this->getSettingName('HideFromReports'), _t('EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?'), $this->getSetting('HideFromReports'))); }
public function getFieldConfiguration() { $customSettings = unserialize($this->CustomSettings); $content = isset($customSettings['Content']) ? $customSettings['Content'] : ''; $textAreaField = new TextareaField($this->getSettingName('Content'), "HTML", $content); $textAreaField->setRows(4); $textAreaField->setColumns(20); return new FieldList($textAreaField); }
/** * @return TextareaField|TextField */ public function getFormField() { if ($this->getSetting('Rows') && $this->getSetting('Rows') > 1) { $taf = new TextareaField($this->Name, $this->Title); $taf->setRows($this->getSetting('Rows')); return $taf; } else { return new TextField($this->Name, $this->Title, null, $this->getSetting('MaxLength')); } }
public function updateCMSFields(FieldList $fields) { if ($this->owner->MediaType != __CLASS__) { return; } $thumbField = $this->owner->getUploadField('ThumbnailImage', 'Thumbnail (optional - will grab from YouTube)', SitePhoto::$allowed_file_types, 'images'); $posterField = $this->owner->getUploadField('PosterImage', 'Poster Image (optional - will grab from YouTube)', SitePhoto::$allowed_file_types, 'images'); $fields->addFieldsToTab('Root.Main', array(new TextField('YouTubeVideoID', 'YouTube Video ID'), $caption = new TextareaField('Caption'), $thumbField, $posterField)); $caption->setRows(1); }
public function getCMSFields() { $fields = parent::getCMSFields(); if ($this->disableEditor) { $tfa = new TextareaField('HTML'); $tfa->setRows(30); $tfa->setColumns(150); $fields->addFieldToTab('Root.Main', $tfa); } return $fields; }
/** * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', $dateTimeField = new DatetimeField('Date', $this->fieldLabel('Date')), 'Content'); $dateTimeField->getDateField()->setConfig('showcalendar', true); $fields->addfieldToTab('Root.Main', $abstractField = new TextareaField('Abstract', $this->fieldLabel('Abstract')), 'Content'); $abstractField->setAttribute('maxlength', '160'); $abstractField->setRightTitle(_t('DateUpdatePage.AbstractDesc', 'The abstract is used as a summary on the listing pages. It is limited to 160 characters.')); $abstractField->setRows(6); return $fields; }
public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab('Root.Main.Metadata', $keywordsField = new TextareaField('MetaKeywords', 'Meta Keywords'), "ExtraMeta"); $fields->addFieldToTab('Root.Main.Metadata', new TextField('MetaTitle', 'Meta Title'), 'MetaDescription'); foreach (array('MetaTitle', 'MetaDescription', 'MetaKeywords') as $MetaFieldName) { $oldField = $fields->dataFieldByName($MetaFieldName); $oldField->setTitle($oldField->Title() . '<span class="field_count">' . strlen($this->owner->{$MetaFieldName}) . '</span>'); } $keywordsField->setRows(1); if (permission::check('ADMIN')) { $fields->addFieldToTab("Root.Main", new CheckboxField("NoFollow", "Set nav link to no-follow?"), "MetaDescription"); $fields->addFieldToTab('Root.Main.Metadata', new TextareaField('URLRedirects', '301 Redirects')); } return $fields; }
function Form() { if ($this->request->requestVar('_REDIRECT_BACK_URL')) { $url = $this->request->requestVar('_REDIRECT_BACK_URL'); } else { if ($this->request->getHeader('Referer')) { $url = $this->request->getHeader('Referer'); } else { $url = Director::baseURL(); } } $folder = Folder::find_or_make("ErrorScreenshots"); $whatDidYouTryDoField = new TextareaField('WhatDidYouTryToDo', 'What did you try to do'); $whatDidYouTryDoField->setRows(3); $whatWentWrongField = new TextareaField('WhatWentWrong', 'What went wrong'); $whatWentWrongField->setRows(3); $screenshotField = new FileField('Screenshot', 'To take a screenshot press the PRT SCR button on your keyboard, then open MS Word or MS Paint and paste the screenshot. Save the file and then attach (upload) the file here.'); $screenshotField->setFolderName($folder->Name); $form = new Form($this, 'Form', new FieldList(new TextField('Name'), new TextField('Email'), new TextField('URL', 'What is the URL of the page the error occured (this is the address shown in the address bar (e.g. http://www.mysite.com/mypage/with/errors/)', $url), $whatDidYouTryDoField, $whatWentWrongField, $screenshotField), new FieldList(new FormAction('senderror', 'Submit Error')), new RequiredFields(array("Email", "Name"))); return $form; }
/** * Return the linked file view form, which shows a readonly form that contains the * source text of the file being viewed. * @throws Exception * @return Form */ public function LinkedFileViewForm() { // grab the parameters if (isset($_REQUEST['ID'])) { $id = addslashes($_REQUEST['ID']); } else { throw new Exception("invalid ID"); } // Extract parameters from this ID. It's base 64 of // templateID:path $id = base64_decode($id); $params = explode(':', $id); if (count($params) != 2) { throw Exception("Invalid params, expected 2 components"); } $dynamicTemplateId = $params[0]; $path = $params[1]; $form = new Form($this, "LinkedFileViewForm", new FieldList(new LabelField("Filename", "File: " . $path), $sourceTextField = new TextareaField("SourceText", ""), new HiddenField('ID', 'ID'), new HiddenField('BackURL', 'BackURL', $this->Link())), new FieldList(new FormAction('cancelFileEdit', _t('DynamicTemplate.CANCELFILEEDIT', 'Cancel')))); $form->setTemplate('FilesEditorForm'); // Get the contents of the file $contents = file_get_contents(BASE_PATH . $path); $sourceTextField->setRows(20); $sourceTextField->setColumns(150); $sourceTextField->setValue($contents); $form->HelpType = null; return $form; }
/** * * @param FieldList $fields */ protected function setDeployConfigurationFields(&$fields) { if (!$this->config()->get('allow_web_editing')) { return; } if ($this->envFileExists()) { $deployConfig = new TextareaField('DeployConfig', 'Deploy config', $this->getEnvironmentConfig()); $deployConfig->setRows(40); $fields->insertAfter($deployConfig, 'ArchiveDownloaders'); return; } $noDeployConfig = new LabelField('noDeployConfig', 'Warning: This environment don\'t have deployment configuration.'); $noDeployConfig->addExtraClass('message warning'); $fields->insertAfter($noDeployConfig, 'Filename'); $createConfigField = new CheckboxField('CreateEnvConfig', 'Create Config'); $createConfigField->setDescription('Would you like to create the capistrano deploy configuration?'); $fields->insertAfter($createConfigField, 'noDeployConfig'); }
/** * @param FieldList $fields */ protected function setPipelineConfigurationFields($fields) { if (!$this->config()->get('allow_web_editing')) { return; } $config = $this->pipelineFileExists() ? file_get_contents($this->getPipelineFilename()) : ''; $deployConfig = new TextareaField('PipelineConfig', 'Pipeline config', $config); $deployConfig->setRows(40); if (!$this->pipelineFileExists()) { $deployConfig->setDescription("No pipeline is configured for this environment. Saving content here will generate a new template."); } $fields->addFieldsToTab('Root.PipelineSettings', array(FieldGroup::create(CheckboxField::create('DryRunEnabled', 'Enable dry-run?'))->setTitle('Pipeline Options')->setDescription("Allows admins to run simulated pipelines without triggering deployments or notifications."), $deployConfig)); }
public function PostForm() { $fields = FieldList::create(); if ($this->Options()->UserTitle) { $fields->push($title = TextField::create('Title', _t('MicroBlog.TITLE', 'Title'))); $title->setAttribute('placeholder', _t('MicroBlog.TITLE_PLACEHOLDER', 'Title (optional)')); } $fields->push($taf = new TextareaField('Content', _t('MicroBlog.POST', 'Post'))); $taf->setAttribute('placeholder', _t('MicroBlog.CONTENT_PLACEHOLDER', 'Add content here, eg text or a link')); $taf->setRows(3); $taf->addExtraClass('expandable'); $taf->addExtraClass('postContent'); $taf->addExtraClass('preview'); $public = CheckboxField::create('PublicUsers', 'Public users', Config::inst()->get('TimelineController', 'default_public')); $loggedIn = CheckboxField::create('LoggedInUsers', "Logged in users", Config::inst()->get('TimelineController', 'default_logged_in')); $groups = Group::get()->filter("ParentID", 0); $specificGroups = null; if (class_exists('Multisites')) { $specificGroups = Multisites::inst()->getCurrentSite()->TargetedGroups(); } else { $specificGroups = SiteConfig::current_site_config()->TargetedGroups(); } if (count($specificGroups)) { $groups = $specificGroups; } $members = Member::get(); if ($members->count() > $this->ajaxMemberLimit) { $member = AjaxSelect2Field::create('Members', "To")->setConfig('classToSearch', 'Member')->setConfig('multiple', true)->setConfig('searchFields', array('FirstName', 'Surname', 'Email'))->setConfig('resultsLimit', $this->ajaxMemberLimit); } else { $member = MultiSelect2Field::create('Members', "To", $members->map()->toArray())->setMultiple(true); } $group = MultiSelect2Field::create("Groups", "To Groups", $groups->map()->toArray())->setMultiple(true); $fields->push($public); $fields->push($loggedIn); $fields->push($member); $fields->push($group); $target = $this->getTargetFilter(); if ($target) { $fields->push(HiddenField::create('PostTarget', '', $target)); } $actions = new FieldList(new FormAction('savepost', _t('MicroBlog.SAVE', 'Add'))); $form = new Form($this, 'PostForm', $fields, $actions); $this->extend('updatePostForm', $form); return $form; }
public function getCMSFields() { $fieldBody = new TextareaField('Body', 'Inhoud (max ongeveer 90 tekens)'); $fieldBody->setRows(5); return new FieldList(new TextField('Header', 'Titel'), $fieldBody, new TextField('BtnLabel', 'Tekst op knop')); }
public function EnquiryForm() { if (!Email::validEmailAddress($this->EmailTo) || !Email::validEmailAddress($this->EmailFrom)) { return false; } if (!$this->EmailSubject) { $this->EmailSubject = 'Website Enquiry'; } $elements = $this->EnquiryFormFields(); if ($elements->count() == 0) { return false; } /* Build the fieldlist */ $fields = new FieldList(); $validator = new RequiredFields(); $jsValidator = array(); foreach ($elements as $el) { $key = $this->keyGen($el->FieldName, $el->SortOrder); $field = false; $type = false; if ($el->FieldType == 'Text') { if ($el->FieldOptions == 1) { $field = new TextField($key, htmlspecialchars($el->FieldName)); } else { $field = new TextareaField($key, htmlspecialchars($el->FieldName)); $field->setRows($el->FieldOptions); } } else { if ($el->FieldType == 'Email') { $field = new EmailField($key, htmlspecialchars($el->FieldName)); } else { if ($el->FieldType == 'Select') { $options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY); if (count($options) > 0) { $tmp = array(); foreach ($options as $o) { $tmp[trim($o)] = trim($o); } $field = new DropdownField($key, htmlspecialchars($el->FieldName), $tmp); $field->setEmptyString('[ Please Select ]'); } } else { if ($el->FieldType == 'Checkbox') { $options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY); if (count($options) > 0) { $tmp = array(); foreach ($options as $o) { $tmp[trim($o)] = trim($o); } $field = new CheckboxSetField($key, htmlspecialchars($el->FieldName), $tmp); } } else { if ($el->FieldType == 'Radio') { $options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY); if (count($options) > 0) { $tmp = array(); foreach ($options as $o) { $tmp[trim($o)] = trim($o); } $field = new OptionsetField($key, htmlspecialchars($el->FieldName), $tmp); } } else { if ($el->FieldType == 'Header') { if ($el->FieldOptions) { $field = new LiteralField(htmlspecialchars($el->FieldName), '<h4>' . htmlspecialchars($el->FieldName) . '</h4> <p class="note">' . nl2br(htmlspecialchars($el->FieldOptions)) . '</p>'); } else { $field = new HeaderField(htmlspecialchars($el->FieldName), 4); } } else { if ($el->FieldType == 'Note') { if ($el->FieldOptions) { $field = new LiteralField(htmlspecialchars($el->FieldName), '<p class="note">' . nl2br(htmlspecialchars($el->FieldOptions)) . '</p>'); } else { $field = new LiteralField(htmlspecialchars($el->FieldName), '<p class="note">' . htmlspecialchars($el->FieldName) . '</p>'); } } } } } } } } if ($field) { if ($el->RequiredField == 1) { $field->addExtraClass('required'); /* Add "Required" next to field" */ $validator->addRequiredField($key); $jsValidator[$key] = $el->FieldType; } if ($el->PlaceholderText) { $field->setAttribute('placeholder', $el->PlaceholderText); } $fields->push($field); } } if ($this->AddCaptcha) { $label = $this->CaptchaLabel; $field = new CaptchaField('CaptchaImage', $label); $field->addExtraClass('required'); $validator->addRequiredField('CaptchaImage'); $jsValidator['CaptchaImage'] = 'Text'; if ($this->CaptchaHelp) { $field->setRightTitle('<span id="CaptchaHelp">' . htmlspecialchars($this->CaptchaHelp) . '</span>'); } $fields->push($field); } $actions = new FieldList(new FormAction('SendEnquiryForm', $this->EmailSubmitButtonText)); Requirements::customScript("var EnquiryFormValidator=" . json_encode($jsValidator) . ';'); Requirements::javascript(basename(dirname(dirname(__FILE__))) . "/templates/javascript/EnquiryForm.js"); $form = new Form($this, 'EnquiryForm', $fields, $actions, $validator); return $form; }