Inheritance: implements GridField_HTMLProvider, implements GridField_ActionProvider, implements GridField_DataManipulator
 public function getCMSFields()
 {
     $DefaultAlbumCoverField = UploadField::create('DefaultAlbumCover');
     $DefaultAlbumCoverField->folderName = "PhotoGallery";
     $DefaultAlbumCoverField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
     $fields = parent::getCMSFields();
     $AlbumsGridField = new GridField("PhotoAlbums", "Album", $this->PhotoAlbums(), 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($sortable = new GridFieldSortableRows('SortID')));
     if ($this->AlbumDefaultTop == true) {
         $sortable->setAppendToTop(true);
     }
     $fields->addFieldToTab("Root.Albums", $AlbumsGridField);
     $fields->addFieldToTab("Root.Config", HeaderField::create("Album Settings"));
     $fields->addFieldToTab("Root.Config", $DefaultAlbumCoverField);
     $fields->addFieldToTab("Root.Config", SliderField::create('AlbumsPerPage', 'Number of Albums Per Page', 1, 25));
     $fields->addFieldToTab("Root.Config", SliderField::create("AlbumThumbnailWidth", "Album Cover Thumbnail Width", 50, 400));
     $fields->addFieldToTab("Root.Config", SliderField::create("AlbumThumbnailHeight", "Album Cover Thumbnail Height", 50, 400));
     $fields->addFieldToTab("Root.Config", CheckboxField::create("ShowAllPhotoAlbums")->setTitle("Show photo album even if it's empty"));
     $fields->addFieldToTab("Root.Config", CheckboxField::create("AlbumDefaultTop")->setTitle("Sort new albums to the top by default"));
     $fields->addFieldToTab("Root.Config", HeaderField::create("Photo Settings"));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotosPerPage", "Number of Photos Per Page", 1, 50));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoThumbnailWidth", "Photo Thumbnail Width", 50, 400));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoThumbnailHeight", "Photo Thumbnail Height", 50, 400));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoFullWidth", "Photo Fullsize Width", 400, 1200));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoFullHeight", "Photo Fullsize Height", 400, 1200));
     $fields->addFieldToTab("Root.Config", CheckboxField::create("PhotoDefaultTop")->setTitle("Sort new photos to the top by default"));
     return $fields;
 }
コード例 #2
0
 function updateCMSFields(FieldList $fields)
 {
     //prevent certain pages from having a Document tab in the CMS
     if (in_array($this->owner->ClassName, self::$noDocumentsList)) {
         return;
     }
     //javascript to customize the grid field for the DMS document (overriding entwine in FRAMEWORK_DIR.'/javascript/GridField.js'
     Requirements::javascript(DMS_DIR . '/javascript/DMSGridField.js');
     Requirements::css(DMS_DIR . '/css/DMSMainCMS.css');
     //javascript for the link editor pop-up in TinyMCE
     Requirements::javascript(DMS_DIR . "/javascript/DocumentHtmlEditorFieldToolbar.js");
     // Document listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldEditButton(), new DMSGridFieldDeleteAction(), new GridFieldDetailForm());
     if (class_exists('GridFieldPaginatorWithShowAll')) {
         $paginatorComponent = new GridFieldPaginatorWithShowAll(15);
     } else {
         $paginatorComponent = new GridFieldPaginator(15);
     }
     $gridFieldConfig->addComponent($paginatorComponent);
     if (class_exists('GridFieldSortableRows')) {
         $sortableComponent = new GridFieldSortableRows('DocumentSort');
         $sortableComponent->setUsePagination(false)->setForceRedraw(true);
         $gridFieldConfig->addComponent($sortableComponent);
     }
     // HACK: Create a singleton of DMSDocument to ensure extensions are applied before we try to get display fields.
     singleton('DMSDocument');
     $gridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields(Config::inst()->get('DMSDocument', 'display_fields'))->setFieldCasting(array('LastChanged' => "Datetime->Ago"))->setFieldFormatting(array('FilenameWithoutID' => '<a target=\'_blank\' class=\'file-url\' href=\'$Link\'>$FilenameWithoutID</a>'));
     //override delete functionality with this class
     $gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('DMSGridFieldDetailForm_ItemRequest');
     $gridField = GridField::create('Documents', false, $this->owner->Documents()->Sort('DocumentSort'), $gridFieldConfig);
     $gridField->addExtraClass('documents');
     $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="add" href="%s">%s</a>', Controller::join_links(singleton('DMSDocumentAddController')->Link(), '?ID=' . $this->owner->ID), "Add Documents"));
     $fields->addFieldsToTab('Root.Documents (' . $this->owner->Documents()->Count() . ')', array($uploadBtn, $gridField));
 }
