/**
  * @param FieldList $fields
  * @return FieldList|void
  */
 public function updateCMSFields(FieldList $fields)
 {
     $oldFields = $fields->toArray();
     foreach ($oldFields as $field) {
         $fields->remove($field);
     }
     $fields->push(new TextField("Title", "Title"));
     $fields->push(new HtmlEditorField("Summary", "Summary"));
     $fields->push(new HtmlEditorField("Description", "Description"));
     $fields->push(new MemberAutoCompleteField("Curator", "Curator"));
     $fields->push($ddl = new DropdownField('ReleaseID', 'Release', OpenStackRelease::get()->map("ID", "Name")));
     $ddl->setEmptyString('-- Select a Release --');
     if ($this->owner->ID > 0) {
         $components_config = new GridFieldConfig_RelationEditor(100);
         $components = new GridField("OpenStackComponents", "Supported Release Components", $this->owner->OpenStackComponents(), $components_config);
         $components_config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchList($this->getAllowedComponents());
         $components_config->removeComponentsByType('GridFieldAddNewButton');
         //$components_config->addComponent(new GridFieldSortableRows('OpenStackSampleConfig_OpenStackComponents.Order'));
         $fields->push($components);
         $fields->push($ddl = new DropdownField('TypeID', 'Type', OpenStackSampleConfigurationType::get()->filter('ReleaseID', $this->owner->ReleaseID)->map("ID", "Type")));
         $ddl->setEmptyString('-- Select a Configuration Type --');
         $related_notes_config = new GridFieldConfig_RecordEditor(100);
         $related_notes = new GridField("RelatedNotes", "Related Notes", $this->owner->RelatedNotes(), $related_notes_config);
         $related_notes_config->addComponent(new GridFieldSortableRows('Order'));
         $fields->push($related_notes);
     }
     return $fields;
 }
 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;
 }
