public function updateCMSFields(FieldList $fields)
 {
     foreach (['primary', 'secondary'] as $lower) {
         $upper = ucfirst($lower);
         $config = $this->owner->config()->get("{$lower}_gallery");
         if (is_null($config) || isset($config['enabled']) && $config['enabled'] === false) {
             continue;
         }
         $config['title'] = isset($config['title']) ? $config['title'] : "{$upper} Gallery";
         $config['folder'] = isset($config['folder']) ? $config['folder'] : "{$upper}-Gallery-Images";
         $GridFieldConfig = new GridFieldConfig_RecordEditor();
         $GridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
         $GridFieldConfig->addComponent($bulkUploadConfig = new GridFieldBulkUpload());
         $GridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
         $GridFieldConfig->addComponent(new GridFieldGalleryTheme('Image'));
         $bulkUploadConfig->setUfSetup('setFolderName', "Images/{$config['folder']}");
         $GridField = new GridField("{$upper}GalleryGridField", $config['title'], $this->owner->{"{$upper}GalleryImages"}(), $GridFieldConfig);
         /** @var TabSet $rootTab */
         //We need to repush Metadata to ensure it is the last tab
         $rootTab = $fields->fieldByName('Root');
         $rootTab->push($tab = Tab::create("{$upper}Gallery"));
         if ($rootTab->fieldByName('Metadata')) {
             $metaChildren = $rootTab->fieldByName('Metadata')->getChildren();
             $rootTab->removeByName('Metadata');
             $rootTab->push(Tab::create('Metadata')->setChildren($metaChildren));
         }
         $tab->setTitle($config['title']);
         $fields->addFieldToTab("Root.{$upper}Gallery", $GridField);
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Main Content tab
     // Carousel tab
     $carouselItemsGrid = null;
     // Manay to many relations can only be established if we have an id. So put a place holder instead of a grid if this is a new object.
     if ($this->ID == 0) {
         $carouselItemsGrid = TextField::create("CarouselItems", "Carousel Items")->setDisabled(true)->setValue("Page must be saved once before adding Carousel Items.");
     } else {
         $carouselItemsGrid = new GridField('CarouselItems', 'Carousel', $this->CarouselItems()->sort('Archived'), GridFieldConfig_RelationEditor::create());
         $carouselItemsGridUploadComponent = new GridFieldBulkUpload("Image");
         $carouselItemsGridUploadComponent->setUfSetup("setFolderName", $this->ImageFolder("carousel"));
         $carouselItemsGrid->setModelClass('CarouselItem')->getConfig()->addComponent($carouselItemsGridUploadComponent)->addComponent(new GridFieldOrderableRows("SortID"));
     }
     $fields->addFieldToTab('Root.Carousel', $carouselItemsGrid);
     // Links
     $fields->addFieldToTab('Root.Links', new TreeDropdownField('LearnMorePageID', 'Page to link the "Learn More" button to:', 'SiteTree'));
     $fields->addFieldToTab('Root.Links', new TextField('LearnMoreButtonText', 'Text to display on the "Learn More" button:', 'SiteTree'));
     $quickLinksGrid = new GridField('Quicklinks', 'Quicklinks', $this->Quicklinks(), GridFieldConfig_RelationEditor::create());
     $quickLinksGrid->setModelClass('Quicklink');
     $quickLinksFieldGroup = FieldGroup::create($quickLinksGrid)->setTitle('Quick Links');
     $quickLinksFieldGroup->setName("QuicklinkGroup");
     $fields->addFieldToTab('Root.Links', $quickLinksFieldGroup);
     $fields->removeByName('Translations');
     $fields->removeByName('Import');
     $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureOne', _t('SiteTree.FeatureOne', 'Feature One'), array(new TextField('FeatureOneTitle', 'Title'), new DropdownField('FeatureOneCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureOneCategory')->enumValues()), new HTMLEditorField('FeatureOneContent', 'Content'), new TreeDropdownField('FeatureOneLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureOneButtonText', 'Button text')))->setHeadingLevel(3));
     $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureTwo', _t('SiteTree.FeatureTwo', 'Feature Two'), array(new TextField('FeatureTwoTitle', 'Title'), new DropdownField('FeatureTwoCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureTwoCategory')->enumValues()), new HTMLEditorField('FeatureTwoContent', 'Content'), new TreeDropdownField('FeatureTwoLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureTwoButtonText', 'Button text')))->setHeadingLevel(3));
     return $fields;
 }
 /**
  * Get CMS Fields
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Images');
     $fields->removeFieldsFromTab('Root.Main', array('BackgroundImage'));
     $gridFieldBulkUpload = new GridFieldBulkUpload();
     $gridFieldBulkUpload->setUfSetup('setFolderName', 'GalleryImages/' . $this->ID);
     $fields->insertBefore(GridField::create('Images', 'Images', $this->Images(), GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldSortableRows('SortOrder'))->addComponent($gridFieldBulkUpload)), 'ExtraClassDescriptionContainer');
     return $fields;
 }
 public function getCMSFields()
 {
     if ($this->ID == 0) {
         $PhotosGridField = TextField::create('PhotosDisclaimer')->setTitle('Photos')->setDisabled(true)->setValue('You can add photos once you have saved the record for the first time.');
         $ImageField = TextField::create('AlbumCoverDisclaimer')->setTitle('Album Cover Photo')->setDisabled(true)->setValue('You can add an album cover once you have saved the record for the first time.');
     } else {
         $BulkUploadComponent = new GridFieldBulkUpload();
         $BulkUploadComponent->setUfSetup('setFolderName', "photogallery/" . $this->PageFolder() . "/" . $this->AlbumFolder());
         $PhotosGridField = new GridField('PhotoItems', 'Photos', $this->PhotoItems(), GridFieldConfig::create()->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldAddNewButton("toolbar-header-right"))->addComponent(new GridFieldSortableHeader())->addComponent(new GridFieldDataColumns())->addComponent(new GridFieldPaginator(50))->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldDetailForm())->addComponent(new GridFieldFilterHeader())->addComponent(new GridFieldBulkManager())->addComponent($BulkUploadComponent)->addComponent($sortable = new GridFieldSortableRows('SortID')));
         if ($this->getComponent('PhotoGallery')->PhotoDefaultTop == true) {
             $sortable->setAppendToTop(true);
         }
         $ImageField = UploadField::create('AlbumCover')->setTitle('Album Cover Photo');
         $ImageField->folderName = 'photogallery/' . $this->PageFolder();
         $ImageField->getValidator()->allowedExtensions = array("jpg", "jpeg", "gif", "png");
     }
     $Fields = new FieldList(TextField::create('Name'), TextareaField::create('Description'), $ImageField, $PhotosGridField);
     $this->extend('updateCMSFields', $Fields);
     return $Fields;
 }
 public function getCMSFields()
 {
     // If the album is not created yet, ask first for an album title to create the folder
     if (!$this->ID) {
         $fields = new FieldList();
         $fields->push(new TextField('AlbumName', _t('MagnificGalleryAlbum.ALBUMTITLE', 'Album Title'), null, 255));
         $fields->push(new LiteralField('AlbumSaveInfos', _t('MagnificGalleryAlbum.ALBUMSAVEINFOS', 'You can add images and a description once the album is saved'), null, 255));
         return $fields;
     }
     $fields = new FieldList(new TabSet('Root'));
     // Image listing
     $galleryConfig = GridFieldConfig_RecordEditor::create();
     // Enable bulk image loading if necessary module is installed
     // @see composer.json/suggests
     if (class_exists('GridFieldBulkManager')) {
         $galleryConfig->addComponent(new GridFieldBulkManager());
     }
     if (class_exists('GridFieldBulkUpload')) {
         $galleryConfig->addComponents($imageConfig = new GridFieldBulkUpload('Image'));
         $imageConfig->setUfSetup('setFolderName', $this->getUploadFolder());
     }
     // Enable image sorting if necessary module is installed
     // @see composer.json/suggests
     if (class_exists('GridFieldSortableRows')) {
         $galleryConfig->addComponent(new GridFieldSortableRows('SortOrder'));
     } else {
         if (class_exists('GridFieldOrderableRows')) {
             $galleryConfig->addComponent(new GridFieldOrderableRows('SortOrder'));
         }
     }
     $galleryField = new GridField('GalleryItems', 'Gallery Items', $this->GalleryItems(), $galleryConfig);
     $fields->addFieldToTab('Root.Main', $galleryField);
     // Details
     $thumbnailField = new UploadField('CoverImage', _t('MagnificGalleryAlbum.COVERIMAGE', 'Cover Image'));
     $thumbnailField->getValidator()->setAllowedExtensions(File::config()->app_categories['image']);
     $thumbnailField->setFolderName($this->getUploadFolder());
     $fields->addFieldsToTab('Root.Album', array(new TextField('AlbumName', _t('MagnificGalleryAlbum.ALBUMTITLE', 'Album Title'), null, 255), new TextareaField('Description', _t('MagnificGalleryAlbum.DESCRIPTION', 'Description')), $thumbnailField));
     return $fields;
 }