public function getCMSFields()
 {
     $fields = FieldList::create(TabSet::create('Root'))->text('Title')->text('Code', 'Code', '', 5)->textarea('Description')->numeric('SessionCount', 'Number of sessions')->numeric('AlternateCount', 'Number of alternates')->checkbox('VotingVisible', "This category is visible to voters")->checkbox('ChairVisible', "This category is visible to track chairs")->hidden('SummitID', 'SummitID');
     if ($this->ID > 0) {
         //tags
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType(new GridFieldDataColumns());
         $config->removeComponentsByType(new GridFieldDetailForm());
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setResultsFormat('$Tag');
         $completer->setSearchFields(array('Tag'));
         $completer->setSearchList(Tag::get());
         $editconf = new GridFieldDetailForm();
         $editconf->setFields(FieldList::create(TextField::create('Tag', 'Tag'), DropdownField::create('ManyMany[Group]', 'Group', array('topics' => 'Topics', 'speaker' => 'Speaker', 'openstack projects mentioned' => 'OpenStack Projects Mentioned'))));
         $summaryfieldsconf = new GridFieldDataColumns();
         $summaryfieldsconf->setDisplayFields(array('Tag' => 'Tag', 'Group' => 'Group'));
         $config->addComponent($editconf);
         $config->addComponent($summaryfieldsconf, new GridFieldFilterHeader());
         $tags = new GridField('AllowedTags', 'Tags', $this->AllowedTags(), $config);
         $fields->addFieldToTab('Root.Main', $tags);
         // extra questions for call-for-presentations
         $config = new GridFieldConfig_RelationEditor();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('TrackTextBoxQuestionTemplate' => 'TextBox', 'TrackCheckBoxQuestionTemplate' => 'CheckBox', 'TrackCheckBoxListQuestionTemplate' => 'CheckBoxList', 'TrackRadioButtonListQuestionTemplate' => 'RadioButtonList', 'TrackDropDownQuestionTemplate' => 'ComboBox', 'TrackLiteralContentQuestionTemplate' => 'Literal'));
         $config->addComponent($multi_class_selector);
         $questions = new GridField('ExtraQuestions', 'Track Specific Questions', $this->ExtraQuestions(), $config);
         $fields->addFieldToTab('Root.Main', $questions);
     }
     return $fields;
 }
 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $cfg = new GridFieldConfig_RelationEditor(100);
     if (class_exists('GridFieldOrderableRows')) {
         $cfg->addComponent(new GridFieldOrderableRows('Sort'));
     }
     $grid = new GridField('Videos', 'Videos', $this->owner->Videos(), $cfg);
     $fields->addFieldToTab('Root.Videos', $grid);
 }
 /**
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     $slidesConfig = new GridFieldConfig_RelationEditor();
     if (class_exists('GridFieldSortableRows')) {
         $slidesConfig->addComponent(new GridFieldSortableRows('Sort'));
     }
     $slidesGrid = GridField::create('HomeSlides', 'HomeSlides', $this->owner->HomeSlides(), $slidesConfig);
     $fields->addFieldToTab('Root.Slides', $slidesGrid);
     return $fields;
 }
 /**
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     $tilesConfig = new GridFieldConfig_RelationEditor();
     if (class_exists('GridFieldSortableRows')) {
         $tilesConfig->addComponent(new GridFieldSortableRows('Sort'));
     }
     if ($this->owner->HomeTiles()->Count() == $this->owner->config()->HomeTilesLimit) {
         $tilesConfig->removeComponentsByType('GridFieldAddNewButton');
     }
     $slidesGrid = GridField::create('HomeTiles', 'HomeTiles', $this->owner->HomeTiles(), $tilesConfig);
     $fields->addFieldToTab('Root.Tiles', $slidesGrid);
     return $fields;
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $galleryConfig = new GridFieldConfig_RelationEditor();
     if (class_exists('GridFieldSortableRows')) {
         $galleryConfig->addComponent(new GridFieldSortableRows('Sort'));
     }
     if ($this->owner->GalleryItems()->Count() >= $this->getItemLimit()) {
         $galleryConfig->removeComponentsByType('GridFieldAddNewButton');
     }
     $galleryGrid = GridField::create('GalleryItems', 'GalleryItems', $this->GalleryItems(), $galleryConfig);
     $fields->addFieldToTab('Root.Gallery', $galleryGrid);
     return $fields;
 }
 public function getCMSFields()
 {
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', new TextField('Name', 'Name'));
     $f->addFieldToTab('Root.Main', new ColorField('Color', 'Color'));
     if ($this->ID > 0) {
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $config->addComponent(new GridFieldDeleteAction('unlinkrelation'));
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setSearchList(PresentationCategory::get()->filter('SummitID', $summit_id));
         $categories = new GridField('Categories', 'Presentation Category', $this->Categories(), $config);
         $f->addFieldToTab('Root.Main', $categories);
     }
     $f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     return $f;
 }
 public function getCMSFields()
 {
     $f = parent::getCMSFields();
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('SubmissionBeginDate', 'Submission Begin Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('SubmissionEndDate', 'Submission End Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldsToTab('Root.Main', new NumericField('MaxSubmissionAllowedPerUser', 'Max. Submission Allowed Per User'));
     if ($this->ID > 0) {
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $config->addComponent(new GridFieldDeleteAction('unlinkrelation'));
         $groups = new GridField('AllowedGroups', 'Allowed Groups', $this->AllowedGroups(), $config);
         $f->addFieldToTab('Root.Main', $groups);
     }
     return $f;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Sort');
     $fields->removeByName('Products');
     $url_field = TextField::create('URLSegment')->setReadonly(true)->performReadonlyTransformation();
     $gridconfig = new GridFieldConfig_RelationEditor();
     $gridconfig->addComponent(new GridFieldOrderableRows('SortOrder'));
     $products_field = GridField::create("Products", "", $this->Products(), $gridconfig);
     $parent_field = TreeDropdownField::create('ParentID', 'Parent Category', 'ProductCategory')->setLabelField("Title");
     // Add fields to the CMS
     $fields->addFieldToTab('Root.Main', TextField::create('Title'));
     $fields->addFieldToTab('Root.Main', $url_field);
     $fields->addFieldToTab('Root.Main', $parent_field);
     $fields->addFieldToTab("Root.Main", HeaderField::create("ProductsHeader", "Products in this category"));
     $fields->addFieldToTab('Root.Main', $products_field);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * Caution: Only call on instances, not through a singleton.
  * The "root group" fields will be created through {@link SecurityAdmin->EditForm()}.
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::javascript(FRAMEWORK_DIR . '/javascript/PermissionCheckboxSetField.js');
     $fields = new FieldList(new TabSet("Root", new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $parentidfield = DropdownField::create('ParentID', $this->fieldLabel('Parent'), Group::get()->exclude('ID', $this->ID)->map('ID', 'Breadcrumbs'))->setEmptyString(' '), new TextareaField('Description', $this->fieldLabel('Description'))), $permissionsTab = new Tab('Permissions', _t('SecurityAdmin.PERMISSIONS', 'Permissions'), $permissionsField = new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this))));
     $parentidfield->setDescription(_t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles'));
     // Filter permissions
     // TODO SecurityAdmin coupling, not easy to get to the form fields through GridFieldDetailForm
     $permissionsField->setHiddenPermissions((array) Config::inst()->get('SecurityAdmin', 'hidden_permissions'));
     if ($this->ID) {
         $group = $this;
         $config = new GridFieldConfig_RelationEditor();
         $config->addComponent(new GridFieldButtonRow('after'));
         $config->addComponents(new GridFieldExportButton('buttons-after-left'));
         $config->addComponents(new GridFieldPrintButton('buttons-after-left'));
         $config->getComponentByType('GridFieldAddExistingAutocompleter')->setResultsFormat('$Title ($Email)')->setSearchFields(array('FirstName', 'Surname', 'Email'));
         $config->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator())->setItemEditFormCallback(function ($form, $component) use($group) {
             $record = $form->getRecord();
             $groupsField = $form->Fields()->dataFieldByName('DirectGroups');
             if ($groupsField) {
                 // If new records are created in a group context,
                 // set this group by default.
                 if ($record && !$record->ID) {
                     $groupsField->setValue($group->ID);
                 } elseif ($record && $record->ID) {
                     // TODO Mark disabled once chosen.js supports it
                     // $groupsField->setDisabledItems(array($group->ID));
                     $form->Fields()->replaceField('DirectGroups', $groupsField->performReadonlyTransformation());
                 }
             }
         });
         $memberList = GridField::create('Members', false, $this->DirectMembers(), $config)->addExtraClass('members_grid');
         // @todo Implement permission checking on GridField
         //$memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
         $fields->addFieldToTab('Root.Members', $memberList);
     }
     // Only add a dropdown for HTML editor configurations if more than one is available.
     // Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
     $editorConfigMap = HtmlEditorConfig::get_available_configs_map();
     if (count($editorConfigMap) > 1) {
         $fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
     }
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
     }
     // Only show the "Roles" tab if permissions are granted to edit them,
     // and at least one role exists
     if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
         $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "Roles are predefined sets of permissions, and can be assigned to groups.<br />" . "They are inherited from parent groups if required.") . '<br />' . sprintf('<a href="%s" class="add-role">%s</a>', singleton('SecurityAdmin')->Link('show/root#Root_Roles'), _t('Group.RolesAddEditLink', 'Manage roles')) . "</p>"));
         // Add roles (and disable all checkboxes for inherited roles)
         $allRoles = PermissionRole::get();
         if (Permission::check('ADMIN')) {
             $allRoles = $allRoles->filter("OnlyAdminCanApply", 0);
         }
         if ($this->ID) {
             $groupRoles = $this->Roles();
             $inheritedRoles = new ArrayList();
             $ancestors = $this->getAncestors();
             foreach ($ancestors as $ancestor) {
                 $ancestorRoles = $ancestor->Roles();
                 if ($ancestorRoles) {
                     $inheritedRoles->merge($ancestorRoles);
                 }
             }
             $groupRoleIDs = $groupRoles->column('ID') + $inheritedRoles->column('ID');
             $inheritedRoleIDs = $inheritedRoles->column('ID');
         } else {
             $groupRoleIDs = array();
             $inheritedRoleIDs = array();
         }
         $rolesField = ListboxField::create('Roles', false, $allRoles->map()->toArray())->setMultiple(true)->setDefaultItems($groupRoleIDs)->setAttribute('data-placeholder', _t('Group.AddRole', 'Add a role for this group'))->setDisabledItems($inheritedRoleIDs);
         if (!$allRoles->Count()) {
             $rolesField->setAttribute('data-placeholder', _t('Group.NoRoles', 'No roles found'));
         }
         $fields->addFieldToTab('Root.Roles', $rolesField);
     }
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }