function ItemEditForm()
 {
     $form = parent::ItemEditForm();
     $actions = $form->Actions();
     $majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
     $rootTabSet = new TabSet('ActionMenus');
     $moreOptions = new Tab('MoreOptions', _t('SiteTree.MoreOptions', 'More options', 'Expands a view for more buttons'));
     $rootTabSet->push($moreOptions);
     $rootTabSet->addExtraClass('ss-ui-action-tabset action-menus');
     // Render page information into the "more-options" drop-up, on the top.
     $baseClass = ClassInfo::baseDataClass($this->record->class);
     $live = Versioned::get_one_by_stage($this->record->class, 'Live', "\"{$baseClass}\".\"ID\"='{$this->record->ID}'");
     $existsOnLive = $this->record->getExistsOnLive();
     $published = $this->record->isPublished();
     $moreOptions->push(new LiteralField('Information', $this->record->customise(array('Live' => $live, 'ExistsOnLive' => $existsOnLive))->renderWith('SiteTree_Information')));
     $actions->removeByName('action_doSave');
     $actions->removeByName('action_doDelete');
     if ($this->record->canEdit()) {
         if ($this->record->IsDeletedFromStage) {
             if ($existsOnLive) {
                 $majorActions->push(FormAction::create('revert', _t('CMSMain.RESTORE', 'Restore')));
                 if ($this->record->canDelete() && $this->record->canDeleteFromLive()) {
                     $majorActions->push(FormAction::create('unpublish', _t('CMSMain.DELETEFP', 'Delete'))->addExtraClass('ss-ui-action-destructive'));
                 }
             } else {
                 if (!$this->record->isNew()) {
                     $majorActions->push(FormAction::create('restore', _t('CMSMain.RESTORE', 'Restore'))->setAttribute('data-icon', 'decline'));
                 } else {
                     $majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
                     $majorActions->push(FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true));
                 }
             }
         } else {
             if ($this->record->canDelete() && !$published) {
                 $moreOptions->push(FormAction::create('delete', _t('SiteTree.BUTTONDELETE', 'Delete draft'))->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
             }
             $majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
         }
     }
     $publish = FormAction::create('publish', $published ? _t('SiteTree.BUTTONPUBLISHED', 'Published') : _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true);
     if (!$published || $this->record->stagesDiffer('Stage', 'Live') && $published) {
         $publish->addExtraClass('ss-ui-alternate');
     }
     if ($this->record->canPublish() && !$this->record->IsDeletedFromStage) {
         $majorActions->push($publish);
     }
     if ($published && $this->record->canPublish() && !$this->record->IsDeletedFromStage && $this->record->canDeleteFromLive()) {
         $moreOptions->push(FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
     }
     if ($this->record->stagesDiffer('Stage', 'Live') && !$this->record->IsDeletedFromStage && $this->record->isPublished() && $this->record->canEdit()) {
         $moreOptions->push(FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'))->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'))->setUseButtonTag(true));
     }
     $actions->push($majorActions);
     $actions->push($rootTabSet);
     if ($this->record->hasMethod('getCMSValidator')) {
         $form->setValidator($this->record->getCMSValidator());
     }
     return $form;
 }
 public function updateCMSFlexiTabs(TabSet $fields, TabSet $settings_tab, $flexi)
 {
     $field = new LiteralField('HandlerSettings', "<h3>Handler Settings</h3>");
     $settings_tab->push($field);
     $form_settings = $flexi->FlexiFormConf('HandlerSettings');
     foreach (Config::inst()->get($this->class, 'handler_settings', Config::INHERITED) as $component => $class) {
         if (!($setting = $flexi->FlexiFormSetting($component))) {
             $setting = new $class();
             $setting->Setting = $component;
             $setting->HandlerID = $this->ID;
             $form_settings->add($setting);
         }
         $field = $setting->getCMSField($component);
         // field name: FlexiFormConfig[Setting][<handler_id>][<setting_name>]
         $field->setName($this->getSettingFieldName($component));
         $settings_tab->push($field);
     }
 }
 function updateCMSFields(FieldList $fields)
 {
     $fields->insertAfter($tabset = new TabSet('ColoredImages'), 'Image');
     $tabset->push($uploadtab = new Tab('UploadImages'));
     $tabset->push($attributetab = new Tab('AssignAttribute'));
     $uploadtab->push($uf = new UploadField('Images', 'Images'));
     $uf->setDescription('Note: The product must be saved before attributes can be assigned to new uploaded images.');
     $attributetab->push($gf = GridField::create("ImageAttributes", "Images", $this->owner->Images(), GridFieldConfig_RelationEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldEditButton")->removeComponentsByType("GridFieldDataColumns")->removeComponentsByType("GridFieldDeleteAction")->addComponent($cols = new GridFieldEditableColumns())->addComponent(new GridFieldOrderableRows('Sort'))));
     $displayfields = array('Title' => array('title' => 'Title', 'field' => new ReadonlyField("Name")));
     //add drop-down color selection
     $colors = $this->owner->getColors();
     if ($colors->exists()) {
         $displayfields['ColorID'] = function ($record, $col, $grid) use($colors) {
             return DropdownField::create($col, "Color", $colors->map('ID', 'Value')->toArray())->setHasEmptyDefault(true);
         };
     }
     $cols->setDisplayFields($displayfields);
 }
 function getCMSFields()
 {
     if ($this->ID != 0) {
         $totalCount = $this->getTotalVotes();
     } else {
         $totalCount = 0;
     }
     $fields = new FieldList($rootTab = new TabSet("Root", new Tab("Main", new TextField('Title', 'Poll title (maximum 50 characters)', null, 50), new OptionsetField('MultiChoice', 'Single answer (radio buttons)/multi-choice answer (tick boxes)', array(0 => 'Single answer', 1 => 'Multi-choice answer')), new OptionsetField('IsActive', 'Poll state', array(1 => 'Active', 0 => 'Inactive')), $embargo = new DatetimeField('Embargo', 'Embargo'), $expiry = new DatetimeField('Expiry', 'Expiry'), new HTMLEditorField('Description', 'Description'), $image = new UploadField('Image', 'Poll image'))));
     $embargo->getDateField()->setConfig('showcalendar', true);
     $embargo->getTimeField()->setConfig('showdropdown', true);
     $embargo->getDateField()->setConfig('dateformat', 'dd/MM/YYYY');
     $embargo->getTimeField()->setConfig('timeformat', 'h:m a');
     $expiry->getDateField()->setConfig('showcalendar', true);
     $expiry->getTimeField()->setConfig('showdropdown', true);
     $expiry->getDateField()->setConfig('dateformat', 'dd/MM/YYYY');
     $expiry->getTimeField()->setConfig('timeformat', 'h:m a');
     // Add the fields that depend on the poll being already saved and having an ID
     if ($this->ID != 0) {
         $config = GridFieldConfig::create();
         $config->addComponent(new GridFieldToolbarHeader());
         $config->addComponent(new GridFieldAddNewButton('toolbar-header-right'));
         $config->addComponent(new GridFieldDataColumns());
         $config->addComponent(new GridFieldEditButton());
         $config->addComponent(new GridFieldDeleteAction());
         $config->addComponent(new GridFieldDetailForm());
         $config->addComponent(new GridFieldSortableHeader());
         $pollChoicesTable = new GridField('Choices', 'Choices', $this->Choices(), $config);
         $fields->addFieldToTab('Root.Data', $pollChoicesTable);
         $fields->addFieldToTab('Root.Data', new ReadonlyField('Total', 'Total votes', $totalCount));
         // Display the results using the default poll chart
         $pollForm = new PollForm(new Controller(), 'PollForm', $this);
         $chartTab = new Tab("Result chart", new LiteralField('Chart', sprintf('<h1>%s</h1><p>%s</p>', $this->Title, $pollForm->getChart(), $this->Title)));
         $rootTab->push($chartTab);
     } else {
         $fields->addFieldToTab('Root.Choices', new ReadOnlyField('ChoicesPlaceholder', 'Choices', 'You will be able to add options once you have saved the poll for the first time.'));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Ejemplo n.º 5
0
 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     $folder = $id && is_numeric($id) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
     $fields = $form->Fields();
     $title = $folder && $folder->exists() ? $folder->Title : _t('AssetAdmin.FILES', 'Files');
     $fields->push(new HiddenField('ID', false, $folder ? $folder->ID : null));
     // File listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldPaginator(self::config()->page_length), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d'));
     $gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig);
     $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Title' => _t('File.Title', 'Title'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'Size' => _t('AssetAdmin.SIZE', 'Size')));
     $columns->setFieldCasting(array('Created' => 'SS_Datetime->Nice'));
     $gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
     if ($folder->canCreate()) {
         $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="drive-upload" href="%s">%s</a>', Controller::join_links(singleton('CMSFileAddController')->Link(), '?ID=' . $folder->ID), _t('Folder.UploadFilesButton', 'Upload')));
     } else {
         $uploadBtn = null;
     }
     if (!$folder->hasMethod('canAddChildren') || $folder->hasMethod('canAddChildren') && $folder->canAddChildren()) {
         // TODO Will most likely be replaced by GridField logic
         $addFolderBtn = new LiteralField('AddFolderButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-add-folder-link" data-icon="add" data-url="%s" href="%s">%s</a>', Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array('action_doAdd' => 1, 'ParentID' => $folder->ID, 'SecurityID' => $form->getSecurityToken()->getValue()))), Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID), _t('Folder.AddFolderButton', 'Add folder')));
     } else {
         $addFolderBtn = '';
     }
     if ($folder->canEdit()) {
         $syncButton = new LiteralField('SyncButton', sprintf('<a class="ss-ui-button ss-ui-action ui-button-text-icon-primary ss-ui-button-ajax" data-icon="arrow-circle-double" title="%s" href="%s">%s</a>', _t('AssetAdmin.FILESYSTEMSYNCTITLE', 'Update the CMS database entries of files on the filesystem. Useful when new files have been uploaded outside of the CMS, e.g. through FTP.'), $this->Link('doSync'), _t('AssetAdmin.FILESYSTEMSYNC', 'Sync files')));
     } else {
         $syncButton = null;
     }
     // Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
     // Required to keep Folder->getCMSFields() simple and reuseable,
     // without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
     if (!$fields->hasTabset()) {
         $tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')), $tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View')));
         $tabList->addExtraClass("content-listview cms-tabset-icon list");
         $tabTree->addExtraClass("content-treeview cms-tabset-icon tree");
         if ($fields->Count() && $folder->exists()) {
             $tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
             $tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit");
             foreach ($fields as $field) {
                 $fields->removeByName($field->getName());
                 $tabDetails->push($field);
             }
         }
         $fields->push($tabs);
     }
     // we only add buttons if they're available. User might not have permission and therefore
     // the button shouldn't be available. Adding empty values into a ComposteField breaks template rendering.
     $actionButtonsComposite = CompositeField::create()->addExtraClass('cms-actions-row');
     if ($uploadBtn) {
         $actionButtonsComposite->push($uploadBtn);
     }
     if ($addFolderBtn) {
         $actionButtonsComposite->push($addFolderBtn);
     }
     if ($syncButton) {
         $actionButtonsComposite->push($syncButton);
     }
     // List view
     $fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create($actionButtonsComposite)->addExtraClass('cms-content-toolbar field'), $gridField));
     $treeField = new LiteralField('Tree', '');
     // Tree view
     $fields->addFieldsToTab('Root.TreeView', array(clone $actionsComposite, new LiteralField('Tree', FormField::create_tag('div', array('class' => 'cms-tree', 'data-url-tree' => $this->Link('getsubtree'), 'data-url-savetreenode' => $this->Link('savetreenode')), $this->SiteTreeAsUL()))));
     // Move actions to "details" tab (they don't make sense on list/tree view)
     $actions = $form->Actions();
     $saveBtn = $actions->fieldByName('action_save');
     $deleteBtn = $actions->fieldByName('action_delete');
     $actions->removeByName('action_save');
     $actions->removeByName('action_delete');
     if (($saveBtn || $deleteBtn) && $fields->fieldByName('Root.DetailsView')) {
         $fields->addFieldToTab('Root.DetailsView', CompositeField::create($saveBtn, $deleteBtn)->addExtraClass('Actions'));
     }
     $fields->setForm($form);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // TODO Can't merge $FormAttributes in template at the moment
     $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     $this->extend('updateEditForm', $form);
     return $form;
 }
 function testRootFieldSet()
 {
     /* Given a nested set of FormField, CompositeField, and FieldSet objects */
     $fieldSet = new FieldSet($root = new TabSet("Root", $main = new Tab("Main", $a = new TextField("A"), $b = new TextField("B"))));
     /* rootFieldSet() should always evaluate to the same object: the topmost fieldset */
     $this->assertSame($fieldSet, $fieldSet->rootFieldSet());
     $this->assertSame($fieldSet, $root->rootFieldSet());
     $this->assertSame($fieldSet, $main->rootFieldSet());
     $this->assertSame($fieldSet, $a->rootFieldSet());
     $this->assertSame($fieldSet, $b->rootFieldSet());
     /* If we push additional fields, they should also have the same rootFieldSet() */
     $root->push($other = new Tab("Other"));
     $other->push($c = new TextField("C"));
     $root->push($third = new Tab("Third", $d = new TextField("D")));
     $this->assertSame($fieldSet, $other->rootFieldSet());
     $this->assertSame($fieldSet, $third->rootFieldSet());
     $this->assertSame($fieldSet, $c->rootFieldSet());
     $this->assertSame($fieldSet, $d->rootFieldSet());
 }