Ejemplo n.º 5
0
 /**
  * @return \FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Countries');
     if ($this->exists()) {
         $fields->addFieldToTab('Root.Countries', new \GridField('Countries', 'Countries in zone', $this->Countries(), $config = new \GridFieldConfig_RelationEditor()));
         $config->removeComponentsByType("GridFieldAddNewButton");
         $config->removeComponentsByType("GridFieldEditButton");
         //GridFieldConfig_RelationEditor
     }
     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;
 }
 public function updateCMSFields(FieldList $fields)
 {
     // variables
     // 		$config = SiteConfig::current_site_config();
     $owner = $this->owner;
     //// Authorship
     $tab = 'Root.SEO.Authorship';
     //
     $authorsConfig = new GridFieldConfig_RelationEditor();
     $authorsConfig->removeComponentsByType('GridFieldAddNewButton');
     //
     $fields->addFieldsToTab($tab, array(GridField::create('Authors', 'Authors', $owner->Authors(), $authorsConfig)));
 }
 /**
  * @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;
 }
 /**
  * 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;
 }
 function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab('Root.SkitterSlides', $grid = new GridField('MaxSkitterSlides', 'Skitter slides', $this->owner->MaxSkitterSlides(), GridFieldConfig_RelationEditor::create(10)));
     if (class_exists("GridFieldSortableRows")) {
         $grid->getConfig()->addComponent(new GridFieldSortableRows('SortOrder'));
     }
 }
 /**
  * Returns array of fields to be added to Gallery Images Tab
  *
  * @return array
  */
 public function getFieldsForImagesTab()
 {
     $aFields[] = new HeaderField(_t('ResponsiveGalleryExtension.SOURCE_HEADER', 'Choose your desired image source'));
     $aFields[] = new OptionsetField("Source", _t('ResponsiveGalleryExtension.SOURCE_LABEL', 'Source'), array("sf" => _t('ResponsiveGalleryExtension.SOURCEFOLDER_LABEL', 'Source Folder'), "dl" => _t('ResponsiveGalleryExtension.DATALIST_LABEL', 'Data List')), "sf");
     switch ($this->owner->Source) {
         case "dl":
             $oGridFieldConfig = GridFieldConfig_RelationEditor::create()->addComponents(new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldBulkUpload('GalleryImage'), new GridFieldSortableRows('SortOrder'));
             $oGridFieldConfig->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $this->getUploadFolder())->setUfConfig('sequentialUploads', true);
             $aFields[] = new HeaderField(_t('ResponsiveGalleryExtension.DATALIST_HEADER', 'Create your image list'));
             $aFields[] = LiteralField::create("DataListInfo", '<div class="field"><p>' . _t('ResponsiveGalleryExtension.DATALIST_INFO', 'You can select images from files or upload images and add them to your customized image list. ' . 'Use "Target Folder" field to select a default target folder for your image uploads.') . '</p></div>');
             $aFields[] = new TreeDropdownField('UploadFolderID', _t('ResponsiveGalleryExtension.UPLOADFOLDER_LABEL', 'Target Folder'), 'Folder');
             $aFields[] = new GridField("GalleryImages", _t('ResponsiveGalleryExtension.IMAGES_LABEL', 'Images'), $this->getImages(), $oGridFieldConfig);
             break;
         case "sf":
             $iImageCount = $this->countImages();
             $aFields[] = new HeaderField(_t('ResponsiveGalleryExtension.SOURCEFOLDER_HEADER', 'Select source folder of gallery'));
             $aFields[] = new TreeDropdownField('SourceFolderID', _t('ResponsiveGalleryExtension.SOURCEFOLDER_LABEL', 'Source Folder'), 'Folder');
             if ($this->isSourcefolderSelected()) {
                 $aFields[] = LiteralField::create("ImageCountInfo", '<div class="field">' . '<p class="info-message">' . _t('ResponsiveGalleryExtension.IMAGECOUNTINFO', 'There are {imageCount} images in your selected folder.', 'The number of images in this gallery', array('imageCount' => $iImageCount)) . '</p></div>');
             } else {
                 $aFields[] = LiteralField::create("NoSelectedFolderInfo", '<div class="field">' . '<p><span class="info-message">' . _t('ResponsiveGalleryExtension.NOSELECTEDFOLDER_INFO', 'Please select a folder that contains the images to be displayed in this gallery.') . '</p></div>');
             }
             break;
         default:
             $aFields[] = LiteralField::create("SelectSourceInfo", '<div class="field">' . '<p><span class="info-message">' . _t('ResponsiveGalleryExtension.SELECTSOURCEINFO_HEADER', 'Please select your desired image source type in field above.') . '</span><br/>' . _t('ResponsiveGalleryExtension.SELECTSOURCE_INFO', 'Then click on save button below, to be able to configure this gallery.') . '</p></div>');
     }
     return $aFields;
 }
 function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab('Root.MaxCarouselItems', $grid = new GridField('MaxCarouselItems', 'Carousel items', $this->owner->sortedMaxCarouselItems(), GridFieldConfig_RelationEditor::create(10)));
     if (class_exists("GridFieldSortableRows")) {
         $grid->getConfig()->addComponent(new GridFieldSortableRows('SortOrder'));
     }
 }
