/**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     // Redo LDAP metadata fields as read-only and move to LDAP tab.
     $ldapMetadata = array();
     $fields->replaceField('IsImportedFromLDAP', $ldapMetadata[] = new ReadonlyField('IsImportedFromLDAP', _t('LDAPMemberExtension.ISIMPORTEDFROMLDAP', 'Is user imported from LDAP/AD?')));
     $fields->replaceField('GUID', $ldapMetadata[] = new ReadonlyField('GUID'));
     $fields->replaceField('IsExpired', $ldapMetadata[] = new ReadonlyField('IsExpired', _t('LDAPMemberExtension.ISEXPIRED', 'Has user\'s LDAP/AD login expired?')));
     $fields->replaceField('LastSynced', $ldapMetadata[] = new ReadonlyField('LastSynced', _t('LDAPMemberExtension.LASTSYNCED', 'Last synced')));
     $fields->addFieldsToTab('Root.LDAP', $ldapMetadata);
     if ($this->owner->IsImportedFromLDAP) {
         // Transform the automatically mapped fields into read-only.
         $mappings = Config::inst()->get('Member', 'ldap_field_mappings');
         foreach ($mappings as $ldap => $ss) {
             $field = $fields->dataFieldByName($ss);
             if (!empty($field)) {
                 // This messes up the Member_Validator, preventing the record from saving :-(
                 // $field->setReadonly(true);
                 $field->setTitle($field->Title() . _t('LDAPMemberExtension.IMPORTEDFIELD', ' (imported)'));
             }
         }
         // Display alert message at the top.
         $message = _t('LDAPMemberExtension.INFOIMPORTED', 'This user is automatically imported from LDAP. ' . 'Manual changes to imported fields will be removed upon sync.');
         $fields->addFieldToTab('Root.Main', new LiteralField('Info', sprintf('<p class="message warning">%s</p>', $message)), 'FirstName');
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $avatar = new UploadField('Avatar', 'Avatar');
     $avatar->setFolderName('member/avatar');
     $fields->replaceField('Avatar', $avatar);
     $fields->removeByName('SortOrder');
 }
 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");
     }
     if ($count = $this->getUseCount()) {
         $fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), 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->makeFieldReadonly("Type");
     } else {
         if ($this->Type && (double) $this->{$this->Type}) {
             $valuefield = $this->Type == "Percent" ? $percentfield : $amountfield;
             $fields->makeFieldReadonly("Type");
             $fields->insertAfter($valuefield, "ActionTitle");
             $fields->replaceField($this->Type, $valuefield->performReadonlyTransformation());
             if ($this->Type == "Percent") {
                 $fields->insertAfter($maxamountfield, "Percent");
             }
         }
     }
     $this->extend("updateCMSFields", $fields, $params);
     return $fields;
 }
 /**
  * Get the CMS view of the instance. This is used to display the log of
  * this workflow, and options to reassign if the workflow hasn't been
  * finished yet
  *
  * @return \FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList();
     if (Permission::check('REASSIGN_ACTIVE_WORKFLOWS')) {
         if ($this->WorkflowStatus == 'Paused' || $this->WorkflowStatus == 'Active') {
             $cmsUsers = Member::mapInCMSGroups();
             $fields->push(new HiddenField('DirectUpdate', '', 1));
             $fields->push(new HeaderField('InstanceReassignHeader', _t('WorkflowInstance.REASSIGN_HEADER', 'Reassign workflow')));
             $fields->push(new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Users'), $cmsUsers));
             $fields->push(new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Groups'), 'Group'));
         }
     }
     if ($this->canEdit()) {
         $action = $this->CurrentAction();
         if ($action->exists()) {
             $actionFields = $this->getWorkflowFields();
             $fields->merge($actionFields);
             $transitions = $action->getValidTransitions();
             if ($transitions) {
                 $fields->replaceField('TransitionID', DropdownField::create("TransitionID", "Next action", $transitions->map()));
             }
         }
     }
     $items = WorkflowActionInstance::get()->filter(array('Finished' => 1, 'WorkflowID' => $this->ID));
     $grid = new GridField('Actions', _t('WorkflowInstance.ActionLogTitle', 'Log'), $items);
     $fields->push($grid);
     return $fields;
 }
 /**
  * Setup the CMS Fields
  *
  * @param FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     if (!$this->supportsElemental()) {
         return false;
     }
     // add an empty holder for content as some module explicitly use insert
     // after content.
     $fields->replaceField('Content', new LiteralField('Content', ''));
     $adder = new ElementalGridFieldAddNewMultiClass();
     $list = $this->getAvailableTypes();
     $adder->setClasses($list);
     $area = $this->owner->ElementArea();
     if (!$area->exists() || !$area->isInDB()) {
         $area->write();
         $this->owner->ElementAreaID = $area->ID;
         $this->owner->write();
     }
     $gridField = GridField::create('ElementArea', Config::inst()->get("ElementPageExtension", 'elements_title'), $this->owner->ElementArea()->Elements(), GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldAddExistingAutocompleter')->addComponent(new ElementalGridFieldAddExistingAutocompleter())->addComponent(new ElementalGridFieldDeleteAction())->addComponent($adder)->addComponent(new GridFieldSortableRows('Sort')));
     $config = $gridField->getConfig();
     $paginator = $config->getComponentByType('GridFieldPaginator');
     $paginator->setItemsPerPage(100);
     $config->removeComponentsByType('GridFieldDetailForm');
     $config->addComponent(new VersionedDataObjectDetailsForm());
     $fields->addFieldToTab('Root.Main', $gridField);
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     // Changed Type to an optionset because drop down does not work sometimes in a dialog :-(
     // Also move sitetree to first item, I like that better.
     $types = $this->owner->config()->get('types');
     $i18nTypes = array();
     // Move SiteTree to first
     $i18nTypes['SiteTree'] = _t('Linkable.TYPE' . strtoupper('SiteTree'), $types['SiteTree']);
     foreach ($types as $key => $label) {
         $i18nTypes[$key] = _t('Linkable.TYPE' . strtoupper($key), $label);
     }
     $fields->replaceField('Type', OptionsetField::create('Type', _t('Linkable.LINKTYPE', 'Link Type'), $i18nTypes), 'OpenInNewWindow');
     // Chris Bolt, replaced file choose with an upload field
     $fields->replaceField('FileID', UploadField::create('File', _t('Linkable.FILE', 'File')), 'OpenInNewWindow');
     // Chris Bolt, added functionality for adding custom attributes
     $fields->addFieldToTab('Root.Main', TextField::create('ExtraAttributes', 'Extra Attributes')->setDescription('e.g. onClick="_gaq.push([\'_trackEvent\', \'whitepaper\', \'download\', pdfName, pdfValue, true]);"'));
 }
 public function updateCMSFields(FieldList $fields)
 {
     Requirements::javascript(TINYMCE4_DIR . "/javascript/HtmlEditorField.js");
     Requirements::css(TINYMCE4_DIR . "/css/HtmlEditorField.css");
     if (Member::currentUser()) {
         CustomHtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
     }
     $fields->replaceField("Content", CustomHtmlEditorField::create("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", 'HTML editor title'))->addExtraClass('stacked'));
 }
 /**
  * Adds a field the the cms allowing the user to choose a secondary identifier based on templates
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     /** @var Config_ForClass $config */
     $config = $this->owner->config();
     $fields->replaceField('SecondaryIdentifier', $field = new DropdownField('SecondaryIdentifier', 'Secondary Identifier', $this->getAvailableSecondaryIdentifiers($config->get('secondaryIdentifierAsTemplatesMap', Config::UNINHERITED))));
     if (Config::inst()->forClass(__CLASS__)->get('HasDefault')) {
         $field->setHasEmptyDefault(true);
         $field->setEmptyString('Default');
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     // remove if already scaffolded so we can add as editable grid field
     $fields->removeByName(self::RelationshipName);
     if ($this->showOnCMSForm()) {
         // hide the content field if we have sections.
         $fields->replaceField('Content', new HiddenField('Content'));
         $gridField = $this->makeEditableGridField(self::RelationshipName, $this->getFieldLabel(), self::RelatedModelClass, $this->ArtisanHasSections());
         $fields->addFieldToTab(self::get_config_setting('tab_name'), $gridField);
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     if (Config::inst()->get('MarkdownExtension', 'replace_html_fields')) {
         foreach ($fields->dataFields() as $field) {
             if ($field instanceof HtmlEditorField) {
                 $attributes = $field->getAttributes();
                 $fields->replaceField($field->getName(), MarkdownEditorField::create($field->getName(), $field->Title())->setRows($attributes['rows']));
             }
         }
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->UserSubmissionHolder()) {
         $fields->removeByName($this->owner->config()->remove_fields);
         $whitelist_fields = $this->owner->config()->whitelist_fields;
         foreach ($fields->dataFields() as $field) {
             if (!in_array($field->getName(), $whitelist_fields)) {
                 $fields->replaceField($field->getName(), $field->performReadonlyTransformation());
             }
         }
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     // if there are Models set in the Product Category then use a dropdown to select
     if ($this->owner->Parent && $this->owner->Parent->ProductModels()->count()) {
         $fields->replaceField('Model', DropdownField::create('Model', _t("Product.MODELREQUIRED", "Model (required)"), ArrayLib::valuekey($this->owner->Parent->ProductModels()->column('Title')))->setEmptyString(_t("Product.MODELSELECT", "Select..."))->setAttribute('Required', true));
     } else {
         // Update Model for extended length
         // see config.yml for updated db settings
         $model = $fields->dataFieldByName('Model');
         $model->setMaxLength(100);
     }
 }
 /**
  * Setup the CMS Fields
  *
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     // redirector pages should not have elements
     if (is_a($this->owner, 'RedirectorPage')) {
         return;
     } else {
         if ($ignored = Config::inst()->get('ElementPageExtension', 'ignored_classes')) {
             foreach ($ignored as $check) {
                 if (is_a($this->owner, $check)) {
                     return;
                 }
             }
         }
     }
     // add an empty holder for content as some module explicitly use insert
     // after content.
     $fields->replaceField('Content', new LiteralField('Content', ''));
     $adder = new ElementalGridFieldAddNewMultiClass();
     if (is_array($this->owner->config()->get('allowed_elements'))) {
         $list = $this->owner->config()->get('allowed_elements');
     } else {
         $classes = ClassInfo::subclassesFor('BaseElement');
         $list = array();
         unset($classes['BaseElement']);
         foreach ($classes as $class) {
             $inst = singleton($class);
             if ($inst->canCreate()) {
                 $list[$class] = singleton($class)->i18n_singular_name();
             }
         }
     }
     if (method_exists($this->owner, 'sortElementalOptions')) {
         $this->owner->sortElementalOptions($list);
     } else {
         asort($list);
     }
     $adder->setClasses($list);
     $area = $this->owner->ElementArea();
     if (!$area->exists() || !$area->isInDB()) {
         $area->write();
         $this->owner->ElementAreaID = $area->ID;
         $this->owner->write();
     }
     $gridField = GridField::create('ElementArea', Config::inst()->get("ElementPageExtension", 'elements_title'), $this->owner->ElementArea()->Elements(), GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldAddExistingAutocompleter')->removeComponentsByType('GridFieldDeleteAction')->addComponent(new GridFieldDeleteAction(false))->addComponent($adder)->addComponent(new GridFieldSortableRows('Sort')));
     $config = $gridField->getConfig();
     $paginator = $config->getComponentByType('GridFieldPaginator');
     $paginator->setItemsPerPage(100);
     $config->removeComponentsByType('GridFieldDetailForm');
     $config->addComponent(new VersionedDataObjectDetailsForm());
     $fields->addFieldToTab('Root.Main', $gridField, 'Metadata');
     return $fields;
 }
 /**
  * Updates the form fields for address'es to use a dropdown for the state and an additional field for the other state
  * @param {FieldList} $fields Fields to modify
  */
 public function updateFormFields(FieldList $fields)
 {
     $stateField = $fields->dataFieldByName('State');
     if ($stateField) {
         $newStateField = new GroupedDropdownField('State', $stateField->Title, array(_t('FedExStateProvinceExtension.UNITED_STATES', '_United States') => array('AL' => _t('FedExStateProvinceExtension.US_AL', '_Alabama'), 'LA' => _t('FedExStateProvinceExtension.US_LA', '_Louisiana'), 'OK' => _t('FedExStateProvinceExtension.US_OK', '_Oklahoma'), 'AK' => _t('FedExStateProvinceExtension.US_AK', '_Alaska'), 'ME' => _t('FedExStateProvinceExtension.US_ME', '_Maine'), 'OR' => _t('FedExStateProvinceExtension.US_OR', '_Oregon'), 'AZ' => _t('FedExStateProvinceExtension.US_AZ', '_Arizona'), 'MD' => _t('FedExStateProvinceExtension.US_MD', '_Maryland'), 'PA' => _t('FedExStateProvinceExtension.US_PA', '_Pennsylvania'), 'AR' => _t('FedExStateProvinceExtension.US_AR', '_Arkansas'), 'MA' => _t('FedExStateProvinceExtension.US_MA', '_Massachusetts'), 'RI' => _t('FedExStateProvinceExtension.US_RI', '_Rhode Island'), 'CA' => _t('FedExStateProvinceExtension.US_CA', '_California'), 'MI' => _t('FedExStateProvinceExtension.US_MI', '_Michigan'), 'SC' => _t('FedExStateProvinceExtension.US_SC', '_South Carolina'), 'CO' => _t('FedExStateProvinceExtension.US_CO', '_Colorado'), 'MN' => _t('FedExStateProvinceExtension.US_MN', '_Minnesota'), 'SD' => _t('FedExStateProvinceExtension.US_SD', '_South Dakota'), 'CT' => _t('FedExStateProvinceExtension.US_CT', '_Connecticut'), 'MS' => _t('FedExStateProvinceExtension.US_MS', '_Mississippi'), 'TN' => _t('FedExStateProvinceExtension.US_TN', '_Tennessee'), 'DE' => _t('FedExStateProvinceExtension.US_DE', '_Delaware'), 'MO' => _t('FedExStateProvinceExtension.US_MO', '_Missouri'), 'TX' => _t('FedExStateProvinceExtension.US_TX', '_Texas'), 'DC' => _t('FedExStateProvinceExtension.US_DC', '_District of Columbia'), 'MT' => _t('FedExStateProvinceExtension.US_MT', '_Montana'), 'UT' => _t('FedExStateProvinceExtension.US_UT', '_Utah'), 'FL' => _t('FedExStateProvinceExtension.US_FL', '_Florida'), 'NE' => _t('FedExStateProvinceExtension.US_NE', '_Nebraska'), 'VT' => _t('FedExStateProvinceExtension.US_VT', '_Vermont'), 'GA' => _t('FedExStateProvinceExtension.US_GA', '_Georgia'), 'NV' => _t('FedExStateProvinceExtension.US_NV', '_Nevada'), 'VA' => _t('FedExStateProvinceExtension.US_VA', '_Virginia'), 'HI' => _t('FedExStateProvinceExtension.US_HI', '_Hawaii'), 'NH' => _t('FedExStateProvinceExtension.US_NH', '_New Hampshire'), 'WA' => _t('FedExStateProvinceExtension.US_WA', '_Washington State'), 'ID' => _t('FedExStateProvinceExtension.US_ID', '_Idaho'), 'NJ' => _t('FedExStateProvinceExtension.US_NJ', '_New Jersey'), 'WV' => _t('FedExStateProvinceExtension.US_WV', '_West Virginia'), 'IL' => _t('FedExStateProvinceExtension.US_IL', '_Illinois'), 'NM' => _t('FedExStateProvinceExtension.US_NM', '_New Mexico'), 'WI' => _t('FedExStateProvinceExtension.US_WI', '_Wisconsin'), 'IN' => _t('FedExStateProvinceExtension.US_IN', '_Indiana'), 'NY' => _t('FedExStateProvinceExtension.US_NY', '_New York'), 'WY' => _t('FedExStateProvinceExtension.US_WY', '_Wyoming'), 'IA' => _t('FedExStateProvinceExtension.US_IA', '_Iowa'), 'NC' => _t('FedExStateProvinceExtension.US_NC', '_North Carolina'), 'PR' => _t('FedExStateProvinceExtension.US_PR', '_Puerto Rico'), 'KS' => _t('FedExStateProvinceExtension.US_KS', '_Kansas'), 'ND' => _t('FedExStateProvinceExtension.US_ND', '_North Dakota'), 'KY' => _t('FedExStateProvinceExtension.US_KY', '_Kentucky'), 'OH' => _t('FedExStateProvinceExtension.US_OH', '_Ohio')), _t('FedExStateProvinceExtension.CANADA', '_Canada') => array('AB' => _t('FedExStateProvinceExtension.CA_AB', '_Alberta'), 'BC' => _t('FedExStateProvinceExtension.CA_BC', '_British Columbia'), 'MB' => _t('FedExStateProvinceExtension.CA_MB', '_Manitoba'), 'NB' => _t('FedExStateProvinceExtension.CA_NB', '_New Brunswick'), 'NL' => _t('FedExStateProvinceExtension.CA_NL', '_Newfoundland'), 'NT' => _t('FedExStateProvinceExtension.CA_NT', '_Northwest Territories and Labrador'), 'NS' => _t('FedExStateProvinceExtension.CA_NS', '_Nova Scotia'), 'NU' => _t('FedExStateProvinceExtension.CA_NU', '_Nunavut'), 'ON' => _t('FedExStateProvinceExtension.CA_ON', '_Ontario'), 'PE' => _t('FedExStateProvinceExtension.CA_PE', '_Prince Edward Island'), 'QC' => _t('FedExStateProvinceExtension.CA_QC', '_Quebec'), 'SK' => _t('FedExStateProvinceExtension.CA_SK', '_Saskatchewan'), 'YT' => _t('FedExStateProvinceExtension.CA_YT', '_Yukon')), '' => _t('FedExStateProvinceExtension.OTHER', '_Other')));
         $newStateField->setDescription = $stateField->getDescription();
         $newStateField->setForm($stateField->getForm());
         $fields->replaceField('State', $newStateField);
         $fields->insertAfter($otherState = new TextField('OtherState', _t('FedExStateProvinceExtension.OTHER_STATE', '_Other State'), null, 200), 'State');
         $otherState->setDescription(_t('FedExStateProvinceExtension.OTHER_DESC', '_If you chose other as your state please place it here'));
         $otherState->setForm($stateField->getForm());
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->Parent()->config()->get('hide_categories')) {
         $fields->removeByName('Categories');
     } else {
         if ($this->owner->config()->get('use_addnewlistboxfield')) {
             // Remove this once tagfield us fixed
             $list = new AddNewListboxField('Categories', 'Categories', $this->owner->Parent()->Categories()->map("ID", "Title")->toArray());
             $list->setMultiple(true);
             $list->setModel('BlogCategory')->setDialogTitle('New Category')->setBeforeWriteCallback(array($this->owner, 'AddNewDropDownFieldCategorisationCallback'));
             $fields->replaceField('Categories', $list);
         }
     }
     if ($this->owner->Parent()->config()->get('hide_tags')) {
         $fields->removeByName('Tags');
     } else {
         if ($this->owner->config()->get('use_addnewlistboxfield')) {
             // Remove this once tagfield us fixed
             $list = new AddNewListboxField('Tags', 'Tags', $this->owner->Parent()->Tags()->map("ID", "Title")->toArray());
             $list->setMultiple(true);
             $list->setModel('BlogTag')->setDialogTitle('New Tag')->setBeforeWriteCallback(array($this->owner, 'AddNewDropDownFieldCategorisationCallback'));
             $fields->replaceField('Tags', $list);
         }
     }
     if ($this->owner->config()->get('hide_authors')) {
         $fields->removeByName("Authors");
         $fields->removeByName("AuthorNames");
     }
     if ($this->owner->config()->get('hide_summary')) {
         $fields->removeByName("CustomSummary");
     }
     if ($this->owner->config()->get('hide_image')) {
         $fields->removeByName("FeaturedImage");
     } else {
         // Add description about ContentImage
         $fields->dataFieldByName('FeaturedImage')->setDescription(_t('BlogPost.FEATURED_IMAGE_DESCRIPTION', 'If no image is supplied then the first image found in the article content will be used if one exists.'));
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     // Add read-only LDAP metadata fields.
     $fields->replaceField('IsImportedFromLDAP', $readOnly[] = new ReadonlyField('IsImportedFromLDAP', _t('LDAPGroupExtension.ISIMPORTEDFROMLDAP', 'Is group imported from LDAP/AD?')));
     $fields->addFieldToTab('Root.LDAP', new ReadonlyField('GUID'));
     $fields->addFieldToTab('Root.LDAP', new ReadonlyField('DN'));
     $fields->addFieldToTab('Root.LDAP', new ReadonlyField('LastSynced', _t('LDAPGroupExtension.LASTSYNCED', 'Last synced')));
     if ($this->owner->IsImportedFromLDAP) {
         $fields->replaceField('Title', new ReadonlyField('Title'));
         $fields->replaceField('Description', new ReadonlyField('Description'));
         // Surface the code which is normally hidden from the CMS user.
         $fields->addFieldToTab('Root.Members', new ReadonlyField('Code'), 'Members');
         $message = _t('LDAPGroupExtension.INFOIMPORTED', 'This group is automatically imported from LDAP.');
         $fields->addFieldToTab('Root.Members', new LiteralField('Info', sprintf('<p class="message warning">%s</p>', $message)), 'Title');
         $fields->addFieldToTab('Root.LDAP', new ReadonlyField('LDAPGroupMappingsRO', _t('LDAPGroupExtension.AUTOMAPPEDGROUPS', 'Automatically mapped LDAP Groups'), implode('; ', $this->owner->LDAPGroupMappings()->column('DN'))));
     } else {
         $field = GridField::create('LDAPGroupMappings', _t('LDAPGroupExtension.MAPPEDGROUPS', 'Mapped LDAP Groups'), $this->owner->LDAPGroupMappings());
         $config = GridFieldConfig_RecordEditor::create();
         $config->getComponentByType('GridFieldAddNewButton')->setButtonName(_t('LDAPGroupExtension.ADDMAPPEDGROUP', 'Add LDAP group mapping'));
         $field->setConfig($config);
         $fields->addFieldToTab('Root.LDAP', $field);
     }
 }
 /**
  * Transform the named field into a readonly feld.
  *
  * @param string|FormField
  * @return bool
  */
 public function makeFieldReadonly($field)
 {
     $fieldName = $field instanceof FormField ? $field->getName() : $field;
     // Iterate on items, looking for the applicable field
     foreach ($this->children as $i => $item) {
         if ($item instanceof CompositeField) {
             if ($item->makeFieldReadonly($fieldName)) {
                 return true;
             }
         } elseif ($item instanceof FormField && $item->getName() == $fieldName) {
             // Once it's found, use FormField::transform to turn the field into a readonly version of itself.
             $this->children->replaceField($fieldName, $item->transform(new ReadonlyTransformation()));
             // A true results indicates that the field was found
             return true;
         }
     }
     return false;
 }
    public function updateCMSFields(\FieldList $fields)
    {
        if ($this->owner->Has2FA) {
            // HACK HACK HACK
            $field = \LiteralField::create('PrintableTOTPToken', sprintf('<div id="PrintableTOTPToken" class="field readonly">
	<label class="left" for="Form_EditForm_PrintableTOTPToken">TOTP Token</label>
	<div class="middleColumn">
	<span id="Form_EditForm_PrintableTOTPToken" class="readonly">
		%s<br />
<img src="%s" width=175 height=175 />
	</span>
	</div>
</div>', $this->getPrintableTOTPToken(), $this->generateQRCode()));
            $fields->replaceField('TOTPToken', $field);
        } else {
            $fields->removeByName('TOTPToken');
        }
    }
Example #19
0
 /**
  * Transform the named field into a readonly feld.
  * 
  * @param string|FormField
  */
 function makeFieldReadonly($field)
 {
     $fieldName = $field instanceof FormField ? $field->Name() : $field;
     // Iterate on items, looking for the applicable field
     foreach ($this->children as $i => $item) {
         if ($item->isComposite()) {
             $item->makeFieldReadonly($fieldName);
         } else {
             // Once it's found, use FormField::transform to turn the field into a readonly version of itself.
             if ($item->Name() == $fieldName) {
                 $this->children->replaceField($fieldName, $item->transform(new ReadonlyTransformation()));
                 // Clear an internal cache
                 $this->sequentialSet = null;
                 // A true results indicates that the field was foudn
                 return true;
             }
         }
     }
     return false;
 }
 /**
  * Setup the CMS Fields
  *
  * @param FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     if (!$this->supportsElemental()) {
         return;
     }
     // add an empty holder for content as some module explicitly use insert
     // after content.
     $fields->replaceField('Content', new LiteralField('Content', ''));
     $adder = new ElementalGridFieldAddNewMultiClass();
     $list = $this->getAvailableTypes();
     if ($list) {
         $adder->setClasses($list);
     }
     $area = $this->owner->ElementArea();
     if ($this->owner->exists() && (!$area->exists() || !$area->isInDB())) {
         $area->write();
         $this->owner->ElementAreaID = $area->ID;
         $this->owner->write();
     }
     $gridField = GridField::create('ElementArea', Config::inst()->get("ElementPageExtension", 'elements_title'), $area->AllElements(), GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldSortableHeader')->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldAddExistingAutocompleter')->addComponent($autocomplete = new ElementalGridFieldAddExistingAutocompleter())->addComponent(new ElementalGridFieldDeleteAction())->addComponent(new GridFieldTitleHeader())->addComponent($adder)->addComponent(new GridFieldSortableRows('Sort')));
     if ($list) {
         $autocomplete->setSearchList(BaseElement::get()->filter('ClassName', array_keys($list)));
     }
     $config = $gridField->getConfig();
     $paginator = $config->getComponentByType('GridFieldPaginator');
     $paginator->setItemsPerPage(100);
     if (!$this->owner->config()->disable_element_publish_button) {
         $config->removeComponentsByType('GridFieldDetailForm');
         $config->addComponent($obj = new VersionedDataObjectDetailsForm());
     }
     if ($this->owner instanceof SiteTree && $fields->findOrMakeTab('Root.Main')->fieldByName('Metadata')) {
         $fields->addFieldToTab('Root.Main', $gridField, 'Metadata');
     } else {
         $fields->addFieldToTab('Root.Main', $gridField);
     }
     return $fields;
 }
 /**
  * Hook into the updateProfileFields function to swap out the email field with our own custom Field.
  * @param  FieldList $fields
  */
 public function updateProfileFields(FieldList $fields)
 {
     // Get a reference to the MemberProfilePage
     $owner = $this->getOwner();
     // Get the Email Profile Field
     $profileField = $owner->Fields()->filter(array('MemberField' => 'Email'))->first();
     if (!$profileField || !$profileField->ID || $profileField->AllowedDomains && $profileField->DisallowedDomains) {
         // If we can't find the Email Profile Field or if there's no domain condition on the field,
         // there's no point carrying on
         return;
     }
     // Get the actual Email Form Field
     $oldField = $fields->fieldByName('Email');
     if (!$oldField) {
         // IF we can't find the form field.
         return;
     }
     // The form field might come as a CheckableVisibilityField or a TextField.
     // We need to handle both case differently
     if (is_a($oldField, 'CheckableVisibilityField')) {
         // Create our new DomainSpecificEmailField
         $field = $this->initNewField($oldField->getChild(), $profileField);
         // We need to replicate a bit of logic from MembrProfilePage::getProfileFields()
         $field = new CheckableVisibilityField($field);
         if ($profileField->PublicVisibility == 'Display') {
             $field->makeAlwaysVisible();
         } else {
             $field->getCheckbox()->setValue($profileField->PublicVisibilityDefault);
         }
     } else {
         // Just convert the Email Form Field to our DomainSpecificEmailField
         $field = $this->initNewField($oldField, $profileField);
     }
     // Swap our the old field with the new one.
     $fields->replaceField('Email', $field);
 }
 /**
  * Set default for inherit
  *
  * @param FieldSet $fields
  */
 public function updateFrontEndFields(FieldList $fields)
 {
     if (!$this->owner->ID) {
         $fields->replaceField('InheritPerms', new CheckboxField('InheritPerms', _t('Restrictable.INHERIT_PERMS', 'Inherit Permissions'), true));
     }
     $ownerField = $fields->fieldByName('OwnerID');
     if ($ownerField) {
         $members = singleton('DataService')->getAllMember();
         $source = array();
         if ($members) {
             $source = $members->map();
         }
         if (method_exists($ownerField, 'setSource')) {
             $ownerField->setSource($source);
         }
     }
 }
 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->replaceField('RelationID', new TreeDropdownField('RelationID', 'Relation', $this->relationClass));
 }
 public function updateCMSFields(\FieldList $fields)
 {
     $fields->removeByName('UploadFolder');
     $opts = array_combine(self::$permission_options, self::$permission_options);
     $fields->replaceField('PostPermission', DropdownField::create('PostPermission', _t('ProfileDashlet.POST_PERM', 'Post permissions'), $opts));
 }
 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->replaceField('GUID', new ReadonlyField('GUID'));
     $fields->removeFieldFromTab('Root', 'SAMLSessionIndex');
 }
Example #26
0
 /**
  * Test replacing a field with another one.
  */
 public function testReplaceField()
 {
     $fields = new FieldList();
     $tab = new Tab('Root');
     $fields->push($tab);
     /* A field gets added to the set */
     $fields->addFieldToTab('Root', new TextField('Country'));
     /* We have the same object as the one we pushed */
     $this->assertSame($fields->dataFieldByName('Country'), $tab->fieldByName('Country'));
     /* The field called Country is replaced by the field called Email */
     $fields->replaceField('Country', new EmailField('Email'));
     /* We have 1 field inside our tab */
     $this->assertEquals(1, $tab->Fields()->Count());
 }
 /**
  * Test replacing a field with another one.
  */
 public function testReplaceField()
 {
     $fields = new FieldList();
     $tab = new Tab('Root');
     $fields->push($tab);
     /* A field gets added to the set */
     $fields->addFieldToTab('Root', new TextField('Country'));
     $this->assertSame($fields->dataFieldByName('Country'), $tab->fieldByName('Country'));
     $fields->replaceField('Country', new EmailField('Email'));
     $this->assertEquals(1, $tab->Fields()->Count());
     $fields = new FieldList();
     $fields->push(new TextField('Name', 'Your name'));
     $brack = new TextField('Name[Field]', 'Your name');
     $fields->replaceField('Name', $brack);
     $this->assertEquals(1, $fields->Count());
     $this->assertEquals('Name[Field]', $fields->first()->getName());
 }
 /**
  * Gets fields used in the cms
  * @return {FieldSet} Fields to be used
  */
 public function getCMSFields()
 {
     $fields = new FieldList(new TextField('Name', _t('SnippetLanguage.NAME', '_Name'), null, 100), new TextField('FileExtension', _t('SnippetLanguage.FILE_EXTENSION', '_File Extension'), null, 45), new CheckboxField('Hidden', _t('SnippetLanguage.HIDDEN', '_Hidden')));
     if ($this->UserLanguage == false) {
         $fields->replaceField('Name', $fields->dataFieldByName('Name')->performReadonlyTransformation());
         $fields->replaceField('FileExtension', $fields->dataFieldByName('FileExtension')->performReadonlyTransformation());
     }
     return $fields;
 }
 /**
  * standard SS method
  * @var Array
  **/
 public function updateCMSFields(FieldList $fields)
 {
     //separate MetaTitle
     if (Config::inst()->get("MetaTagsContentControllerEXT", "use_separate_metatitle") == 1) {
         $fields->addFieldToTab('Root.Main.Metadata', $allowField0 = new TextField('MetaTitle', _t('SiteTree.METATITLE', 'Meta Title')), "MetaDescription");
         $allowField0->setRightTitle(_t("SiteTree.METATITLE_EXPLANATION", "Leave this empty to use the page title"));
     }
     //info about automation
     $fields->addFieldToTab('Root.Main.Metadata', $allowField1 = new CheckboxField('AutomateMetatags', _t('MetaManager.UPDATEMETA', 'Automatically update Meta Description and Navigation Label? ')));
     $automatedFields = $this->updatedFieldsArray();
     $updatedFieldString = "";
     if (count($automatedFields)) {
         $updatedFieldString = "" . _t("MetaManager.UPDATED_EXTERNALLY", "Based on your current settings, the following fields will be automatically updated at all times") . ": <em>" . implode("</em>, <em>", $automatedFields) . "</em>.";
         foreach ($automatedFields as $fieldName => $fieldTitle) {
             $oldField = $fields->dataFieldByName($fieldName);
             if ($oldField) {
                 $newField = $oldField->performReadonlyTransformation();
                 //$newField->setTitle($newField->Title());
                 $newField->setRightTitle(_t("MetaTags.AUTOMATICALLY_UPDATED", "Automatically updated when you save this page (see metadata settings)."));
                 $fields->replaceField($fieldName, $newField);
             }
         }
     }
     $fields->removeByName('ExtraMeta');
     $linkToManager = Config::inst()->get("MetaTagCMSControlPages", "url_segment") . '/';
     $fields->addFieldToTab('Root.Main.Metadata', new LiteralField("LinkToManagerHeader", "<blockquote style='padding-left: 12px;'>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tOpen the Meta Tag Manager to\n\t\t\t\t\t\t<a href=\"{$linkToManager}\" target=\"_blank\">Review and Edit</a>\n\t\t\t\t\t\tthe Meta Data for all pages on this site.\n\t\t\t\t\t\tAlso make sure to review the general settings for\n\t\t\t\t\t\t<a href=\"/admin/settings/\">Search Engines</a>. {$updatedFieldString}\n\t\t\t\t\t</p>\n\t\t\t\t</blockquote>"));
     if ($this->owner->URLSegment == RootURLController::get_default_homepage_link()) {
         $newField = $fields->dataFieldByName('URLSegment');
         $newField->setRightTitle("Careful: changing the URL from 'home' to anything else means that this page will no longer be the home page");
         $fields->replaceField('URLSegment', $newField);
     }
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $this->owner->getBuyable();
     $buyables = EcommerceConfig::get("EcommerceDBConfig", "array_of_buyables");
     if ($buyables && is_array($buyables) && count($buyables)) {
         foreach ($buyables as $item) {
             $fields->replaceField($item . "ID", new HiddenField($item . "ID"));
         }
     }
     $fields->replaceField("From", new TextField("From"));
     return $fields;
 }