Ejemplo n.º 7
0
 /**
  * Get the actions available in the CMS for this page - eg Save, Publish.
  *
  * Frontend scripts and styles know how to handle the following FormFields:
  * - top-level FormActions appear as standalone buttons
  * - top-level CompositeField with FormActions within appear as grouped buttons
  * - TabSet & Tabs appear as a drop ups
  * - FormActions within the Tab are restyled as links
  * - major actions can provide alternate states for richer presentation (see ssui.button widget extension)
  *
  * @return FieldList The available actions for this page.
  */
 public function getCMSActions()
 {
     $existsOnLive = $this->getExistsOnLive();
     // Major actions appear as buttons immediately visible as page actions.
     $majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
     // Minor options are hidden behind a drop-up and appear as links (although they are still FormActions).
     $rootTabSet = new TabSet('ActionMenus');
     $moreOptions = new Tab('MoreOptions', _t('SiteTree.MoreOptions', 'More options', 'Expands a view for more buttons'));
     $rootTabSet->push($moreOptions);
     $rootTabSet->addExtraClass('ss-ui-action-tabset action-menus');
     // Render page information into the "more-options" drop-up, on the top.
     $live = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\"='{$this->ID}'");
     $moreOptions->push(new LiteralField('Information', $this->customise(array('Live' => $live, 'ExistsOnLive' => $existsOnLive))->renderWith('SiteTree_Information')));
     // "readonly"/viewing version that isn't the current version of the record
     $stageOrLiveRecord = Versioned::get_one_by_stage($this->class, Versioned::current_stage(), sprintf('"SiteTree"."ID" = %d', $this->ID));
     if ($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
         $moreOptions->push(FormAction::create('email', _t('CMSMain.EMAIL', 'Email')));
         $moreOptions->push(FormAction::create('rollback', _t('CMSMain.ROLLBACK', 'Roll back to this version')));
         $actions = new FieldList(array($majorActions, $rootTabSet));
         // getCMSActions() can be extended with updateCMSActions() on a extension
         $this->extend('updateCMSActions', $actions);
         return $actions;
     }
     if ($this->isPublished() && $this->canPublish() && !$this->IsDeletedFromStage && $this->canDeleteFromLive()) {
         // "unpublish"
         $moreOptions->push(FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')->setDescription(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site'))->addExtraClass('ss-ui-action-destructive'));
     }
     if ($this->stagesDiffer('Stage', 'Live') && !$this->IsDeletedFromStage) {
         if ($this->isPublished() && $this->canEdit()) {
             // "rollback"
             $moreOptions->push(FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'), 'delete')->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page')));
         }
     }
     if ($this->canEdit()) {
         if ($this->IsDeletedFromStage) {
             // The usual major actions are not available, so we provide alternatives here.
             if ($existsOnLive) {
                 // "restore"
                 $majorActions->push(FormAction::create('revert', _t('CMSMain.RESTORE', 'Restore')));
                 if ($this->canDelete() && $this->canDeleteFromLive()) {
                     // "delete from live"
                     $majorActions->push(FormAction::create('deletefromlive', _t('CMSMain.DELETEFP', 'Delete'))->addExtraClass('ss-ui-action-destructive'));
                 }
             } else {
                 // "restore"
                 $majorActions->push(FormAction::create('restore', _t('CMSMain.RESTORE', 'Restore'))->setAttribute('data-icon', 'decline'));
             }
         } else {
             if ($this->canDelete()) {
                 // "delete"
                 $moreOptions->push(FormAction::create('delete', _t('CMSMain.DELETE', 'Delete draft'))->addExtraClass('delete ss-ui-action-destructive'));
             }
             // "save", supports an alternate state that is still clickable, but notifies the user that the action is not needed.
             $majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft')));
         }
     }
     if ($this->canPublish() && !$this->IsDeletedFromStage) {
         // "publish", as with "save", it supports an alternate state to show when action is needed.
         $majorActions->push($publish = FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish')));
         // Set up the initial state of the button to reflect the state of the underlying SiteTree object.
         if ($this->stagesDiffer('Stage', 'Live')) {
             $publish->addExtraClass('ss-ui-alternate');
         }
     }
     $actions = new FieldList(array($majorActions, $rootTabSet));
     // Hook for extensions to add/remove actions.
     $this->extend('updateCMSActions', $actions);
     return $actions;
 }
 function getCMSFields()
 {
     if ($this->FolderID) {
         // New token - select file:
         $folder = DataObject::get_by_id('Folder', $this->FolderID);
         $files = new DataObjectSet();
         if ($folder->myChildren()) {
             foreach ($folder->myChildren() as $file) {
                 if (!$file instanceof Folder) {
                     $files->push($file);
                 }
             }
             $files->sort('Name');
         }
         $fileField = new DropdownField('FileID', 'File', $files->map('ID', 'Name'));
     } else {
         // Existing token:
         $fileField = new ReadonlyField('FileDummy', 'File', $this->File()->Name);
     }
     $fields = new FieldSet();
     $fields->push($root = new TabSet('Root'));
     $root->push($main = new Tab('Main'));
     $main->push($fileField);
     if (ClassInfo::exists('DatetimeField')) {
         // 2.4.x
         $main->push($expiry_field = new DatetimeField('Expiry', 'Expiry'));
         $expiry_field->getDateField()->setConfig('showcalendar', true);
         $expiry_field->getTimeField()->setConfig('showdropdown', true);
     } else {
         // 2.3.x
         $main->push($expiry_field = new PopupDateTimeField('Expiry', 'Expiry'));
     }
     $main->push(new ReadonlyField('MemberDummyField', 'Member', $this->MemberNice()));
     if ($this->ID) {
         $main->push(new ReadonlyField('Token', 'Token'));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function getEditForm($id = null, $fields = null)
 {
     Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $form = parent::getEditForm($id, $fields);
     $folder = $id && is_numeric($id) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
     $fields = $form->Fields();
     $title = $folder && $folder->exists() ? $folder->Title : _t('AssetAdmin.FILES', 'Files');
     $fields->push(new HiddenField('ID', false, $folder ? $folder->ID : null));
     // File listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldPaginator(self::config()->page_length), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d'));
     $gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig);
     $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Title' => _t('File.Title', 'Title'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'Size' => _t('AssetAdmin.SIZE', 'Size')));
     $columns->setFieldCasting(array('Created' => 'SS_Datetime->Nice'));
     $gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
     if (!$folder->hasMethod('canAddChildren') || $folder->hasMethod('canAddChildren') && $folder->canAddChildren()) {
         // TODO Will most likely be replaced by GridField logic
         $addFolderBtn = new LiteralField('AddFolderButton', sprintf('<a class="ss-ui-button font-icon-folder-add no-text cms-add-folder-link" title="%s" data-icon="add" data-url="%s" href="%s"></a>', _t('Folder.AddFolderButton', 'Add folder'), Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array('action_doAdd' => 1, 'ParentID' => $folder->ID, 'SecurityID' => $form->getSecurityToken()->getValue()))), Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID)));
     } else {
         $addFolderBtn = '';
     }
     // Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
     // Required to keep Folder->getCMSFields() simple and reuseable,
     // without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
     if (!$fields->hasTabset()) {
         $tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')), $tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View')));
         $tabList->addExtraClass("content-listview cms-tabset-icon list");
         $tabTree->addExtraClass("content-treeview cms-tabset-icon tree");
         if ($fields->Count() && $folder->exists()) {
             $tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
             $tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit");
             foreach ($fields as $field) {
                 $fields->removeByName($field->getName());
                 $tabDetails->push($field);
             }
         }
         $fields->push($tabs);
     }
     // we only add buttons if they're available. User might not have permission and therefore
     // the button shouldn't be available. Adding empty values into a ComposteField breaks template rendering.
     $actionButtonsComposite = CompositeField::create()->addExtraClass('cms-actions-row');
     if ($addFolderBtn) {
         $actionButtonsComposite->push($addFolderBtn);
     }
     // Add the upload field for new media
     if ($currentPageID = $this->currentPageID()) {
         Session::set("{$this->class}.currentPage", $currentPageID);
     }
     $folder = $this->currentPage();
     $uploadField = UploadField::create('AssetUploadField', '');
     $uploadField->setConfig('previewMaxWidth', 40);
     $uploadField->setConfig('previewMaxHeight', 30);
     $uploadField->setConfig('changeDetection', false);
     $uploadField->addExtraClass('ss-assetuploadfield');
     $uploadField->removeExtraClass('ss-uploadfield');
     $uploadField->setTemplate('AssetUploadField');
     if ($folder->exists()) {
         $path = $folder->getFilename();
         $uploadField->setFolderName($path);
     } else {
         $uploadField->setFolderName('/');
         // root of the assets
     }
     $exts = $uploadField->getValidator()->getAllowedExtensions();
     asort($exts);
     $uploadField->Extensions = implode(', ', $exts);
     // List view
     $fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create($actionButtonsComposite)->addExtraClass('cms-content-toolbar field'), $uploadField, new HiddenField('ID'), $gridField));
     // Tree view
     $fields->addFieldsToTab('Root.TreeView', array(clone $actionsComposite, new LiteralField('Tree', FormField::create_tag('div', array('class' => 'cms-tree', 'data-url-tree' => $this->Link('getsubtree'), 'data-url-savetreenode' => $this->Link('savetreenode')), $this->SiteTreeAsUL()))));
     // Move actions to "details" tab (they don't make sense on list/tree view)
     $actions = $form->Actions();
     $saveBtn = $actions->fieldByName('action_save');
     $deleteBtn = $actions->fieldByName('action_delete');
     $actions->removeByName('action_save');
     $actions->removeByName('action_delete');
     if (($saveBtn || $deleteBtn) && $fields->fieldByName('Root.DetailsView')) {
         $fields->addFieldToTab('Root.DetailsView', CompositeField::create($saveBtn, $deleteBtn)->addExtraClass('Actions'));
     }
     $fields->setForm($form);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // TODO Can't merge $FormAttributes in template at the moment
     $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     $this->extend('updateEditForm', $form);
     return $form;
 }
 /**
  * Returns modified CMS fields for the payment modules
  *
  * @return FieldList
  */
 public function getCMSFieldsForModules()
 {
     $this->getCMSFieldsIsCalled = true;
     $tabset = new TabSet('Root');
     $fields = new FieldList($tabset);
     // --------------------------------------------------------------------
     // Common GUI elements for all payment methods
     // --------------------------------------------------------------------
     $tabBasic = new Tab('Basic', _t('SilvercartPaymentMethod.BASIC_SETTINGS', 'basic settings'));
     $translationsTab = new Tab('Translations');
     $translationsTab->setTitle(_t('SilvercartConfig.TRANSLATIONS'));
     $tabset->push($tabBasic);
     $tabset->push($translationsTab);
     $tabBasicFieldList = new FieldList();
     $tabBasic->setChildren($tabBasicFieldList);
     //multilingual fields
     $tabBasicFieldList->push(new CheckboxField('isActive', _t('SilvercartShopAdmin.PAYMENT_ISACTIVE', 'activated')));
     $tabBasicFieldList->push(new DropdownField('mode', _t('SilvercartPaymentMethod.MODE', 'mode'), array('Live' => $this->fieldLabel('modeLive'), 'Dev' => $this->fieldLabel('modeDev')), $this->mode));
     if ($this->isExtendingSilvercartPaymentMethod()) {
         $languageFields = SilvercartLanguageHelper::prepareCMSFields($this->getLanguageClassName());
         foreach ($languageFields as $languageField) {
             $tabBasicFieldList->push($languageField);
         }
     }
     $tabBasicFieldList->push(new TextField('minAmountForActivation', _t('SilvercartShopAdmin.PAYMENT_MINAMOUNTFORACTIVATION')));
     $tabBasicFieldList->push(new TextField('maxAmountForActivation', _t('SilvercartShopAdmin.PAYMENT_MAXAMOUNTFORACTIVATION')));
     $tabBasicFieldList->push(new DropdownField('orderStatus', _t('SilvercartPaymentMethod.STANDARD_ORDER_STATUS', 'standard order status for this payment method'), SilvercartOrderStatus::getStatusList()->map('Code', 'Title')->toArray()));
     $tabBasicFieldList->dataFieldByName('orderStatus')->setEmptyString(_t("SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE"));
     // --------------------------------------------------------------------
     // Handling cost table
     // --------------------------------------------------------------------
     $tabHandlingCosts = new Tab('HandlingCosts', _t('SilvercartPaymentMethod.HANDLINGCOSTS_SETTINGS'));
     $tabset->push($tabHandlingCosts);
     $handlingCostField = new GridField('SilvercartHandlingCosts', $this->fieldLabel('SilvercartHandlingCosts'), $this->SilvercartHandlingCosts(), SilvercartGridFieldConfig_RelationEditor::create(50));
     $tabHandlingCosts->setChildren(new FieldList($handlingCostField));
     // --------------------------------------------------------------------
     // GUI for management of logo images
     // --------------------------------------------------------------------
     $tabLogos = new Tab('Logos', _t('SilvercartPaymentMethod.PAYMENT_LOGOS', 'Payment Logos'));
     $tabset->push($tabLogos);
     $paymentLogosTable = new GridField('PaymentLogos', $this->fieldLabel('PaymentLogos'), $this->PaymentLogos(), SilvercartGridFieldConfig_RelationEditor::create());
     $paymentLogosTable->getConfig()->removeComponentsByType('GridFieldAddNewButton');
     $paymentLogosTable->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter');
     $paymentLogosTable->getConfig()->addComponent(new GridFieldDeleteAction());
     $paymentLogosUploadField = new SilvercartImageUploadField('UploadPaymentLogos', $this->fieldLabel('AddPaymentLogos'));
     $paymentLogosUploadField->setFolderName('Uploads/payment-images');
     $tabLogos->setChildren(new FieldList(new CheckboxField('showPaymentLogos', _t('SilvercartShopAdmin.SHOW_PAYMENT_LOGOS')), $paymentLogosUploadField, $paymentLogosTable));
     // --------------------------------------------------------------------
     // GUI for access management
     // --------------------------------------------------------------------
     $tabAccessManagement = new Tab('AccessManagement', _t('SilvercartPaymentMethod.ACCESS_SETTINGS', 'Access management'));
     $tabset->push($tabAccessManagement);
     $tabsetAccessManagement = new TabSet('AccessManagementSection');
     $tabAccessManagement->push($tabsetAccessManagement);
     $tabAccessManagementBasic = new Tab('AccessManagementBasic', _t('SilvercartPaymentMethod.ACCESS_MANAGEMENT_BASIC_LABEL', 'General'));
     $tabAccessManagementGroup = new Tab('AccessManagementGroup', _t('SilvercartPaymentMethod.ACCESS_MANAGEMENT_GROUP_LABEL', 'By group(s)'));
     $tabAccessManagementUser = new Tab('AccessManagementUser', _t('SilvercartPaymentMethod.ACCESS_MANAGEMENT_USER_LABEL', 'By user(s)'));
     $tabsetAccessManagement->push($tabAccessManagementBasic);
     $tabsetAccessManagement->push($tabAccessManagementGroup);
     $tabsetAccessManagement->push($tabAccessManagementUser);
     $showOnlyForGroupsTable = new GridField('ShowOnlyForGroups', $this->fieldLabel('ShowOnlyForGroups'), $this->ShowOnlyForGroups(), SilvercartGridFieldConfig_RelationEditor::create());
     $showNotForGroupsTable = new GridField('ShowNotForGroups', $this->fieldLabel('ShowNotForGroups'), $this->ShowNotForGroups(), SilvercartGridFieldConfig_RelationEditor::create());
     $showOnlyForUsersTable = new GridField('ShowOnlyForUsers', $this->fieldLabel('ShowOnlyForUsers'), $this->ShowOnlyForUsers(), SilvercartGridFieldConfig_RelationEditor::create());
     $showNotForUsersTable = new GridField('ShowNotForUsers', $this->fieldLabel('ShowNotForUsers'), $this->ShowNotForUsers(), SilvercartGridFieldConfig_RelationEditor::create());
     $restrictionByOrderQuantityField = new TextField('orderRestrictionMinQuantity', '');
     $restrictionByOrderStatusField = new GridField('OrderRestrictionStatus', $this->fieldLabel('SilvercartOrderStatus'), $this->OrderRestrictionStatus(), SilvercartGridFieldConfig_RelationEditor::create());
     // Access management basic --------------------------------------------
     $tabAccessManagementBasic->push(new HeaderField('RestrictionLabel', _t('SilvercartPaymentMethod.RESTRICTION_LABEL') . ':', 2));
     $tabAccessManagementBasic->push(new LiteralField('separatorForActivationByOrderRestrictions', '<hr />'));
     $tabAccessManagementBasic->push(new CheckboxField('enableActivationByOrderRestrictions', _t('SilvercartPaymentMethod.ENABLE_RESTRICTION_BY_ORDER_LABEL')));
     $tabAccessManagementBasic->push(new LiteralField('RestrictionByOrderQuantityLabel', '<p>' . _t('SilvercartPaymentMethod.RESTRICT_BY_ORDER_QUANTITY') . ':</p>'));
     $tabAccessManagementBasic->push($restrictionByOrderQuantityField);
     $tabAccessManagementBasic->push(new LiteralField('RestrictionByOrderStatusLabel', '<p>' . _t('SilvercartPaymentMethod.RESTRICT_BY_ORDER_STATUS') . ':</p>'));
     $tabAccessManagementBasic->push($restrictionByOrderStatusField);
     // Access management for groups ---------------------------------------
     $tabAccessManagementGroup->push(new HeaderField('ShowOnlyForGroupsLabel', _t('SilvercartPaymentMethod.SHOW_ONLY_FOR_GROUPS_LABEL') . ':', 2));
     $tabAccessManagementGroup->push($showOnlyForGroupsTable);
     $tabAccessManagementGroup->push(new HeaderField('ShowNotForGroupsLabel', _t('SilvercartPaymentMethod.SHOW_NOT_FOR_GROUPS_LABEL') . ':', 2));
     $tabAccessManagementGroup->push($showNotForGroupsTable);
     // Access management for users ----------------------------------------
     $tabAccessManagementUser->push(new HeaderField('ShowOnlyForUsersLabel', _t('SilvercartPaymentMethod.SHOW_ONLY_FOR_USERS_LABEL') . ':', 2));
     $tabAccessManagementUser->push($showOnlyForUsersTable);
     $tabAccessManagementUser->push(new HeaderField('ShowNotForUsersLabel', _t('SilvercartPaymentMethod.SHOW_NOT_FOR_USERS_LABEL') . ':', 2));
     $tabAccessManagementUser->push($showNotForUsersTable);
     // --------------------------------------------------------------------
     // Countries
     // --------------------------------------------------------------------
     $countriesTab = new Tab('SilvercartCountries', $this->fieldLabel('SilvercartCountries'));
     $tabset->push($countriesTab);
     $countriesTable = new GridField('SilvercartCountries', $this->fieldLabel('SilvercartCountries'), $this->SilvercartCountries(), SilvercartGridFieldConfig_RelationEditor::create());
     $countriesTab->push($countriesTable);
     // --------------------------------------------------------------------
     // shipping methods
     // --------------------------------------------------------------------
     $shippingMethodsTab = new Tab('SilvercartShippingMethods', $this->fieldLabel('SilvercartShippingMethods'));
     $shippingMethodsDesc = new HeaderField('SilvercartShippingMethodsDesc', _t('SilvercartPaymentMethod.SHIPPINGMETHOD_DESC'));
     $shippingMethodsTable = new GridField('SilvercartShippingMethods', _t('SilvercartPaymentMethod.SHIPPINGMETHOD', 'shipping method'), $this->SilvercartShippingMethods(), SilvercartGridFieldConfig_RelationEditor::create(50));
     $tabset->push($shippingMethodsTab);
     $shippingMethodsTab->push($shippingMethodsDesc);
     $shippingMethodsTab->push($shippingMethodsTable);
     $this->getFieldsForChargesAndDiscounts($fields);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * Return the FieldSet used to edit a dynamic template in the CMS.
  */
 function getCMSFields()
 {
     // // delete files button
     // if( $this->canEdit() ) {
     // 	$deleteButton = new InlineFormAction('deletemarked',_t('Folder.DELSELECTED','Delete selected files'), 'delete');
     // 	$deleteButton->includeDefaultJS(false);
     // } else {
     // 	$deleteButton = new HiddenField('deletemarked');
     // }
     // link file button
     if ($this->canEdit()) {
         $fileButtons = new CompositeField($linkFileButton = new InlineFormAction('linkfile', _t('DynamicTemplate.LINKFILE', 'Link file(s) from theme'), 'link'), $copyFileButton = new InlineFormAction('copyfile', _t('DynamicTemplate.COPYFILE', 'Copy file(s) from theme'), 'copy'), $newFileButton = new InlineFormAction('newfile', _t('DynamicTemplate.NEWFILE', 'New file'), 'newfile'));
         $linkFileButton->includeDefaultJS(false);
         $copyFileButton->includeDefaultJS(false);
         $newFileButton->includeDefaultJS(false);
     } else {
         $fileButtons = new HiddenField('linkfile');
     }
     $propButtons = new CompositeField();
     //		$propButtons->push($exportButton = new InlineFormAction('exporttemplate', _t('DynamicTemplate.EXPORTTEMPLATE', 'Export'), 'export'));
     //		$exportButton->includeDefaultJS(false);
     //		if ($this->canEdit()) {
     //			$propButtons->push($saveButton = new InlineFormAction('savetemplate', _t('DynamicTemplate.SAVETEMPLATE', 'Save'), 'save'));
     //			$saveButton->includeDefaultJS(false);
     //		}
     if (DynamicTemplateAdmin::tarball_available()) {
         $exportTarballButton = new InlineFormAction('exportastarball', _t('DynamicTemplate.EXPORT', 'Export as tarball'), 'exportastarball');
         $exportTarballButton->includeDefaultJS(false);
         $propButtons->push($exportTarballButton);
     }
     if (DynamicTemplateAdmin::zip_available()) {
         $exportZipButton = new InlineFormAction('exportaszip', _t('DynamicTemplate.EXPORT', 'Export as zip'), 'exportaszip');
         $exportZipButton->includeDefaultJS(false);
         $propButtons->push($exportZipButton);
     }
     //		$titleField = ($this->ID && $this->ID != "root") ? new TextField("Title", _t('Folder.TITLE', 'Title')) : new HiddenField("Title");
     $titleField = new TextField("Title", _t('Folder.TITLE', 'Title'));
     if (!$this->canEdit()) {
         $titleField->setReadOnly(true);
     }
     $nameField = new TextField("Name");
     if (!$this->canEdit()) {
         $titleField->setReadOnly(true);
     }
     $fields = new FieldList($rootTabSet = new TabSet("Root", new Tab("Properties", _t('DynamicTemplate.PROPERTIESTAB', 'Properties'), $titleField, new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated')), new HiddenField("ID"), new HiddenField("ClassName", null, "DynamicTemplate"), $propButtons), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LabelField('UploadPrompt', _t('DynamicTemplate.UPLOADPROMPT', 'Upload files to your template. Uploads will automatically be added to the right place.')), $this->getUploadField())));
     // A DT can only have files if it has been saved at least once. This is also to avoid time out issue where DynamicTemplatesFileField::calc_tree
     // tries to find files from a DT with ID=0
     if ($this->ID) {
         $fileList = new DynamicTemplateFilesField("Files", "Files", $this);
         $rootTabSet->push(new Tab("Files", _t('Folder.FILESTAB', "Files"), $fileList, $fileButtons, new HiddenField("FileIDs"), new HiddenField("DestFolderID")));
     }
     if (!$this->canEdit()) {
         $fields->removeFieldFromTab("Root", "Upload");
     }
     $this->extend('updateCMSFields', $fields);
     Session::set("dynamictemplates_currentID", $this->ID);
     return $fields;
 }
Ejemplo n.º 12
0
	public function getEditForm($id = null, $fields = null) {
		$form = parent::getEditForm($id, $fields);
		$folder = ($id && is_numeric($id)) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
		$fields = $form->Fields();

		$fields->push(new HiddenField('ID', false, $folder->ID));

		// File listing
		$gridFieldConfig = GridFieldConfig::create()->addComponents(
			new GridFieldSortableHeader(),
			new GridFieldDataColumns(),
			new GridFieldPaginator(15),
			new GridFieldEditButton(),
			new GridFieldDeleteAction(),
			new GridFieldDetailForm()
		);
		$gridField = new GridField('File','Files', $this->getList(), $gridFieldConfig);
		$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
		$columns->setDisplayFields(array(
			'StripThumbnail' => '',
			// 'Parent.FileName' => 'Folder',
			'Title' => _t('File.Name'),
			'Created' => _t('AssetAdmin.CREATED', 'Date'),
			'Size' => _t('AssetAdmin.SIZE', 'Size'),
		));
		$columns->setFieldCasting(array(
			'Created' => 'Date->Nice'
		));
		$gridField->setAttribute(
			'data-url-folder-template', 
			Controller::join_links($this->Link('show'), '%s')
		);

		if($folder->canCreate()) {
			$uploadBtn = new LiteralField(
				'UploadButton', 
				sprintf(
					'<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-target-panel=".cms-content" data-icon="drive-upload" href="%s">%s</a>',
					Controller::join_links(singleton('CMSFileAddController')->Link(), '?ID=' . $folder->ID),
					_t('Folder.UploadFilesButton', 'Upload')
				)
			);	
		} else {
			$uploadBtn = null;
		}

		if(!$folder->hasMethod('canAddChildren') || ($folder->hasMethod('canAddChildren') && $folder->canAddChildren())) {
			// TODO Will most likely be replaced by GridField logic
			$addFolderBtn = new LiteralField(
				'AddFolderButton', 
				sprintf(
					'<a class="ss-ui-button ss-ui-action-constructive cms-add-folder-link" data-icon="add" data-url="%s" href="%s">%s</a>',
					Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array(
						'action_doAdd' => 1,
						'ParentID' => $folder->ID,
						'SecurityID' => $form->getSecurityToken()->getValue()
					))),
					Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID),
					_t('Folder.AddFolderButton', 'Add folder')
				)
			);
		} else {
			$addFolderBtn = '';
		}

		if($folder->canEdit()) {
			$syncButton = new LiteralField(
				'SyncButton',
				sprintf(
					'<a class="ss-ui-button ss-ui-action ui-button-text-icon-primary ss-ui-button-ajax" title="%s" href="%s">%s</a>',
					_t('AssetAdmin.FILESYSTEMSYNCTITLE', 'Update the CMS database entries of files on the filesystem. Useful when new files have been uploaded outside of the CMS, e.g. through FTP.'),
					$this->Link('doSync'),
					_t('FILESYSTEMSYNC','Sync files')
				)
			);
		} else {
			$syncButton = null;
		}
		
		// Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
		// Required to keep Folder->getCMSFields() simple and reuseable,
		// without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
		if(!$fields->hasTabset()) {
			$tabs = new TabSet('Root', 
				$tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')),
				$tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View'))
			);
			$tabList->addExtraClass("content-listview");
			$tabTree->addExtraClass("content-treeview");
			if($fields->Count() && $folder->exists()) {
				$tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
				$tabDetails->addExtraClass("content-galleryview");
				foreach($fields as $field) {
					$fields->removeByName($field->getName());
					$tabDetails->push($field);
				}
			}
			$fields->push($tabs);
		}

		// List view
		$fields->addFieldsToTab('Root.ListView', array(
			$actionsComposite = CompositeField::create(
				CompositeField::create(
					$uploadBtn,
					$addFolderBtn,
					$syncButton //TODO: add this into a batch actions menu as in https://github.com/silverstripe/silverstripe-design/raw/master/Design/ss3-ui_files-manager-list-view.jpg
				)->addExtraClass('cms-actions-row')
			)->addExtraClass('cms-content-toolbar field'),
			$gridField
		));
		
		$treeField = new LiteralField('Tree', '');
		// Tree view
		$fields->addFieldsToTab('Root.TreeView', array(
			clone $actionsComposite,
			// TODO Replace with lazy loading on client to avoid performance hit of rendering potentially unused views
			new LiteralField(
				'Tree',
				$treeField->createTag(
					'div', 
					array(
						'class' => 'cms-tree', 
						'data-url-tree' => $this->Link('getsubtree'), 
						'data-url-savetreenode' => $this->Link('savetreenode')
					),
					$this->SiteTreeAsUL()
				)
			)
		));

		$fields->setForm($form);
		$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
		// TODO Can't merge $FormAttributes in template at the moment
		$form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
		$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');

		$this->extend('updateEditForm', $form);

		return $form;
	}