コード例 #3
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Main", new TextField("Description", "Description", "", 100));
     $conf = GridFieldConfig_RelationEditor::create(10);
     $conf->addComponent($sortable = new GridFieldSortableRows('SortID'));
     //Append new GalleryItems to the top
     $sortable->setAppendToTop(true);
     $field = TagField::create('GalleryTags', 'Gallery Tags', GalleryTag::get(), $this->GalleryTags())->setShouldLazyLoad(true)->setCanCreate(true);
     // new tag DataObjects can be created;
     $fields->addFieldToTab('Root.Tags', $field);
     $fields->addFieldToTab('Root.MyAlbum', new GridField('GalleryItems', 'My Album', $this->GalleryItems(), $conf));
     return $fields;
 }
コード例 #4
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', HTMLEditorField::create('BottomContent')->setTitle('Content for below the list items'), 'Metadata');
     $fields->addFieldToTab('Root.ListItems', GridField::create('ListItems', 'List Items', $this->ListItems(), GridFieldConfig_RecordEditor::create('50')->addComponent($sortableitems = new GridFieldSortableRows('SortID'))));
     $sortableitems->setAppendToTop(true);
     $fields->addFieldToTab('Root.ListCategories', GridField::create('ListCategories', 'List Categories', $this->ListCategories(), GridFieldConfig_RecordEditor::create('50')->addComponent($sortablecategories = new GridFieldSortableRows('SortID'))));
     $sortablecategories->setAppendToTop(true);
     $fields->addFieldToTab('Root.Config', HeaderField::create('ListItemsDesc')->setTitle('List Items Options'));
     $fields->addFieldToTab('Root.Config', CheckboxField::create('AlphabeticalOrder')->setTitle('Alphabetical Order for List Items')->setDescription('Show in alphabetical order (By the list item title, overwrites drag and drop order)'));
     $fields->addFieldToTab('Root.Config', CheckboxField::create('ToggleEffectItems')->setTitle('Toggle Effect for List Items')->setDescription('Set toggle effect on list items'));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoMaxWidth", "Max Photo Width", 50, 1600)->setDescription('For photo that is associated with list items'));
     $fields->addFieldToTab('Root.Config', HeaderField::create('ListCategoriesDesc')->setTitle('List Categories Options'));
     $fields->addFieldToTab('Root.Config', CheckboxField::create('AlphaOrderCategories')->setTitle('Alphabetical Order for List Categories')->setDescription('Show in alphabetical order (By the list category title, overwrites drag and drop ordering)'));
     $fields->addFieldToTab('Root.Config', CheckboxField::create('ToggleEffect')->setTitle('Toggle Effect for List Cateogries')->setDescription('Set toggle effect on list categories'));
     $fields->addFieldToTab('Root.Config', CheckboxField::create('StartToggleClosed')->setTitle('Start Toggle Closed for List Categories')->setDescription('The toggle for all catogries will start closed, if off the first category toggle will be open'));
     return $fields;
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     $fields->removeByName('Images');
     $name = Config::inst()->get('SimpleGalleryExtension', 'gallery_name');
     if ($this->owner->ID > 0) {
         $folder = Config::inst()->get('SimpleGalleryExtension', 'folder_path');
         if (strlen($folder) == 0) {
             $folder = 'simplegallery';
         }
         $gridFieldConfig = GridFieldConfig_RecordEditor::create();
         $bu = new GridFieldBulkImageUpload('Image', array('Title'));
         $bu->setConfig('folderName', $folder);
         $gridFieldConfig->addComponent($bu);
         $gridFieldSortableRows = new GridFieldSortableRows('SortOrder');
         $gridFieldConfig->addComponent($gridFieldSortableRows->setAppendToTop(true));
         $gridfield = new GridField("Gallery", $name, $this->SortedImages(true), $gridFieldConfig);
         $fields->addFieldToTab('Root.' . $name, $gridfield);
     }
     return $fields;
 }