public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Remove fields
     $fields->removeByName(array('Unique', 'Permanent', 'CanClose', 'CloseColor', 'LinkID'));
     // Add fields
     // Main tab
     $fields->addFieldToTab("Root.Main", $test = TextField::create("ButtonText")->setTitle(_t("SiteMessage.LABELBUTTONTEXT", "Button Text")));
     $fields->addFieldToTab("Root.Main", TreeDropdownField::create("PageID")->setTitle(_t("SiteMessage.LABELLINKTO", "Link to"))->setSourceObject("SiteTree"));
     $fields->addFieldToTab("Root.Main", HTMLEditorField::create("Content")->setTitle(_t("SiteMessage.LABELCONTENT", "Message content"))->setRows(15));
     // Design tab
     $fields->addFieldToTab("Root.Design", HeaderField::create("ColorSettings")->setTitle(_t("SiteMessage.HEADERCOLORSETTINGS", "Color settings")));
     $fields->addFieldToTab("Root.Design", ColorField::create("BackgroundColor")->setTitle(_t("SiteMessage.LABELBACKGROUNDCOLOR", "Background Color")));
     $fields->addFieldToTab("Root.Design", ColorField::create("TextColor")->setTitle(_t("SiteMessage.LABELTEXTCOLOR", "Text Color")));
     $fields->addFieldToTab("Root.Design", ColorField::create("ButtonColor")->setTitle(_t("SiteMessage.LABELBUTTONCOLOR", "Button Color")));
     $fields->addFieldToTab("Root.Design", ColorField::create("ButtonTextColor")->setTitle(_t("SiteMessage.LABELBUTTONTEXTCOLOR", "Button Text Color")));
     $fields->addFieldToTab("Root.Design", HeaderField::create("CloseSettings")->setTitle(_t("SiteMessage.HEADERCLOSESETTINGS", "Close button settings")));
     $fields->addFieldToTab("Root.Design", FieldGroup::create(_t("SiteMessage.LABELCANCLOSE", "Show close button?"), Checkboxfield::create("CanClose", "")));
     $fields->addFieldToTab("Root.Design", ColorField::create("CloseColor")->setTitle(_t("SiteMessage.LABELCLOSECOLOR", "Close button color")));
     // Schedule tab
     $fields->addFieldToTab("Root.Schedule", FieldGroup::create(_t("SiteMessage.LABELPERMANENT", "Is this message permanent?"), CheckboxField::create("Permanent", "")));
     $fields->addFieldToTab("Root.Schedule", $Start = new DatetimeField("Start"));
     $fields->addFieldToTab("Root.Schedule", $End = new DatetimeField("End"));
     $Start->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm')->setTitle(_t("SiteMessage.LABELSTART", "Start Date"))->getDateField('Start')->setConfig('showcalendar', TRUE);
     $End->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm')->setTitle(_t("SiteMessage.LABELSTART", "End Date"))->getDateField('End')->setConfig('showcalendar', TRUE);
     return $fields;
 }
 /**
  * Updates the CMS fields of the extended object.
  *
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     // Create Moderno Tab Set:
     $fields->addFieldToTab('Root', TabSet::create('Moderno', _t('ModernoConfigExtension.MODERNO', 'Moderno')));
     // Create Colors Tab:
     $fields->findOrMakeTab('Root.Moderno.Colors', _t('ModernoConfigExtension.COLORS', 'Colors'));
     // Create Colors Fields:
     $fields->addFieldsToTab('Root.Moderno.Colors', array(ColorField::create('ModernoHighlightColor', _t('ModernoConfigExtension.HIGHLIGHTCOLOR', 'Highlight color')), ColorField::create('ModernoLogoBkgColor', _t('ModernoConfigExtension.LOGOBACKGROUNDCOLOR', 'Logo background color')), ColorField::create('ModernoLinkColor', _t('ModernoConfigExtension.LINKCOLOR', 'Link color')), ColorField::create('ModernoProfileLinkColor', _t('ModernoConfigExtension.PROFILELINKCOLOR', 'Profile link color'))));
     // Create Branding Tab:
     $fields->findOrMakeTab('Root.Moderno.Branding', _t('ModernoConfigExtension.BRANDING', 'Branding'));
     // Create Branding Fields:
     $fields->addFieldsToTab('Root.Moderno.Branding', array(TextField::create('ModernoApplicationName', _t('ModernoConfigExtension.APPLICATIONNAME', 'Application name')), TextField::create('ModernoApplicationLink', _t('ModernoConfigExtension.APPLICATIONLINK', 'Application link')), ToggleCompositeField::create('ModernoLogoToggle', _t('ModernoConfigExtension.LOGOIMAGETOGGLETITLE', 'Logo Image'), array(UploadField::create('ModernoLogoImage', _t('ModernoConfigExtension.LOGOIMAGE', 'Logo image'))->setAllowedFileCategories('image')->setFolderName(self::get_asset_path()), FieldGroup::create(_t('ModernoConfigExtension.DIMENSIONSINPIXELS', 'Dimensions (in pixels)'), array(TextField::create('ModernoLogoImageWidth', '')->setAttribute('placeholder', _t('ModernoConfigExtension.WIDTH', 'Width')), LiteralField::create('ModernoLogoImageBy', '<i class="fa fa-times by"></i>'), TextField::create('ModernoLogoImageHeight', '')->setAttribute('placeholder', _t('ModernoConfigExtension.HEIGHT', 'Height')))), DropdownField::create('ModernoLogoImageResize', _t('ModernoConfigExtension.RESIZEMETHOD', 'Resize method'), self::get_resize_methods())->setEmptyString(' '), CheckboxField::create('ModernoHideSiteName', _t('ModernoConfigExtension.HIDESITENAME', 'Hide site name')), CheckboxField::create('ModernoSupportRetina', _t('ModernoConfigExtension.SUPPORTRETINADEVICES', 'Support Retina devices')))), ToggleCompositeField::create('ModernoLoadingToggle', _t('ModernoConfigExtension.LOADINGIMAGETOGGLETITLE', 'Loading Image'), array(UploadField::create('ModernoLoadingImage', _t('ModernoConfigExtension.LOADINGIMAGE', 'Loading image'))->setAllowedFileCategories('image')->setFolderName(self::get_asset_path()), FieldGroup::create(_t('ModernoConfigExtension.DIMENSIONSINPIXELS', 'Dimensions (in pixels)'), array(TextField::create('ModernoLoadingImageWidth', '')->setAttribute('placeholder', _t('ModernoConfigExtension.WIDTH', 'Width')), LiteralField::create('ModernoLoadingImageBy', '<i class="fa fa-times by"></i>'), TextField::create('ModernoLoadingImageHeight', '')->setAttribute('placeholder', _t('ModernoConfigExtension.HEIGHT', 'Height')))), DropdownField::create('ModernoLoadingImageResize', _t('ModernoConfigExtension.RESIZEMETHOD', 'Resize method'), self::get_resize_methods())->setEmptyString(' ')))));
 }
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $title = Textfield::create('Title', 'Title');
     $fields->push($title);
     if ($this->IsInDB()) {
         // Allowed Fields
         $allowed = $this->Consultation()->Fields()->filterByCallback(function ($field) {
             return $field->getHasAddableOptions();
         });
         $dropdown_field = DropdownField::create('FieldID', 'Field', $allowed->map())->setEmptyString('Select field to report on...');
         $fields->push($dropdown_field);
         // Report Types
         $dropdown_types = DropdownField::create('Type', 'Type', $this->getAllowedReportTypes());
         $fields->push($dropdown_types);
         $fields->push(ColorField::create('Colour', 'Colour'));
     } else {
         $warning = LiteralField::create('Warning', 'Please save this component to edit it.');
         $fields->push($warning);
     }
     return $fields;
 }
コード例 #4
0
 public static function set_source_file_location($s)
 {
     self::$source_file_location = $s;
 }
コード例 #5
0
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     /** @var  $fields */
     $fields = parent::getCMSFields();
     /** =========================================
      * Settings
      * ==========================================*/
     /** -----------------------------------------
      * Contact Page
      * ----------------------------------------*/
     $fields->addFieldToTab('Root.Main', HeaderField::create('Settings', _t('ContactPage.SettingsHeading', 'Settings')), 'Content');
     /** @var TextField $mailTo */
     $fields->addFieldToTab('Root.Main', $mailTo = TextField::create('MailTo', _t('ContactPage.Email', 'Email')), 'Content');
     $mailTo->setRightTitle('Choose an email address for the contact page to send to');
     /** @var TextField $mailCC */
     $fields->addFieldToTab('Root.Main', $mailCC = TextField::create('MailCC', _t('ContactPage.MailCC', 'Cc')), 'Content');
     $mailCC->setRightTitle(_t('ContactPage.MailCCRightTitle', 'Choose an email, or emails to CC (separate emails with a comma and no space e.g: email1@website.com,email2@website.com)'));
     /** @var TextField $mailBCC */
     $fields->addFieldToTab('Root.Main', $mailBCC = TextField::create('MailBCC', _t('ContactPage.MailBCC', 'Bcc')), 'Content');
     /** @var TextareaField $submissionText */
     $fields->addFieldToTab('Root.Main', $submissionText = TextareaField::create('SubmitText', _t('ContactPage.SubmitText', 'Submission Text')), 'Content');
     $submissionText->setRightTitle(_t('ContactPage.SubmitTextRightTitle', 'Text for contact form submission once the email has been sent i.e "Thank you for your enquiry"'));
     $fields->addFieldToTab('Root.Main', HeaderField::create('RecaptchaHeading', _t('ContactPage.RecaptchaHeading', 'reCaptcha'), 4), 'Content');
     $fields->addFieldToTab('Root.Main', LiteralField::create('RecaptchaDescription', _t('ContactPage.RecaptchaDescription', '<p>By filling in the Site Key, and Secret Key fields a reCaptcha field will be added to the form to protect against spam.</p>')), 'Content');
     $fields->addFieldToTab('Root.Main', LiteralField::create('RecaptchaDescriptionInstructions', _t('ContactPage.RecaptchaDescriptionInstructions', '<div class="message"><p><strong>Note:</strong> you can get your SiteKey, and SecretKey at this address <a href="https://www.google.com/recaptcha/" target="_blank">https://www.google.com/recaptcha/</a></p></div>')), 'Content');
     $fields->addFieldToTab('Root.Main', TextField::create('ReCaptchaSiteKey', _t('ContactPage.RecaptchaSiteKey', 'Site Key')), 'Content');
     $fields->addFieldToTab('Root.Main', TextField::create('ReCaptchaSecretKey', _t('ContactPage.RecaptchaSecretKey', 'Secret Key')), 'Content');
     /** -----------------------------------------
      * Google Map
      * ----------------------------------------*/
     $fields->addFieldToTab('Root.Map', HeaderField::create('MapHeading', _t('ContactPage.MapHeading', 'Map')));
     $fields->addFieldToTab('Root.Map', LiteralField::create('MapDescription', _t('ContactPage.MapDescription', '<p>The Latitude and Longitude fields are required to be populated in order for the map to be displayed.</p>')));
     $fields->addFieldToTab('Root.Map', Textfield::create('GoogleAPI', _t('ContactPage.GoogleAPI', 'Maps API (Optional)')));
     $fields->addFieldToTab('Root.Map', Textfield::create('Latitude', _t('ContactPage.Latitude', 'Latitude')));
     $fields->addFieldToTab('Root.Map', Textfield::create('Longitude', _t('ContactPage.Longitude', 'Longitude')));
     $fields->addFieldToTab('Root.Map', LiteralField::create('MapDescriptionInstructions', _t('ContactPage.MapDescriptionInstructions', '<div class="field"><label class="right"><a href="https://support.google.com/maps/answer/18539" target="_blank">How do I find my latitude/longitude?</a></label></div>')));
     /** @var NumericField $mapZoom */
     $fields->addFieldToTab('Root.Map', $mapZoom = NumericField::create('MapZoom', _t('ContactPage.Zoom', 'Zoom')));
     $mapZoom->setRightTitle(_t('ContactPage.Zoom', 'Zoom level: 1-22 - The higher the number the more zoomed in the map will be.'));
     /**
      * If only one of the colours is set, display a warning.
      */
     if (!$this->MapColor && $this->WaterColor || $this->MapColor && !$this->WaterColor) {
         $fields->addFieldToTab('Root.Map', LiteralField::create('MApColorWarning', _t('ContactPage.MapColorWarning', '<div class="message warning"><p><strong>Note:</strong> To activate the map styling, both Map Colour and Water Colour must be set.</p></div>')));
     }
     $fields->addFieldToTab('Root.Map', ColorField::create('MapColor', _t('ContactPage.MapColor', 'Map Colour (Optional)')));
     $fields->addFieldToTab('Root.Map', ColorField::create('WaterColor', _t('ContactPage.WaterColor', 'Water Colour (Optional)')));
     /** @var TextField $mapSaturation */
     $fields->addFieldToTab('Root.Map', $mapSaturation = TextField::create('MapSaturation', _t('ContactPage.MapSaturation', 'Saturation (Optional)')));
     $mapSaturation->setRightTitle(_t('ContactPage.MapSaturationRightTitle', 'A range of -100 to 100, -100 being completely grayscale.'));
     $fields->addFieldToTab('Root.Map', CheckboxField::create('MapMarker', _t('ContactPage.MapMarker', 'Show map marker')));
     return $fields;
 }