Ejemplo n.º 13
0
 /**
  * @param string $sortField - Field to sort the blocks on. If this is set, it will also make the
  * 	blocks sortable in the CMS (requires SortableGridField module!)
  * @param array $allowedBlocks - a set of allowed class names, optionally mapped to titles
  * @param int $itemsPerPage - How many items per page should show up
  */
 public function __construct($sortField = null, $allowedBlocks = null, $itemsPerPage = null)
 {
     parent::__construct($itemsPerPage);
     // setup a bulk manager for block management
     $bulkManager = new GridFieldBulkManager();
     // remove the default actions
     $toRemove = array('bulkedit', 'bulkEdit', 'delete', 'unlink', 'unLink');
     $validActions = array_keys($bulkManager->getConfig('actions'));
     foreach ($toRemove as $key) {
         if (in_array($key, $validActions)) {
             $bulkManager->removeBulkAction($key);
         }
     }
     // add the actions in desired order
     $bulkManager->addBulkAction('publish', _t('PageBlock.PUBLISH', 'Publish'))->addBulkAction('unpublish', _t('PageBlock.UNPUBLISH', 'Unpublish'))->addBulkAction('bulkedit', _t('PageBlock.EDIT', 'Edit'), 'GridFieldBulkActionEditHandler', array('icon' => 'pencil'))->addBulkAction('versionedunlink', _t('PageBlock.UNLINK', 'Unlink'), 'GridFieldBulkActionVersionedUnlinkHandler', array('icon' => 'chain--minus'))->addBulkAction('versioneddelete', _t('PageBlock.DELETE', 'Delete'), 'GridFieldBulkActionVersionedDeleteHandler', array('isDestructive' => true, 'icon' => 'decline'));
     if ($sortField && class_exists('GridFieldOrderableRows')) {
         $this->addComponent(new GridFieldOrderableRows($sortField));
     }
     // remove the delete action, since unlinking is not required
     $this->removeComponent($this->getComponentByType('GridFieldDeleteAction'));
     // remove the search field since it doesn't make sense (cannot add existing, unless "stealing" from another page)
     $this->removeComponentsByType('GridFieldAddExistingAutocompleter');
     $this->addComponent(new GridFieldAddExistingSearchButton('buttons-before-right'));
     $this->addComponent(new GridFieldAddNewMultiClass(), 'GridFieldToolbarHeader');
     $this->addComponent($bulkManager);
     $this->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Title' => _t('Block.TITLE', 'Title'), 'i18n_singular_name' => _t('Block.TYPE', 'Type'), 'PublishedStatus' => _t('Block.STATUS', 'Status')));
     $this->setAllowedBlocks($allowedBlocks);
 }
Ejemplo n.º 14
0
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // this is what shows int he tab with the table in it
     /*
     $tablefield = new HasOneComplexTableField(
     	$this,
     	'FlickrSetForPage',
     	'FlickrSet',
     	array(
     		'Title' => 'Title'
     	),
     	'getCMSFields_forPopup'
     );
     
     $tablefield->setParentClass('FLickrSetPage');
     */
     $gridConfig = GridFieldConfig_RelationEditor::create()->addComponent(new GridFieldSortableRows('SortOrder'));
     $gridConfig->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('URL', 'Title', 'Description'));
     //$gridField = new GridField( "Links", "List of Links:", $this->Links()->sort( 'SortOrder' ), $gridConfig );
     //$fields->addFieldToTab( "Root.Links", $gridField );
     $fields->addFieldToTab('Root.Main', new HTMLEditorField('Description', 'Description'), 'Content');
     //fields->addFieldToTab( 'Root.FlickrSet', $tablefield );
     //$dropdown = new DropdownField('FlickrSetFolderID', 'Flickr Set Folder', FlickrSetFolder::get()->map('ID','Title');
     /*
     $dropdown->setEmptyString('-- Please Select One --');
     $fields->addFieldToTab('Root.ParentGallery',
     	$dropdown
     );
     */
     return $fields;
 }
