public function updateCMSFields(FieldList $fields)
 {
     // vars
     $config = SiteConfig::current_site_config();
     $owner = $this->owner;
     // decode data into array
     $data = json_decode($owner->OpenGraphData, true);
     // @todo Add repair method if data is missing / corrupt ~ for fringe cases
     // tab
     $tab = new Tab('OpenGraph');
     // add disabled/error state if `off`
     if ($data['og:type'] === 'off') {
         $tab->addExtraClass('error');
     }
     // add the tab
     $fields->addFieldToTab('Root.Metadata', $tab, 'FullOutput');
     // new identity
     $tab = 'Root.Metadata.OpenGraph';
     // add description
     // type always visible
     $fields->addFieldsToTab($tab, array(LabelField::create('OpenGraphHeader', '@todo Information</a>')->addExtraClass('information'), DropdownField::create('OpenGraphType', '<a href="http://ogp.me/#types">og:type</a>', self::$types, $data['og:type'])));
     if ($data['og:type'] !== 'off') {
         $fields->addFieldsToTab($tab, array(ReadonlyField::create('OpenGraphURL', 'Canonical URL', $owner->AbsoluteLink()), TextField::create('OpenGraphSiteName', 'Site Name', $data['og:site_name'])->setAttribute('placeholder', $config->Title), TextField::create('OpenGraphTitle', 'Page Title', $data['og:title'])->setAttribute('placeholder', $owner->Title), TextareaField::create('OpenGraphDescription', 'Description', $data['og:description'])->setAttribute('placeholder', $owner->GenerateDescription()), UploadField::create('OpenGraphImage', 'Image<pre>type: png/jpg/gif</pre><pre>size: variable *</pre>', $owner->OpenGraphImage)->setAllowedExtensions(array('png', 'jpg', 'jpeg', 'gif'))->setFolderName(self::$SEOOpenGraphUpload . $owner->Title)->setDescription('* <a href="https://developers.facebook.com/docs/sharing/best-practices#images" target="_blank">Facebook image best practices</a>, or use any preferred Open Graph guide.')));
     }
 }
 public function getCMSFields($params = null)
 {
     //fields that shouldn't be changed once coupon is used
     $fields = new FieldList(array($tabset = new TabSet("Root", $maintab = new Tab("Main", TextField::create("Title"), CheckboxField::create("Active", "Active")->setDescription("Enable/disable all use of this discount."), HeaderField::create("ActionTitle", "Action", 3), $typefield = SelectionGroup::create("Type", array(new SelectionGroup_Item("Percent", $percentgroup = FieldGroup::create($percentfield = NumericField::create("Percent", "Percentage", "0.00")->setDescription("e.g. 0.05 = 5%, 0.5 = 50%, and 5 = 500%"), $maxamountfield = CurrencyField::create("MaxAmount", _t("MaxAmount", "Maximum Amount"))->setDescription("The total allowable discount. 0 means unlimited.")), "Discount by percentage"), new SelectionGroup_Item("Amount", $amountfield = CurrencyField::create("Amount", "Amount", "\$0.00"), "Discount by fixed amount")))->setTitle("Type"), OptionSetField::create("For", "Applies to", array("Order" => "Entire Order", "Cart" => "Cart Subtotal", "Shipping" => "Shipping Subtotal", "Items" => "Each Individual Item")), new Tab("Main", HeaderField::create("ConstraintsTitle", "Constraints", 3), LabelField::create("ConstraintsDescription", "Configure the requirements an order must meet for this discount to be valid:")), new TabSet("Constraints")))));
     if (!$this->isInDB()) {
         $fields->addFieldToTab("Root.Main", LiteralField::create("SaveNote", "<p class=\"message good\">More constraints will show up after you save for the first time.</p>"), "Constraints");
     }
     $this->extend("updateCMSFields", $fields, $params);
     if ($count = $this->getUseCount()) {
         $fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), HeaderField::create("TotalSavings", sprintf("A total of %s has been saved by customers using this discount.", $this->SavingsTotal), "3"), GridField::create("Orders", "Orders", $this->getAppliedOrders(), GridFieldConfig_RecordViewer::create()->removeComponentsByType("GridFieldViewButton"))));
     }
     if ($params && isset($params['forcetype'])) {
         $valuefield = $params['forcetype'] == "Percent" ? $percentfield : $amountfield;
         $fields->insertAfter($valuefield, "Type");
         $fields->removeByName("Type");
     } elseif ($this->Type && (double) $this->{$this->Type}) {
         $valuefield = $this->Type == "Percent" ? $percentfield : $amountfield;
         $fields->removeByName("Type");
         $fields->insertAfter($valuefield, "ActionTitle");
         $fields->replaceField($this->Type, $valuefield->performReadonlyTransformation());
         if ($this->Type == "Percent") {
             $fields->insertAfter($maxamountfield, "Percent");
         }
     }
     return $fields;
 }
 public function __construct($name, $title = null, $value = null)
 {
     $this->labelField = LabelField::create($name . "Label", self::name_to_label($name))->addExtraClass("left");
     $this->checkboxField = CheckboxField::create($name, "", $value);
     $this->labelField->setTemplate("LabeledCheckboxLabelField");
     $this->addExtraClass("field");
     parent::__construct(array($this->labelField, $this->checkboxField));
 }
 /**
  * Adds variations specific fields to the CMS.
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldsToTab('Root.Variations', array(ListboxField::create("VariationAttributeTypes", _t('ProductVariationsExtension.ATTRIBUTES', "Attributes"), ProductAttributeType::get()->map("ID", "Title")->toArray())->setMultiple(true)->setDescription(_t('ProductVariationsExtension.ATTRIBUTES_DESCRIPTION', "These are fields to indicate the way(s) each variation varies. Once selected, they can be edited on each variation.")), GridField::create("Variations", _t('ProductVariationsExtension.VARIATIONS', "Variations"), $this->owner->Variations(), GridFieldConfig_RecordEditor::create())));
     if ($this->owner->Variations()->exists()) {
         $fields->addFieldToTab('Root.Pricing', LabelField::create('variationspriceinstructinos', _t('ProductVariationsExtension.VARIATIONS_INSTRUCTIONS', "Price - Because you have one or more variations, the price can be set in the \"Variations\" tab.")));
         $fields->removeFieldFromTab('Root.Pricing', 'BasePrice');
         $fields->removeFieldFromTab('Root.Pricing', 'CostPrice');
         $fields->removeFieldFromTab('Root.Main', 'InternalItemID');
     }
 }
 /**
  * Sets up the spam question. Chooses a question at random and adds it to the form
  *
  * @param ContactForm
  */
 public function initialize(ContactForm $proxy)
 {
     if (sizeof($this->questions)) {
         $rand = rand(0, sizeof($this->questions) - 1);
         $q = $this->questions[$rand];
         $name = "SimpleQuestion_{$rand}";
         $proxy->addField(LabelField::create("SimpleSpamQuestion_label_{$rand}", $this->heading))->addField(TextField::create($name, $q['question']));
         $proxy->addOmittedField($name);
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab("Root." . _t('ProductCategory.MODELS', 'Models'), HeaderField::create("ModelHeading", _t("ProductCategory.MODELSHEADING", "Specify the models for this Product Category")));
     $fields->addFieldToTab("Root." . _t('ProductCategory.MODELS', 'Models'), LabelField::create("ModelLabel", _t("ProductCategory.MODELSLABEL", "The below entries determine the order of Models, and their associated products, on the Product Category Pages.  Also, sets the Models to appear in dropdown on each Product's page.")));
     $fields->addFieldToTab("Root." . _t('ProductCategory.MODELS', 'Models'), GridField::create('Models', _t("ProductCategory.MODELS", "Models"), $this->owner->ProductModels()->sort('Sort', 'ASC'), $config = GridFieldConfig_RecordEditor::create()));
     // Add reorder capabilties
     if ($this->owner->ProductModels()->count() >= 2) {
         $config->addComponent(new GridFieldOrderableRows('Sort'));
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName('LastSignificantChange');
     $fields->removeByName('ChangeDescription');
     if ($this->owner->LastSignificantChange !== NULL) {
         $dateTime = new DateTime($this->owner->LastSignificantChange);
         //Put these fields on the top of the First Tab's form
         $fields->first()->Tabs()->first()->getChildren()->unshift(LabelField::create("infoLastSignificantChange", "<strong>Last Significant change was at: " . "{$dateTime->Format('d/m/Y H:i')}</strong>"));
         $fields->insertAfter(CheckboxField::create("isSignificantChange", "CLEAR Last Significant change: {$dateTime->Format('d/m/Y H:i')}")->setDescription('Check and save this Record again to clear the Last Significant change date.')->setValue(FALSE), 'infoLastSignificantChange');
         $fields->insertAfter(TextField::create('ChangeDescription', 'Description of Changes')->setDescription('This is an automatically generated list of changes to important fields.'), 'isSignificantChange');
     }
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('ParentID');
     $fields->removeByName('SortID');
     $fields->removeByName('Archived');
     $fields->addFieldToTab('Root.Main', LinkField::create('LinkID', 'Link'));
     $fields->addFieldToTab('Root.Main', CompositeField::create(array(LabelField::create("LabelArchive", "Archive this carousel item?")->addExtraClass("left"), CheckboxField::create('Archived', '')))->addExtraClass("field special"));
     $imageField = $fields->dataFieldByName('Image');
     if ($imageField) {
         $imageField->setAllowedFileCategories("image")->setAllowedMaxFileNumber(1);
         if ($this->Parent() && $this->Parent()->hasMethod("ImageFolder")) {
             $imageField->setFolderName($this->Parent()->ImageFolder("carousel"));
         }
     }
     return $fields;
 }
 /**
  * Adds tabs & fields to the CMS.
  *
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     //// Favicons Tab
     $tab = 'Root.Metadata.Favicons';
     //// Favicon
     $fields->addFieldsToTab($tab, array(LabelField::create('FaviconDescription', 'Favicons are `favourite icons` used by browsers in a number of ways whenever an icon is necessary e.g. tabs, history, bookmarks, dashboards.<br />@ <a href="https://en.wikipedia.org/wiki/Favicon" target="_blank">Favicon - Wikipedia, the free encyclopedia</a>')->addExtraClass('information')));
     //// HTML4 Favicon
     // check favicon.ico & set status
     $icoStatus = ReadonlyField::create('HTML4FaviconStatus', 'Favicon ICO<pre>type: ico</pre><pre>size: (multiple)<br />16x16 & 32x32 & 64x64 px</pre>', 'favicon.ico error');
     if (Director::fileExists('favicon.ico')) {
         $icoStatus->setValue('favicon.ico found')->addExtraClass('success favicon');
     } else {
         $icoStatus->setValue('favicon.ico not found')->addExtraClass('error');
     }
     // header & fields
     $fields->addFieldsToTab($tab, array(HeaderField::create('HTML4FaviconHeader', 'HTML4 <span class="aka">( favicon.ico )</span>'), LabelField::create('HTML4FaviconDescription', 'It is recommended you simply have a `favicon.ico` file in the webroot.')->addExtraClass('information'), $icoStatus));
     //// HTML5 Favicon
     // header & fields
     $fields->addFieldsToTab($tab, array(HeaderField::create('HTML5FaviconHeader', 'HTML5 <span class="aka">( favicon.png )</span>'), LabelField::create('HTML5FaviconDescription', '@todo Description')->addExtraClass('information'), UploadField::create('HTML5Favicon', 'Favicon PNG<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload)));
     //// Pinned Icons Tab
     $tab = 'Root.Metadata.PinnedIcons';
     //// Pinned Icons Information
     $fields->addFieldsToTab($tab, array(LabelField::create('PiniconDescription', 'Pinned icons are OS-specific desktop shortcuts to pages on your website, they allow you to configure additional theming options to make pages appear more `native` / `web-app-y` within the OS.<br />Given they are OS-specific, they (obviously!) have a different format for each one :(')->addExtraClass('information')));
     //// Pinned Icon Title
     // CMS fields
     $fields->addFieldsToTab($tab, array(HeaderField::create('PiniconTitleHeader', 'Pinned Icon Title <span class="aka">( a.k.a. App Name )</span>'), LabelField::create('PiniconTitleDescription', 'When adding a link to the home screen, the user can choose a caption. By default, this is the bookmarked page title, which is usually fine. However, iOS and Windows 8 let you override this default value.')->addExtraClass('information'), TextField::create('PiniconTitle', 'Application Title')->setAttribute('placeholder', 'default: page title')));
     //// iOS Pinned Icon
     // CMS fields
     $fields->addFieldsToTab($tab, array(HeaderField::create('IOSPiniconHeader', 'iOS Pinned Icon <span class="aka">( a.k.a. Touch Icons, Web Clips )</span>'), LabelField::create('IOSPiniconDescription', 'iPhone and iPad users can pin your web site on their home screen. The link looks like a native app.<br />@ <a href="https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html" target="_blank">Configuring Web Applications - iOS Developer Library</a>')->addExtraClass('information'), UploadField::create('IOSPinicon', 'iOS Icon<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload)->setDescription('iOS will fill the transparent regions with black by default, so put your own background in!')));
     //// Android Pinned Icon
     // CMS fields
     $fields->addFieldsToTab($tab, array(HeaderField::create('AndroidPiniconHeader', 'Android Pinned Icon <span class="aka">( a.k.a. Android Chrome Icons, Launcher Icons )</span>'), LabelField::create('AndroidPiniconDescription', 'Add to Homescreen is a also a feature of Android Chrome. Your visitors can mix their natives apps and web bookmarks.<br />@ <a href="https://developer.chrome.com/multidevice/android/installtohomescreen" target="_blank">Add to Homescreen - Google Chrome</a>')->addExtraClass('information'), UploadField::create('AndroidPinicon', 'Android Icon<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload), TextField::create('AndroidPiniconThemeColor', 'Theme Color<pre>type: hex triplet</pre>')->setAttribute('placeholder', 'none')->setAttribute('size', 6)->setMaxLength(6)->setDescription('Starting with Android Lollipop, you can customize the color of the task bar in the switcher.')));
     //// Windows Pinned Icon
     // CMS fields
     $fields->addFieldsToTab($tab, array(HeaderField::create('WindowsShortcutHeader', 'Windows Pinned Icon <span class="aka">( a.k.a. Windows 8 / Metro Tiles )</span>'), LabelField::create('WindowsShortcutDescription', 'Windows 8 users can pin your web site on their desktop. Your site appears as a tile, just like a native Windows 8 app.<br />@ <a href="https://msdn.microsoft.com/en-us/library/dn455106" target="_blank">Creating custom tiles for IE11 websites (Windows)</a>')->addExtraClass('information'), UploadField::create('WindowsPinicon', 'Windows Icon<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload), TextField::create('WindowsPiniconBackgroundColor', 'Background ( Tile ) Color<pre>type: hex triplet</pre>')->setAttribute('placeholder', 'none')->setAttribute('size', 6)->setMaxLength(6)));
     // @todo Safari Pinned Tab ~ maybe ??
 }
 /**
  * Gets the title fields.
  *
  * This approach for getting fields for updateCMSFields is to be duplicated through all other modules to reduce complexity.
  *
  * @TODO i18n implementation
  *
  * @return array
  */
 public function getTitleFields()
 {
     return array(LabelField::create('FaviconDescription', 'A title tag is the main text that describes an online document. Title elements have long been considered one of the most important on-page SEO elements (the most important being overall content), and appear in three key places: browsers, search engine results pages, and external websites.<br />@ <a href="https://moz.com/learn/seo/title-tag" target="_blank">Title Tag - Learn SEO - Mozilla</a>')->addExtraClass('information'), DropdownField::create('TitleOrder', 'Page Title Order', self::$TitleOrderOptions), TextField::create('TitleSeparator', 'Page Title Separator')->setAttribute('placeholder', self::$TitleSeparatorDefault)->setAttribute('size', 1)->setMaxLength(1)->setDescription('max 1 character'), TextField::create('Title', 'Website Name'), TextField::create('TaglineSeparator', 'Tagline Separator')->setAttribute('placeholder', self::$TaglineSeparatorDefault)->setAttribute('size', 1)->setMaxLength(1)->setDescription('max 1 character'), TextField::create('Tagline', 'Tagline')->setDescription('optional'));
 }
 public function getHTMLFragments($gridField)
 {
     Utilities::include_requirements();
     $state = $gridField->State->Milkyway_SS_GridFieldUtils_RangeSlider;
     $data = ['ColumnCount' => $gridField->getColumnCount()];
     $fieldName = 'filterByRange[' . $gridField->getName() . '][' . $this->filterField . '][slider]';
     $dbField = singleton($gridField->getModelClass())->obj($this->filterField);
     $settings = array_merge(['behaviour' => 'drag-tap'], $this->scaffoldSliderSettingsForField($dbField, $gridField->getList()), $this->sliderSettings);
     if (isset($state->min) && isset($state->max)) {
         $settings['start'] = [$state->min, $state->max];
     } elseif (isset($state->value)) {
         $settings['value'] = [$state->min, $state->max];
     }
     $data['Slider'] = \RangeSliderField::create($fieldName, null, null, $settings)->addExtraClass('ss-gridfield-range-slider--field');
     $data['Button'] = \GridField_FormAction::create($gridField, 'filter', 'Filter', 'filterByRange', null)->addExtraClass('ss-gridfield-range-slider--button')->setAttribute('title', _t('GridField.Filter', 'Filter'))->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $this->filterField);
     if ($this->label !== null) {
         $data['Label'] = $this->label ?: singleton($gridField->getModelClass())->fieldLabel($this->filterField);
     }
     $data['Slider']->inputCallback = function ($fields) use($fieldName, $dbField, $settings, &$data) {
         foreach ($fields as $field) {
             $this->modifyFormFieldForDBField($dbField, $field->Render, $settings);
             if ($field->Render->hasClass('date')) {
                 $data['HasDates'] = true;
             }
         }
         if ($this->navigationLabel) {
             $fields->unshift(\ArrayData::create(['Render' => \LabelField::create($fieldName . '[label]', $this->navigationLabel)]));
         }
         if (isset($data['Label']) && $data['Label']) {
             $fields->unshift(\ArrayData::create(['Render' => \LabelField::create($fieldName . '--LABEL', $data['Label'])->addExtraClass('ss-gridfield-range-slider--holder-label')]));
         }
     };
     $data['Slider']->Field();
     $data['HideNavigation'] = $this->hideNavigation;
     return [$this->fragment => \ArrayData::create($data)->renderWith(array_merge((array) $this->template, ['GridField_RangeSlider_Row']))];
 }