/**
  * Alter the CMS Fields in order to automatically present the
  * correct ones based on current language.
  * @inheritdoc
  */
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     if (!isset(self::$collectorCache[$this->owner->class])) {
         return;
     }
     // remove all localized fields from the list (generated through scaffolding)
     foreach (self::$collectorCache[$this->owner->class] as $translatableField => $type) {
         $fields->removeByName($translatableField);
     }
     // check if we're in a translation
     if (Translatable::default_locale() != Translatable::get_current_locale()) {
         /** @var TranslatableFormFieldTransformation $transformation */
         $transformation = TranslatableFormFieldTransformation::create($this->owner);
         // iterate through all localized fields
         foreach (self::$collectorCache[$this->owner->class] as $translatableField => $type) {
             if (strpos($translatableField, Translatable::get_current_locale())) {
                 $basename = $this->getBasename($translatableField);
                 if ($field = $this->getLocalizedFormField($basename, Translatable::default_locale())) {
                     $fields->replaceField($basename, $transformation->transformFormField($field));
                 }
             }
         }
     }
 }
 public function updateCMSFields(\FieldList $fields)
 {
     if (!Permission::check('ADMIN')) {
         Requirements::css(HIDE_HISTORY_BASE . '/css/hide-history.css');
     }
     parent::updateCMSFields($fields);
 }
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     // Loop over each WidgetArea
     $has_one = $this->owner->has_one();
     foreach ($has_one as $name => $class) {
         if ($class == 'WidgetArea') {
             /*
              * Widget gridfield 
              */
             $adder = new GridFieldAddNewMultiClass();
             // Allowed classes
             $allowed = $this->owner->config()->get("allowed_widgets");
             if (is_array($allowed)) {
                 // Filter classes for creating new ones
                 $adder->setClasses($allowed);
             }
             $config = GridFieldConfig_RelationEditor::create()->removeComponentsByType("GridFieldAddNewButton")->addComponent($adder)->addComponent(new GridFieldOrderableRows('WidgetAreaSort'));
             // It's not possible to add existing through GridFieldAddExistingSearchButton since
             // it display by default $Title in its template and we want to search by $WidgetName
             $config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('WidgetName'))->setResultsFormat('$WidgetName');
             // WidgetArea's Widget GridField
             $gridField = GridField::create($name, $name, $this->owner->{$name}()->SortedWidgets(false))->setConfig($config);
             $fields->addFieldToTab("Root.{$name}", $gridField);
         }
     }
 }
 /**
  * Remove the administrators group from the possible parent group
  * 
  * @todo this check should be done in core code, since the dropdown can be simply 
  *				crafted for injecting administrators group ID
  * @param \FieldList $fields
  */
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     /* @var $parentID DropdownField */
     $parentID = $fields->fieldByName('Root.Members.ParentID');
     $parentID->setDisabledItems(array(DataObject::get_one('Group', "Code='administrators'")->ID));
 }
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $stores = $this->contentService->getStoreTypes();
     if (count($stores)) {
         $default = array('' => 'Inherit');
         $stores = array_merge($default, array_combine(array_keys($stores), array_keys($stores)));
         $fields->push(new DropdownField('StoreInCDN', 'Store content in CDN', $stores));
     }
 }
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $fields->removeByName('Sort');
     $fields->removeByName('ParentID');
     $field = new TextField('WidgetLabel', 'Widget Label');
     $fields->add($field);
     $field = new TextField('WidgetName', 'Widget Name');
     $fields->add($field);
 }
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $fields->findOrMakeTab('Root.Advertisements', _t('UniadsObject.PLURALNAME', 'Advertisements'));
     $fields->addFieldToTab('Root.Advertisements', new CheckboxField('InheritSettings', _t('UniadsObject.InheritSettings', 'Inherit parent settings')));
     if (!$this->owner->InheritSettings) {
         $conf = GridFieldConfig_RelationEditor::create();
         $conf->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('Title'));
         $grid = new GridField("Advertisements", _t('UniadsObject.PLURALNAME', 'Advertisements'), $this->owner->Ads(), $conf);
         $fields->addFieldToTab("Root.Advertisements", $grid);
         $fields->addFieldToTab('Root.Advertisements', new DropdownField('UseCampaignID', _t('UniadsObject.UseCampaign', 'Use Campaign'), $this->getListboxOptions('UniadsCampaign')));
     }
 }
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $token = $this->userToken();
     if (!$token) {
         $token = "This user token can no longer be displayed - if you do not know this value, regenerate tokens by selecting Regenerate below";
     } else {
         $token = $this->owner->ID . ':' . $token;
     }
     $readOnly = ReadonlyField::create('DisplayToken', 'Token', $token);
     $fields->addFieldToTab('Root.Main', $readOnly, 'AuthPrivateKey');
     $field = $fields->dataFieldByName('AuthPrivateKey');
     $fields->replaceField('AuthPrivateKey', $field->performReadonlyTransformation());
     $fields->removeByName('Token');
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->ShowTimeline) {
         // Create add button
         $add_button = new GridFieldAddNewButton('toolbar-header-left');
         $add_button->setButtonName('Add Event');
         // Add timeline editor
         $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent(new GridFieldOrderableRows('Sort'))->addComponent($add_button);
         $timeline_table = GridField::create('Events', false, $this->owner->Events(), $grid_config);
         $fields->addFieldToTab('Root.Timeline', $timeline_table);
     } else {
         $fields->removeByName('Events');
     }
     $fields->removeByName('ShowTimeline');
     parent::updateCMSFields($fields);
 }
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $stores = $this->contentService->getStoreTypes();
     if (count($stores)) {
         if ($this->owner->ID) {
             $default = array('' => 'Inherit');
             $stores = array_merge($default, array_combine(array_keys($stores), array_keys($stores)));
             $fields->push(new DropdownField('StoreInCDN', 'Store content in CDN', $stores));
         } else {
             if ($default = $this->contentService->getDefaultStore()) {
                 $fields->push(LiteralField::create("DefaultStoreNote", sprintf(_t('CDNFolder.DEFAULT_NOTE', '<h3>Storing in %s</h3>'), $default)));
             }
         }
     }
 }
 function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     if (ProductQuestion::get()->count()) {
         $productQuestionsDefault = $this->owner->Product()->ApplicableProductQuestions();
         $productQuestionsDefaultArray = array(0 => 0);
         if ($productQuestionsDefault && $productQuestionsDefault->count()) {
             $productQuestionsDefaultArray = $productQuestionsDefault->map("ID", "FullName")->toArray();
             $fields->addFieldToTab("Root.Questions", new CheckboxSetField("IgnoreProductQuestions", _t("ProductQuestions.IGNORE_QUESTIONS", "Ignore Questions for this variation"), $productQuestionsDefaultArray));
         }
         $productQuestionsAdditional = ProductQuestion::get()->exclude(array("ID" => array_flip($productQuestionsDefaultArray)));
         if ($productQuestionsAdditional->count()) {
             $productQuestionsAdditionalArray = $productQuestionsAdditional->map("ID", "FullName")->toArray();
             $fields->addFieldToTab("Root.Questions", new CheckboxSetField("AdditionalProductQuestions", _t("ProductQuestions.ADDITIONAL_QUESTIONS", "Additional Questions for this variation"), $productQuestionsAdditionalArray));
         }
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->ShowCarousel) {
         // Create add button
         $add_button = new GridFieldAddNewButton('toolbar-header-left');
         $add_button->setButtonName('Add Slide');
         // Add carousel editor
         $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent(new GridFieldOrderableRows('Sort'))->addComponent($add_button);
         $carousel_table = GridField::create('Slides', false, $this->owner->Slides(), $grid_config);
         $fields->addFieldToTab('Root.Carousel', $carousel_table);
     } else {
         $fields->removeByName('Slides');
     }
     $fields->removeByName('ShowCarousel');
     $fields->removeByName('CarouselWidth');
     $fields->removeByName('CarouselHeight');
     parent::updateCMSFields($fields);
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->ShowOrbit) {
         // Create add button
         $add_button = new GridFieldAddNewButton('toolbar-header-left');
         $add_button->setButtonName('Add Slide');
         // Add Orbit editor
         $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent($add_button);
         $orbit_table = GridField::create('Slides', false, $this->owner->Slides()->sort('Sort DESC'), $grid_config);
         $fields->addFieldToTab('Root.Orbit', $orbit_table);
     } else {
         $fields->removeByName('Slides');
     }
     $fields->removeByName('ShowOrbit');
     $fields->removeByName('OrbitWidth');
     $fields->removeByName('OrbitHeight');
     parent::updateCMSFields($fields);
 }
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $field = new DateField('FromDate');
     $field->setConfig('showcalendar', true);
     $field->setConfig('dateformat', 'dd/MM/YYYY');
     $field->setTitle(_t("BlogEntry.FROMDT", "Date"));
     if ($this->owner->Created == $this->owner->LastEdited) {
         // In caso di nuovo post, setto il campo FromDate ad oggi
         $now = Zend_Date::now();
         $this->owner->FromDate = $now->toString('d/M/Y');
     }
     $fields->addFieldToTab('Root.PublishedPeriod', $field);
     $field = new DateField('ToDate');
     $field->setConfig('showcalendar', true);
     $field->setConfig('dateformat', 'dd/MM/YYYY');
     $field->setTitle(_t("BlogEntry.TODT", "Date"));
     $fields->addFieldToTab('Root.PublishedPeriod', $field);
 }
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $fields->removeByName('Images');
     $name = Config::inst()->get('SimpleGalleryExtension', 'gallery_name');
     if ($this->owner->ID > 0) {
         $folder = Config::inst()->get('SimpleGalleryExtension', 'folder_path');
         if (strlen($folder) == 0) {
             $folder = 'simplegallery';
         }
         $gridFieldConfig = GridFieldConfig_RecordEditor::create();
         $bu = new GridFieldBulkImageUpload('Image', array('Title'));
         $bu->setConfig('folderName', $folder);
         $gridFieldConfig->addComponent($bu);
         $gridFieldSortableRows = new GridFieldSortableRows('SortOrder');
         $gridFieldConfig->addComponent($gridFieldSortableRows->setAppendToTop(true));
         $gridfield = new GridField("Gallery", $name, $this->SortedImages(true), $gridFieldConfig);
         $fields->addFieldToTab('Root.' . $name, $gridfield);
     }
     return $fields;
 }
 public function updateCMSFields(Fieldlist $fields)
 {
     // If Users Requests Carousel On Page
     if ($this->owner->ShowCarousel) {
         // Create Add Image Button
         $add_button = new GridFieldAddNewButton('toolbar-header-left');
         $add_button->setButtonName(_t('CarouselPage.ADDIMAGE', 'Add Image'));
         // Add Carousel Editor
         $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent($add_button);
         // Table to Display Current Carousel Images
         $carousel_table = GridField::create('CarouselElements', false, $this->owner->CarouselElements()->sort('Sort ASC'), $grid_config);
         // Creates a tab on CMS to manage Carousel on
         $fields->addFieldToTab('Root.' . _t('CarouselPage.CAROUSELTABLABEL', 'Carousel'), $carousel_table);
     } else {
         $fields->removeByName('CarouselElements');
     }
     // By default carousel settings do not appear
     $fields->removeByName('ShowCarousel');
     $fields->removeByName('CarouselWidth');
     $fields->removeByName('CarouselHeight');
     parent::updateCMSFields($fields);
 }
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $add_classes_to_cms = (array) Config::inst()->get('UntranslatableFields', 'add_classes_to_cms');
     $add_attributes_to_cms = (array) Config::inst()->get('UntranslatableFields', 'add_attributes_to_cms');
     if (!$add_attributes_to_cms && !$add_classes_to_cms) {
         return;
     }
     $untranslatable_fields = $this->getUntranslatableFields();
     foreach ($fields->dataFields() as &$field) {
         if (in_array($field->Name, $untranslatable_fields)) {
             //Mark in the CMS that this field is untranslatable
             if (!empty($add_classes_to_cms)) {
                 foreach ($add_classes_to_cms as $class) {
                     $field->addExtraClass($class);
                 }
             }
             if (!empty($add_attributes_to_cms)) {
                 foreach ($add_attributes_to_cms as $attribute => $value) {
                     $field->setAttribute($attribute, $value);
                 }
             }
         }
     }
 }
 /**
  * manipulate the cms fields of the decorated class
  *
  * @param FieldList $fields the field set of cms fields
  * 
  * @return void
  * 
  * @author Roland Lehmann <*****@*****.**>,
  *         Sebastian Diel <*****@*****.**>
  * @since 13.01.2014
  */
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $fields->insertBefore($fields->dataFieldByName('Salutation'), 'FirstName');
     $fields->dataFieldByName('Salutation')->setSource(array('Herr' => _t('SilvercartAddress.MISTER'), 'Frau' => _t('SilvercartAddress.MISSES')));
     if ($this->owner->exists()) {
         //make addresses deletable in the grid field
         $addressesGrid = $fields->dataFieldByName('SilvercartAddresses');
         $addressesConfig = $addressesGrid->getConfig();
         $addressesConfig->removeComponentsByType('GridFieldDeleteAction');
         $addressesConfig->addComponent(new GridFieldDeleteAction());
     }
     $fields->removeByName('NewsletterOptInStatus');
     $fields->removeByName('NewsletterConfirmationHash');
     $fields->removeByName('SilvercartShoppingCartID');
     $fields->removeByName('SilvercartInvoiceAddressID');
     $fields->removeByName('SilvercartShippingAddressID');
     $fields->removeByName('SilvercartCustomerConfigID');
     $fields->removeByName('SilvercartShippingAddressInUseID');
 }
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $className = $this->owner->ClassName;
     $uncompletedField = $this->owner->CopyFromFieldName();
     $uncompletedFieldWithID = $uncompletedField . "ID";
     $completedField = $this->owner->CopiedFromFieldName();
     $completedFieldWithID = $completedField . "ID";
     //remove by default
     $fields->removeByName($uncompletedFieldWithID);
     $fields->removeByName($completedFieldWithID);
     if ($this->owner->exists() && SiteConfig::current_site_config()->AllowCopyingOfRecords) {
         $changeMessage = "<p class=\"message good\">" . _t("CopyFactory.CHANGE_SETTINGS", "You can change the settings for copying in") . " <a href=\"/admin/settings/\">" . _t("CopyFactory.SITE_CONFIG", "The Site Config (see Copy Tab)") . "</a>. " . _t("CopyFactory.TURN_OFF_WHEN_NOT_IN_USE", "It is recommended you turn off the copy facility when not in use, as it will slow down the CMS.") . "\n\t\t\t\t</p>";
         //reload goes here ... @todo
         /*
         if($this->owner->ID && Session::get("CopyFactoryReload") == $this->owner->ID) {
         	Session::set("CopyFactoryReload", 0);
         	return Controller::curr()->redirectBack();
         }
         */
         if ($this->owner->{$completedFieldWithID}) {
             if ($obj = $this->owner->{$completedField}()) {
                 $fields->addFieldToTab("Root.Copy", $copyQuestionIDField = new ReadonlyField($completedField . "_EXPLANATION", _t("CopyFactory.COPIED_FROM", "This record has been copied from: "), $this->owner->CopyFactoryTitleMaker($obj)));
             }
         } elseif ($situation = SiteConfig::current_site_config()->AllowCopyingOfRecords) {
             if ($situation == 1) {
                 $message = _t('CopyFactory.DRY_RUN_ONLY', "Dry run only --- any changes below will be tested once your press 'SAVE' but no actual changes will be made.  You will find a log of intended changes below for review.");
             }
             if ($situation == 2) {
                 $message = _t('CopyFactory.THIS_IS_FOR_REAL', "Any changes below will be actioned once you press 'SAVE' - please use with care.");
             }
             $fields->addFieldToTab("Root.Copy", $copyField = new LiteralField($uncompletedFieldWithID . "_WARNING", "<p class=\"warning message\">" . $message . "</p>" . $changeMessage));
             $copyableObjects = $className::get()->exclude(array("ID" => intval($this->owner->ID) - 0))->filter(array("ClassName" => $this->owner->ClassName));
             if ($this->owner->hasMethod("additionalFiltersForCopyableObjects")) {
                 $copyAbleObjects = $this->owner->additionalFiltersForCopyableObjects($copyableObjects);
             }
             //there are objects to copy from
             if ($copyableObjects->count() > 0) {
                 $fields->addFieldToTab("Root.Copy", $copyField = new DropdownField($uncompletedFieldWithID, _t('CopyFactory.COPY_EXPLANATION', "Copy from {name}. CAREFUL - this will replace everything in the current {name} with the one copied from ...", 'Explanation on how copying works', array('name' => $this->owner->i18n_singular_name())), $copyableObjects->map("ID", CopyFactory::preferred_title_field($this->owner))));
                 $copyField->setEmptyString(_t("CopyFactory.SELECT_ONE", "--- Select One ---"));
             } else {
                 $fields->addFieldToTab("Root.Copy", $copyField = new LiteralField($uncompletedFieldWithID . "_EXPLANATION", "<h2>" . _t('CopyFactory.COPY_FACTORY_HELP_NO_RECORDS', "There are no records to copy from.") . "</h2>"));
             }
         } else {
             $fields->addFieldToTab("Root.Copy", $copyField = new LiteralField("CopyFactoryNotTurnedOn", "<h2>" . _t('CopyFactory.COPY_FACTORY_TURNED_OFF', "Copying of records is currently turned off.") . "</h2>" . $changeMessage));
         }
         if (Config::inst()->get("CopyFactory", "debug")) {
             $source = CopyFactoryLog::get()->filter(array("CopyCausingClassName" => $this->owner->ClassName, "CopyCausingClassNameID" => $this->owner->ID))->exclude(array("CopyIntoClassName" => $this->owner->ClassName, "CopyIntoClassNameID" => $this->owner->ID))->exclude(array("CopyIntoClassName" => $this->owner->ClassName, "CopyFromClassNameID" => $this->owner->ID));
             if ($source->count()) {
                 $name = "COPY_CAUSING_GRIDFIELD";
                 $title = _t("CopyFactory.COPY_CAUSING_TITLE", "Copy actions originated from this record.");
                 $fields->addFieldToTab("Root.Copy", $this->gridFieldMaker($name, $title, $source));
             }
             $source = CopyFactoryLog::get()->filter(array("CopyIntoClassName" => $this->owner->ClassName, "CopyIntoClassNameID" => $this->owner->ID))->exclude(array("CopyIntoClassName" => $this->owner->ClassName, "CopyFromClassNameID" => $this->owner->ID));
             if ($source->count()) {
                 $name = "COPY_INTO_GRIDFIELD";
                 $title = _t("CopyFactory.COPY_INTO_TITLE", "Copy actioned into this record.");
                 $fields->addFieldToTab("Root.Copy", $this->gridFieldMaker($name, $title, $source));
             }
             $source = CopyFactoryLog::get()->filter(array("CopyIntoClassName" => $this->owner->ClassName, "CopyFromClassNameID" => $this->owner->ID))->exclude(array("CopyIntoClassName" => $this->owner->ClassName, "CopyIntoClassNameID" => $this->owner->ID))->exclude(array("CopyCausingClassName" => $this->owner->ClassName, "CopyCausingClassNameID" => $this->owner->ID));
             if ($source->count()) {
                 $name = "COPY_FROM_GRIDFIELD";
                 $title = _t("CopyFactory.COPY_FROM_TITLE", "Copy actions from this record into another record.");
                 $fields->addFieldToTab("Root.Copy", $this->gridFieldMaker($name, $title, $source));
             }
         }
     } else {
     }
 }