Ejemplo n.º 15
0
 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;
 }
 /**
  * CMS Fields
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     if (!Permission::check("VIEW_SECTIONS")) {
         return $fields;
     }
     $SectionGrid = GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->addComponent(new GridFieldAddNewMultiClass())->addComponent(new GridFieldOrderableRows());
     $SectionGrid->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('AdminTitle', 'MenuTitle'))->setResultsFormat('$AdminTitle - $Type');
     $AvailableTypes = $this->AvailableSectionTypes();
     foreach ($AvailableTypes as $key => $value) {
         if ($value['selectable_option'] && !$value['limit_reached']) {
             $AvailableTypes[$key] = $value['type'];
         }
     }
     $SectionGrid->getComponentByType('GridFieldAddNewMultiClass')->setClasses($AvailableTypes);
     // Limit total sections
     $LimitSectionTotal = Config::inst()->get($this->owner->ClassName, 'LimitSectionTotal');
     if (isset($LimitSectionTotal) && $this->owner->Sections()->Count() >= $LimitSectionTotal) {
         // remove the buttons if we don't want to allow more records to be added/created
         $SectionGrid->removeComponentsByType('GridFieldAddNewButton');
         $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
         $SectionGrid->removeComponentsByType('GridFieldAddNewMultiClass');
     }
     if (!Permission::check("LINK_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
     }
     if (!Permission::check("REORDER_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldOrderableRows');
     }
     if (!Permission::check("UNLINK_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldDeleteAction');
     }
     $fields->addFieldToTab('Root.Section', GridField::create('Sections', 'Current Section(s)', $this->owner->Sections(), $SectionGrid));
     $fields->addFieldToTab('Root.Preview', UploadField::create('PreviewImage', 'Preview image')->setFolderName('Preview'));
     return $fields;
 }
Ejemplo n.º 17
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('PageBuilder');
     /* =========================================
        * Images
        =========================================*/
     $fields->addFieldToTab('Root.Main', new UploadField('Image'), 'Content');
     /* =========================================
        * Menu Item Details
        =========================================*/
     $fields->addFieldToTab('Root.Main', $price = new CurrencyField('Price'), 'Content');
     $price->setRightTitle('To add extra price options e.g Small, Large please add a variation under the "Variations" tab above');
     $fields->addFieldToTab('Root.Main', $ingredients = new HtmlEditorField('Ingredients'), 'Metadata');
     $ingredients->setRows(15);
     /* =========================================
        * Variations
        =========================================*/
     $config = GridFieldConfig_RelationEditor::create(10);
     $config->addComponent(new GridFieldSortableRows('SortOrder'))->addComponent(new GridFieldDeleteAction());
     $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Title' => 'Title', 'Price' => 'Price'));
     $gridField = new GridField('Variations', 'Variations', $this->owner->MenuVariations(), $config);
     $fields->addFieldToTab('Root.Variations', $gridField);
     return $fields;
 }
Ejemplo n.º 18
0
 public function getCMSFields()
 {
     $f = parent::getCMSFields();
     $homes = Home::get();
     $f->addFieldToTab('Root.Homes', new GridField('HomeGrid', 'Homes', $homes, GridFieldConfig_RelationEditor::create()));
     return $f;
 }
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     // Loop over each WidgetArea
     $has_one = $this->owner->has_one();
     foreach ($has_one as $name => $class) {
         if ($class == 'WidgetArea') {
             /*
              * Widget gridfield 
              */
             $adder = new GridFieldAddNewMultiClass();
             // Allowed classes
             $allowed = $this->owner->config()->get("allowed_widgets");
             if (is_array($allowed)) {
                 // Filter classes for creating new ones
                 $adder->setClasses($allowed);
             }
             $config = GridFieldConfig_RelationEditor::create()->removeComponentsByType("GridFieldAddNewButton")->addComponent($adder)->addComponent(new GridFieldOrderableRows('WidgetAreaSort'));
             // It's not possible to add existing through GridFieldAddExistingSearchButton since
             // it display by default $Title in its template and we want to search by $WidgetName
             $config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('WidgetName'))->setResultsFormat('$WidgetName');
             // WidgetArea's Widget GridField
             $gridField = GridField::create($name, $name, $this->owner->{$name}()->SortedWidgets(false))->setConfig($config);
             $fields->addFieldToTab("Root.{$name}", $gridField);
         }
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->ID) {
         // Relation handler for Blocks
         $SConfig = GridFieldConfig_RelationEditor::create(25);
         $SConfig->addComponent(new GridFieldOrderableRows('SortOrder'));
         $SConfig->addComponent(new GridFieldDeleteAction());
         // If the copy button module is installed, add copy as option
         if (class_exists('GridFieldCopyButton')) {
             $SConfig->addComponent(new GridFieldCopyButton(), 'GridFieldDeleteAction');
         }
         $gridField = new GridField("Blocks", "Content blocks", $this->owner->Blocks(), $SConfig);
         $classes = array_values(ClassInfo::subclassesFor($gridField->getModelClass()));
         if (count($classes) > 1 && class_exists('GridFieldAddNewMultiClass')) {
             $SConfig->removeComponentsByType('GridFieldAddNewButton');
             $SConfig->addComponent(new GridFieldAddNewMultiClass());
         }
         if (self::$create_block_tab) {
             $fields->addFieldToTab("Root.Blocks", $gridField);
         } else {
             // Downsize the content field
             $fields->removeByName('Content');
             $fields->addFieldToTab('Root.Main', HTMLEditorField::create('Content')->setRows(self::$contentarea_rows), 'Metadata');
             $fields->addFieldToTab("Root.Main", $gridField, 'Metadata');
         }
     }
     return $fields;
 }
 public function getCMSFields()
 {
     Requirements::javascript('google-store-finder/javascript/store-creator.js');
     $fields = parent::getCMSFields();
     // Create a gridfield to hold the student relationship
     $latField = new NumericField('StartLat', 'Starting Latitude', 40);
     $longField = new NumericField('StartLong', 'Starting Longitude', -100);
     $zoomField = new NumericField('StartZoom', 'Starting Zoom', 2);
     $geoLocatedZoomField = new NumericField('GeolocatedZoom', "Geolocated Zoom", 8);
     $mapType = new DropdownField('MapType', 'Map Type', array("RoadMap" => "Road Map", "Satellite" => "Satellite"), "RoadMap");
     // Create a tab named "Students" and add our field to it
     $fields->addFieldToTab('Root.Map', new LiteralField("geolocation-explanation", '<p>This Module will attempt to detect users location if their device supports it.  if not, please enter the starting latitude and longitude. (Default values center North and South America in the map).</p>'));
     $fields->addFieldToTab('Root.Map', $latField);
     $fields->addFieldToTab('Root.Map', $longField);
     $fields->addFieldToTab('Root.Map', $zoomField);
     $fields->addFieldToTab('Root.Map', $geoLocatedZoomField);
     $fields->addFieldToTab('Root.Map', $mapType);
     $markerClassObject = Injector::inst()->create(self::$MarkerClass);
     // Create a default configuration for the new GridField, allowing record editing
     $config = GridFieldConfig_RelationEditor::create();
     // Set the names and data for our gridfield columns
     $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Name' => 'Name'));
     // Create a gridfield to hold the student relationship
     $locationField = new GridField(self::$MarkerClass, DataObject::get_static(self::$MarkerClass, "singular_name"), DataObject::get(self::$MarkerClass), $config);
     // Create a tab named "Students" and add our field to it
     $fields->addFieldToTab('Root.Locations', $locationField);
     return $fields;
 }
Ejemplo n.º 22
0
 function getCMSFields()
 {
     $_REQUEST["CompanyId"] = $this->ID;
     $large_logo = new UploadField('BigLogo', 'Large Company Logo');
     $large_logo->setFolderName('companies/main_logo');
     $large_logo->setAllowedFileCategories('image');
     $small_logo = new UploadField('Logo', 'Small Company Logo');
     $small_logo->setAllowedFileCategories('image');
     //logo validation rules
     $large_logo_validator = new Upload_Image_Validator();
     $large_logo_validator->setAllowedExtensions(array('jpg', 'png', 'jpeg'));
     $large_logo_validator->setAllowedMaxImageWidth(500);
     $large_logo->setValidator($large_logo_validator);
     $small_logo_validator = new Upload_Image_Validator();
     $small_logo_validator->setAllowedExtensions(array('jpg', 'png', 'jpeg'));
     $small_logo_validator->setAllowedMaxImageWidth(200);
     $small_logo->setValidator($small_logo_validator);
     $fields = new FieldList(new TabSet($name = "Root", new Tab($title = 'Company', new HeaderField("Company Data"), new TextField('Name', 'Company Name'), new TextField('URLSegment', 'Unique page name for this company profile (ie: company-name)'), new TextField('URL', 'Company Web Address (URL)'), $level = new DropDownField('MemberLevel', 'OpenStack Foundation Member Level', $this->dbObject('MemberLevel')->enumValues()), new ColorField("Color", "Company Color"), new CheckboxField('DisplayOnSite', 'List this company on openstack.org'), new CheckboxField('Featured', 'Include this company in featured companies area'), new LiteralField('Break', '<hr/>'), $this->canEditLogo() ? $large_logo : new LiteralField('Space', '<br/>'), $this->canEditLogo() ? $small_logo : new LiteralField('Space', '<br/>'), new TextField('Industry', 'Industry (<4 Words)'), new HtmlEditorField('Description', 'Company Description'), new HtmlEditorField('Contributions', 'How you are contributing to OpenStack (<150 words)'), new HtmlEditorField('Products', 'Products/Services Related to OpenStack (<100 words)'), new HtmlEditorField('Overview', 'Company Overview'), new TextField('CommitmentAuthor', 'Commitment Author (Optional)'), new HtmlEditorField('Commitment', "OpenStack Commitment"), new LiteralField('Break', '<hr/>'), new TextField('ContactEmail', 'Best Contact email address (optional)'))));
     $level->setEmptyString('-- Choose One --');
     if ($this->ID > 0) {
         $admin_list = $this->Administrators()->sort('ID');
         $query = $admin_list->dataQuery();
         $query->groupby('MemberID');
         $admin_list = $admin_list->setDataQuery($query);
         $config = GridFieldConfig_RelationEditor::create();
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('FirstName' => 'First Name', 'Surname' => 'Last Name', 'Email' => 'Email', 'DDLAdminSecurityGroup' => 'Security Group'));
         $admins = new GridField('Administrators', 'Company Administrators', $admin_list, $config);
         $contracts = new GridField("Contracts", "Contracts", $this->Contracts(), GridFieldConfig_RecordEditor::create(10));
         $fields->addFieldsToTab('Root.Administrators', array(new HeaderField("Companies Administrators"), $admins));
         $fields->addFieldsToTab('Root.Contracts', array(new HeaderField("Companies Contracts"), $contracts));
     }
     return $fields;
 }
 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldsToTab('Root.Related', array($grid = GridField::create("RelatedProductsRelation", "Related Products", $this->owner->RelatedProductsRelation()->sort('Order', 'ASC'), GridFieldConfig_RelationEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldEditButton")->addComponent(new GridFieldOrderableRows('Order'))->addComponent(new GridFieldEditableColumns()))));
     $grid->getConfig()->getComponentByType('GridFieldEditableColumns')->setDisplayFields(array('RelatedTitle' => function ($record, $column, $grid) {
         return new TextField($column);
     }));
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $pictures_per_page = $this->config()->get('picturesPerPage');
     $conf = GridFieldConfig_RelationEditor::create($pictures_per_page);
     $conf->getComponentByType('GridFieldPaginator')->setItemsPerPage($pictures_per_page);
     $conf->addComponent(new GridFieldBulkUpload());
     $conf->addComponent(new GridFieldSortableRows('Sort'));
     $imageFolder = $this->config()->get('imageFolder');
     if ($this->config()->get('usePageURLSegmentAsSubfolder')) {
         $imageFolder = preg_replace("/^(.+?)\\/*\$/", '$1/', $imageFolder) . $this->URLSegment;
     }
     $conf->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $imageFolder);
     $gridField = new GridField('Pictures', 'Pictures', $this->SortedPictures(), $conf);
     $dataColumns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $imageFieldMapping = $this->config()->get('galleryImageListFieldMapping');
     foreach ($imageFieldMapping as $key => $value) {
         $imageFieldMapping[$key] = _t('GalleryPicture.' . $key, $value);
     }
     $dataColumns->setDisplayFields($imageFieldMapping);
     if ($this->ID > 0) {
         $fields->addFieldsToTab('Root.' . _t('GalleryPage.Photos', 'Photos'), array($gridField));
     }
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $sortable = singleton('CleanTeaser')->hasExtension('SortableDataExtension');
     $config = GridFieldConfig_RelationEditor::create();
     $config->addComponent($gridFieldForm = new GridFieldDetailForm());
     $dataFields = array();
     if (singleton('CleanTeaser')->hasExtension('CMSPublishableDataExtension')) {
         $dataFields['PublishIndicator'] = 'Published';
     }
     $dataFields = array_merge($dataFields, array('Thumbnail' => 'Thumbnail', 'Title' => 'Title', 'CleanDescription' => 'Description'));
     $config->getComponentByType('GridFieldDataColumns')->setDisplayFields($dataFields);
     $gridFieldForm->setTemplate('CMSGridFieldPopupForms');
     if ($sortable) {
         $config->addComponent(new GridFieldSortableRows('SortOrder'));
     }
     if (ClassInfo::exists('GridFieldBulkUpload')) {
         $iu = new GridFieldBulkUpload('ImageID');
         if (singleton('CleanTeaser')->hasExtension('ControlledFolderDataExtension')) {
             $iu->setUfConfig('folderName', singleton('CleanTeaser')->getUploadFolder());
         } else {
             $iu->setUfConfig('folderName', CleanTeaser::$upload_folder);
         }
         $config->addComponent($iu);
     }
     if ($sortable) {
         $data = $this->owner->CleanTeasers("ClassName = 'CleanTeaser'")->sort('SortOrder');
     } else {
         $data = $this->owner->CleanTeasers("ClassName = 'CleanTeaser'");
     }
     // $config->removeComponentsByType('GridFieldAddNewButton');
     // if (ClassInfo::exists('GridFieldBulkUpload')) {
     // 	$config->addComponent(new GridFieldAddNewMultiClass());
     // }
     $fields->addFieldToTab("Root.Teasers", GridField::create('CleanTeasers', 'CleanTeaser', $data, $config));
 }
Ejemplo n.º 26
0
 public function getCMSFields()
 {
     $f = parent::getCMSFields();
     $member = TeamMember::get();
     $f->addFieldToTab('Root.Team', new GridField('TeamGrid', 'Team', $member, GridFieldConfig_RelationEditor::create()));
     return $f;
 }
 /**
  * A simple Gridfield factory
  * @param  string $model
  * @param  string $relationname
  * @param  DataObject $reference
  * @return GridField
  */
 public static function create_gridfield_for($model, $relationname, $reference)
 {
     if ($relationname != null && ClassInfo::exists($model)) {
         $config = GridFieldConfig_RelationEditor::create();
         $config->addComponent($gridFieldForm = new GridFieldDetailForm());
         if ($items = $reference->{$relationname}()) {
             if (is_a($items, 'ManyManyList') && ClassInfo::exists('GridFieldManyRelationHandler')) {
                 $config->addComponent(new GridFieldManyRelationHandler(), 'GridFieldPaginator');
             } else {
                 $sortable = singleton($model)->hasExtension('SortableDataExtension');
                 if ($sortable) {
                     $config->addComponent(new GridFieldSortableRows('SortOrder'));
                 }
             }
             $gridfield = GridField::create($relationname, $model, $items, $config);
             $datacolumns = $gridfield->getConfig()->getComponentByType('GridFieldDataColumns');
             $cfields = singleton($model)->summaryFields();
             if (singleton($model)->hasExtension('CMSPublishableDataExtension') && !isset($cfields['PublishStatus'])) {
                 $cfields = array('PublishStatus' => 'PublishStatus') + $cfields;
             }
             $datacolumns->setDisplayFields($cfields);
             return $gridfield;
         } else {
             throw new InvalidArgumentException("Couldn't find relation.");
         }
     } else {
         throw new InvalidArgumentException("Couldn't create GridField because wrong parameters passed to the factory.");
     }
 }
Ejemplo n.º 28
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertBefore(TextareaField::create('Intro', 'Intro'), 'Content');
     $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Intro");
     $fields->insertBefore($image = UploadField::create('SplashImage', 'Splash Image'), 'Content');
     $image->setFolderName('Uploads/Splash-Images');
     if ($this->ClassName === "Page" || $this->ClassName === "HomePage") {
         $fields->insertAfter(HTMLEditorField::create('ExtraContent'), 'Content');
         $gridField = new GridField('FeatureItems', 'FeatureItems', $this->FeatureItems()->sort(array('Sort' => 'ASC', 'Archived' => 'ASC')), $config = GridFieldConfig_RelationEditor::create());
         $gridField->setModelClass('FeatureItem');
         $fields->addFieldToTab('Root.Features', $gridField);
         $config->addComponent(new GridFieldOrderableRows());
     } else {
         if ($this->ClassName === "CalendarPage") {
             $content = $fields->dataFieldByName('Content');
             $content->addExtraClass('no-pagebreak');
             $events = Event::get()->sort(array('StartDateTime' => 'Desc'))->filterByCallback(function ($record) {
                 return !$record->getIsPastEvent();
             });
             $gridField = new GridField('Event', 'Upcoming Events', $events, $config = GridFieldConfig_RecordEditor::create());
             $gridField->setModelClass('Event');
             $dataColumns = $config->getComponentByType('GridFieldDataColumns');
             $dataColumns->setDisplayFields(array('Title' => 'Title', 'StartDateTime' => 'Date and Time', 'DatesAndTimeframe' => 'Presentation String'));
             $fields->addFieldToTab('Root.UpcomingEvents', $gridField);
         }
     }
     return $fields;
 }
Ejemplo n.º 29
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         // Summit Images
         $summitImageField = singleton('SummitImage')->getCMSFields();
         $config = GridFieldConfig_RelationEditor::create();
         $config->getComponentByType('GridFieldDetailForm')->setFields($summitImageField);
         $gridField = new GridField('SummitImage', 'SummitImage', SummitImage::get(), $config);
         $fields->addFieldToTab('Root.SummitPageImages', $gridField);
         // Summit Image has_one selector
         $dropdown = DropdownField::create('SummitImageID', 'Please choose an image for this page', SummitImage::get()->map("ID", "Title", "Please Select"))->setEmptyString('(None)');
         $fields->addFieldToTab('Root.Main', $dropdown);
         $fields->addFieldsToTab('Root.Main', $ddl_summit = new DropdownField('SummitID', 'Summit', Summit::get()->map('ID', 'Name')));
         $ddl_summit->setEmptyString('(None)');
     }
     $fields->addFieldsToTab('Root.Main', new TextField('HeroCSSClass', 'Hero CSS Class'));
     //Google Conversion Tracking params
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionId", "Conversion Id", "994798451"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionLanguage", "Conversion Language", "en"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionFormat", "Conversion Format", "3"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new ColorField("GAConversionColor", "Conversion Color", "ffffff"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionLabel", "Conversion Label", "IuM5CK3OzQYQ89at2gM"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionValue", "Conversion Value", "0"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new CheckboxField("GARemarketingOnly", "Remarketing Only"));
     //Facebook Conversion Params
     $fields->addFieldToTab("Root.FacebookConversionTracking", new TextField("FBPixelId", "Pixel Id", "6013247449963"));
     $fields->addFieldToTab("Root.FacebookConversionTracking", new TextField("FBValue", "Value", "0.00"));
     $fields->addFieldToTab("Root.FacebookConversionTracking", new TextField("FBCurrency", "Currency", "USD"));
     //Twitter
     $fields->addFieldToTab("Root.TwitterConversionTracking", new TextField("TwitterPixelId", "Pixel Id", "l5lav"));
     return $fields;
 }
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('ProcessInfo');
        $fields->removeByName('ProcessStages');
        $processParent = Process::get();
        if ($processParent) {
            $fields->insertAfter(new DropdownField('ParentID', 'Belongs to this Process', $processParent->map('ID', 'Title')), 'Title');
        }
        $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField(new GridField('ProcessInfo', 'Information for this stage', $this->ProcessInfo(), GridFieldConfig_RelationEditor::create())));
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
			<span class="step-label">
				<span class="flyout">1.1</span><span class="arrow"></span>
				<span class="title">Stop stage details</span>
			</span>
		</h3>'), 'Title');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
			<span class="step-label">
				<span class="flyout">1.2</span><span class="arrow"></span>
				<span class="title">Final information</span>
			</span>
		</h3>'), 'ProcessInfo');
        return $fields;
    }