/**
  * Contructor
  * @param type $controller
  * @param type $name
  */
 function __construct($controller, $name)
 {
     //Administering calendars
     if (CalendarConfig::subpackage_enabled('calendars')) {
         //Configuration for calendar grid field
         $gridCalendarConfig = GridFieldConfig_RecordEditor::create();
         $gridCalendarConfig->removeComponentsByType('GridFieldDataColumns');
         $gridCalendarConfig->addComponent($dataColumns = new GridFieldDataColumns(), 'GridFieldEditButton');
         $c = singleton('Calendar');
         $summaryFields = $c->summaryFields();
         //$summaryFields = array(
         //	'Title' => 'Title',
         //	//'SubscriptionOptIn' => 'Opt In',
         //	//'Shaded' => 'Shaded'
         //);
         $s = CalendarConfig::subpackage_settings('calendars');
         //show shading info in the gridfield
         if ($s['shading']) {
             $summaryFields['Shaded'] = 'Shaded';
         }
         $dataColumns->setDisplayFields($summaryFields);
         //settings for the case that colors are enabled
         if ($s['colors']) {
             $dataColumns->setFieldFormatting(array("Title" => '<div style=\\"height:20px;width:20px;display:inline-block;vertical-align:middle;margin-right:6px;background:$Color\\"></div> $Title'));
         }
         $GridFieldCalendars = new GridField('Calendars', '', PublicCalendar::get(), $gridCalendarConfig);
         $fields = new FieldList($GridFieldCalendars);
         $actions = new FieldList();
         $this->addExtraClass('CalendarsForm');
         parent::__construct($controller, $name, $fields, $actions);
     }
 }
 public function __construct($controller, $name, $show_actions = true)
 {
     $TempBasketID = Store_BasketController::get_temp_basket_id();
     $order_id = DB::Query("SELECT id FROM `order` WHERE (`TempBasketID`='" . $TempBasketID . "')")->value();
     /* Basket GridField */
     $config = new GridFieldConfig();
     $dataColumns = new GridFieldDataColumns();
     $dataColumns->setDisplayFields(array('getPhoto' => "Photo", 'Title' => 'Product', 'Price' => 'Item Price', 'Quantity' => 'Quantity', 'productPrice' => 'Total Price', 'getfriendlyTaxCalculation' => 'Tax Inc/Exc', 'TaxClassName' => 'Tax'));
     $config->addComponent($dataColumns);
     $config->addComponent(new GridFieldTitleHeader());
     $basket = GridField::create("BasketItems", "", DataObject::get("Order_Items", "(OrderID='" . $order_id . "')"), $config);
     /* Basket Subtotal */
     $subtotal = new Order();
     $subtotal = $subtotal->calculateSubTotal($order_id);
     $subtotal = ReadonlyField::create("SubTotal", "Basket Total (" . Product::getDefaultCurrency() . ")", $subtotal);
     /* Fields */
     $fields = FieldList::create($basket, $subtotal, ReadonlyField::create("Tax", "Tax", "Calculated on the Order Summary page."));
     /* Actions */
     $actions = FieldList::create(CompositeField::create(FormAction::create('continueshopping', 'Continue Shopping'), FormAction::create('placeorder', 'Place Order')));
     /* Required Fields */
     $required = new RequiredFields(array());
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $show_actions ? $actions : FieldList::create(), $required);
 }
 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;
 }
    public function __construct($canAdd = true, $canEdit = true, $canDelete = true, $editableRows = false, $aboveOrBelow = false)
    {
        parent::__construct();
        $this->blockManager = Injector::inst()->get('BlockManager');
        $controllerClass = Controller::curr()->class;
        // Get available Areas (for page) or all in case of ModelAdmin
        if ($controllerClass == 'CMSPageEditController') {
            $currentPage = Controller::curr()->currentPage();
            $areasFieldSource = $this->blockManager->getAreasForPageType($currentPage->ClassName);
        } else {
            $areasFieldSource = $this->blockManager->getAreasForTheme();
        }
        // EditableColumns only makes sense on Saveable parenst (eg Page), or inline changes won't be saved
        if ($editableRows) {
            $this->addComponent($editable = new GridFieldEditableColumns());
            $displayfields = array('TypeForGridfield' => array('title' => _t('Block.BlockType', 'Block Type'), 'field' => 'LiteralField'), 'Title' => array('title' => _t('Block.Title', 'Title'), 'field' => 'ReadonlyField'), 'BlockArea' => array('title' => _t('Block.BlockArea', 'Block Area') . '
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'callback' => function () use($areasFieldSource) {
                return DropdownField::create('BlockArea', 'Block Area', $areasFieldSource)->setHasEmptyDefault(true);
            }), 'isPublishedNice' => array('title' => _t('Block.IsPublishedField', 'Published'), 'field' => 'ReadonlyField'), 'UsageListAsString' => array('title' => _t('Block.UsageListAsString', 'Used on'), 'field' => 'LiteralField'));
            if ($aboveOrBelow) {
                $displayfields['AboveOrBelow'] = array('title' => _t('GridFieldConfigBlockManager.AboveOrBelow', 'Above or Below'), 'callback' => function () {
                    return DropdownField::create('AboveOrBelow', _t('GridFieldConfigBlockManager.AboveOrBelow', 'Above or Below'), BlockSet::config()->get('above_or_below_options'));
                });
            }
            $editable->setDisplayFields($displayfields);
        } else {
            $this->addComponent($dcols = new GridFieldDataColumns());
            $displayfields = array('singular_name' => _t('Block.BlockType', 'Block Type'), 'Title' => _t('Block.Title', 'Title'), 'BlockArea' => _t('Block.BlockArea', 'Block Area'), 'isPublishedNice' => _t('Block.IsPublishedField', 'Published'), 'UsageListAsString' => _t('Block.UsageListAsString', 'Used on'));
            $dcols->setDisplayFields($displayfields);
            $dcols->setFieldCasting(array('UsageListAsString' => 'HTMLText->Raw'));
        }
        $this->addComponent(new GridFieldButtonRow('before'));
        $this->addComponent(new GridFieldToolbarHeader());
        $this->addComponent(new GridFieldDetailForm());
        $this->addComponent($sort = new GridFieldSortableHeader());
        $this->addComponent($filter = new GridFieldFilterHeader());
        $this->addComponent(new GridFieldDetailForm());
        if ($controllerClass == 'BlockAdmin' && class_exists('GridFieldCopyButton')) {
            $this->addComponent(new GridFieldCopyButton());
        }
        $filter->setThrowExceptionOnBadDataType(false);
        $sort->setThrowExceptionOnBadDataType(false);
        if ($canAdd) {
            $multiClass = new GridFieldAddNewMultiClass();
            $classes = $this->blockManager->getBlockClasses();
            $multiClass->setClasses($classes);
            $this->addComponent($multiClass);
            //$this->addComponent(new GridFieldAddNewButton());
        }
        if ($canEdit) {
            $this->addComponent(new GridFieldEditButton());
        }
        if ($canDelete) {
            $this->addComponent(new GridFieldDeleteAction(true));
        }
        return $this;
    }
 public function updateCMSFields(FieldList $fields)
 {
     /** @var GridFieldConfig $gridConfig */
     $gridConfig = GridFieldConfig::create();
     $gridConfig->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldAddNewButton('buttons-before-left'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldSortableHeader())->addComponent(new GridFieldSortableRows('SortOrder'))->addComponent($dataColumns = new GridFieldDataColumns())->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldDetailForm());
     $dataColumns->setDisplayFields(['Title' => 'Author', 'Testimonial.Summary' => 'Testimonial Preview']);
     $GridField = GridField::create('Testimonials', 'Testimonials', $this->owner->Testimonials(), $gridConfig);
     $fields->addFieldToTab('Root.Testimonials', $GridField);
     return $fields;
 }
 function getGridFieldSiteTreeField($name, $title = null, SS_List $dataList = null)
 {
     $gf = GridField::create($name, $title, $dataList, $config = GridFieldConfig::create());
     $config->addComponents(new GridFieldSortableHeader(), $columns = new GridFieldDataColumns(), new GridFieldPaginator(15));
     $fields = array('getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'), 'singular_name' => _t('SiteTree.PAGETYPE'), 'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'));
     $columns->setDisplayFields($fields);
     $columns->setFieldCasting(array('Created' => 'Datetime->Ago', 'LastEdited' => 'Datetime->Ago', 'getTreeTitle' => 'HTMLText'));
     $config->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('getTreeTitle' => 'Title'));
     $controller = $this;
     $columns->setFieldFormatting(array('getTreeTitle' => function ($value, &$item) use($controller) {
         return '<a class="action-detail" href="' . singleton('CMSPageEditController')->Link('show') . '/' . $item->ID . '">' . $item->TreeTitle . '</a>';
     }));
     return $gf;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // NewsGrid
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewSiteTreeItemButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldFilterHeader(), $dataColumns = new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditSiteTreeItemButton());
     $dataColumns->setDisplayFields(array('Title' => 'Title', 'URLSegment' => 'URL', 'formattedPublishDate' => 'Publish date', 'getStatus' => 'Status', 'LastEdited' => 'Changed'));
     // include both live and stage versions of pages
     $pages = $this->AllChildrenIncludingDeleted();
     // use gridfield as normal;
     $gridField = new GridField("Subpages", "Manage Blogposts", $pages, $gridFieldConfig);
     $gridField->setModelClass(self::$default_child);
     //$gridField->setModelClass("GridFieldPage"); // prevents "GridField doesn't have a modelClassName" error
     $fields->addFieldToTab("Root.BlogPosts", $gridField);
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     /** @var GridFieldConfig $gridConfig */
     $gridConfig = GridFieldConfig::create();
     $gridConfig->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldAddNewButton('buttons-before-left'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldSortableHeader())->addComponent(new GridFieldSortableRows('SortOrder'))->addComponent($dataColumns = new GridFieldDataColumns())->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldDetailForm());
     $dataColumns->setDisplayFields(['Title' => 'Question', 'Answer.Summary' => 'Answer Preview']);
     /** @var TabSet $rootTab */
     //We need to repush Metadata to ensure it is the last tab
     $rootTab = $fields->fieldByName('Root');
     $rootTab->push(Tab::create('FaqSegments'));
     if ($rootTab->fieldByName('Metadata')) {
         $metaChildren = $rootTab->fieldByName('Metadata')->getChildren();
         $rootTab->removeByName('Metadata');
         $rootTab->push(Tab::create('Metadata')->setChildren($metaChildren));
     }
     $GridField = GridField::create('FaqSegments', 'FAQs', $this->owner->Faqs(), $gridConfig);
     $fields->addFieldToTab('Root.FaqSegments', $GridField);
     return $fields;
 }
 public static function eventConfig()
 {
     $gridEventConfig = GridFieldConfig_RecordEditor::create();
     //Custom detail form
     $gridEventConfig->removeComponentsByType('GridFieldDetailForm');
     $gridEventConfig->addComponent(new CalendarEventGridFieldDetailForm());
     //Custom columns
     $gridEventConfig->removeComponentsByType('GridFieldDataColumns');
     $dataColumns = new GridFieldDataColumns();
     $summaryFields = Event::$summary_fields;
     //Show the page if the event is connected to an event page
     if (CalendarConfig::subpackage_setting('pagetypes', 'enable_eventpage')) {
         $summaryFields['getEventPageCalendarTitle'] = 'Page';
     }
     //event classname - we might not always want it here - but here it is - for now
     $summaryFields['i18n_singular_name'] = 'Type';
     $dataColumns->setDisplayFields($summaryFields);
     $gridEventConfig->addComponent($dataColumns, 'GridFieldEditButton');
     return $gridEventConfig;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $PageTab = Config::inst()->get($this->owner->className, 'subpage_tab');
     // GridFieldPage
     if (Config::inst()->get($this->owner->className, 'add_default_gridfield')) {
         $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewSiteTreeItemButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldFilterHeader(), $dataColumns = new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditSiteTreeItemButton());
         // Orderable is optional, as often pages may be sorted by other means
         if (Config::inst()->get($this->owner->className, 'apply_sortable')) {
             // OrderableRows will auto-deactivate when users Sort via SortableHeader
             $gridFieldConfig->addComponent(new GridFieldOrderableRows());
             $fields->addFieldToTab($PageTab, new LiteralField('SortWarning', "<p class=\"message warning\" style=\"display: inline-block;\">" . _t("GridFieldPages.PUBLISHAFTERSORTWARNING", "After reordering, the new sort order will get active after one of the pages gets (re)published") . "</p>"));
         }
         $dataColumns->setDisplayFields(array('Title' => 'Title', 'URLSegment' => 'URL', 'getStatus' => 'Status'));
         // include both live and stage versions of pages
         // use gridfield as normal
         $gridField = new GridField("Subpages", Config::inst()->get($this->owner->className, 'gridfield_title'), $this->AllChildrenIncludingDeleted(), $gridFieldConfig);
         $gridField->setModelClass($this->defaultChild());
         $fields->addFieldToTab($PageTab, $gridField);
     }
     return $fields;
 }
    public function __construct($canAdd = true, $canEdit = true, $canDelete = true, $editableRows = false, $aboveOrBelow = false)
    {
        parent::__construct();
        $this->blockManager = Injector::inst()->get('BlockManager');
        $controllerClass = Controller::curr()->class;
        // Get available Areas (for page) or all in case of ModelAdmin
        if ($controllerClass == 'CMSPageEditController') {
            $currentPage = Controller::curr()->currentPage();
            $areasFieldSource = $this->blockManager->getAreasForPageType($currentPage->ClassName);
        } else {
            $areasFieldSource = $this->blockManager->getAreasForTheme();
        }
        // EDIT
        $blockTypeArray = $this->blockManager->getBlockClasses();
        // /EDIT
        // EditableColumns only makes sense on Saveable parenst (eg Page), or inline changes won't be saved
        if ($editableRows) {
            // set project-dir in cookie to be accessible as fallback from js
            Cookie::set('js-project-dir', project(), 90, null, null, false, false);
            $this->addComponent($editable = new GridFieldEditableColumns());
            $displayfields = array('ClassName' => array('title' => _t('Block.BlockType', 'Block Type') . '
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'callback' => function () use($blockTypeArray) {
                return DropdownField::create('ClassName', 'Block Type', $blockTypeArray)->addExtraClass('select2blocktype')->setAttribute('data-project-dir', project());
            }), 'Title' => array('title' => _t('Block.TitleName', 'Block Name'), 'field' => 'TextField'), 'BlockArea' => array('title' => _t('Block.BlockArea', 'Block Area') . '
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'callback' => function () use($areasFieldSource) {
                return DropdownField::create('BlockArea', 'Block Area', $areasFieldSource)->setHasEmptyDefault(true);
            }), 'isPublishedNice' => array('title' => _t('Block.IsPublishedField', 'Published'), 'field' => 'ReadonlyField'), 'UsageListAsString' => array('title' => _t('Block.UsageListAsString', 'Used on'), 'field' => 'ReadonlyField'));
            if ($aboveOrBelow) {
                $displayfields['AboveOrBelow'] = array('title' => _t('GridFieldConfigBlockManager.AboveOrBelow', 'Above or Below'), 'callback' => function () {
                    return DropdownField::create('AboveOrBelow', _t('GridFieldConfigBlockManager.AboveOrBelow', 'Above or Below'), BlockSet::config()->get('above_or_below_options'));
                });
            }
            $editable->setDisplayFields($displayfields);
            // EDIT
            $this->addComponent($erow = new EditableBlockRow());
            // /EDIT
        } else {
            $this->addComponent($dcols = new GridFieldDataColumns());
            $displayfields = array('singular_name' => _t('Block.BlockType', 'Block Type'), 'Title' => _t('Block.TitleName', 'Block Name'), 'BlockArea' => _t('Block.BlockArea', 'Block Area'), 'isPublishedNice' => _t('Block.IsPublishedField', 'Published'), 'UsageListAsString' => _t('Block.UsageListAsString', 'Used on'));
            $dcols->setDisplayFields($displayfields);
            $dcols->setFieldCasting(array('UsageListAsString' => 'HTMLText->Raw'));
        }
        $this->addComponent(new GridFieldButtonRow('before'));
        // EDIT
        $this->addComponent(new GridFieldButtonRow('after'));
        // /EDIT
        $this->addComponent(new GridFieldToolbarHeader());
        $this->addComponent(new GridFieldDetailForm());
        // EDIT
        //$this->addComponent($sort = new GridFieldSortableHeader());
        //$this->addComponent($filter = new GridFieldFilterHeader());
        //$this->addComponent(new GridFieldDetailForm());
        //$filter->setThrowExceptionOnBadDataType(false);
        //$sort->setThrowExceptionOnBadDataType(false);
        // load enhancements module (eg inline editing etc, needs save action @TODO: move to SiteTree only?
        if (class_exists('GF_BlockEnhancements')) {
            $this->addComponent(new GF_BlockEnhancements());
        }
        // stuff only for BlockAdmin
        if ($controllerClass == 'BlockAdmin') {
            $this->addComponent($sort = new GridFieldSortableHeader());
            $sort->setThrowExceptionOnBadDataType(false);
            $this->addComponent($filter = new GridFieldFilterHeader());
            $filter->setThrowExceptionOnBadDataType(false);
        } else {
            // only for GF on SiteTree
            $this->addComponent(new GridFieldTitleHeader());
            $this->addComponent(new GridFieldFooter());
            // groupable
            $this->addComponent(new GridFieldGroupable('BlockArea', 'Area', 'none', $areasFieldSource));
            //            var_dump($areasFieldSource);
            //            // Get available Areas (for page) enhancements inactive when in ModelAdmin/BlockAdmin
            //            if (Controller::curr() && Controller::curr()->class == 'CMSPageEditController') {
            //                // Provide defined blockAreas to JS
            //                $blockManager = Injector::inst()->get('BlockManager');
            ////            $blockAreas = $blockManager->getAreasForPageType( Controller::curr()->currentPage()->ClassName );
            //                $blockAreas = $blockManager->getAreasForPageType( Controller::curr()->currentPage()->ClassName );
            //            }
        }
        if ($canAdd) {
            $multiClass = new GridFieldAddNewMultiClass('after');
            $classes = $this->blockManager->getBlockClasses();
            $multiClass->setClasses($classes);
            $this->addComponent($multiClass);
            //$this->addComponent(new GridFieldAddNewButton());
        }
        // /EDIT
        if ($controllerClass == 'BlockAdmin' && class_exists('GridFieldCopyButton')) {
            $this->addComponent(new GridFieldCopyButton());
        }
        if ($canEdit) {
            $this->addComponent(new GridFieldEditButton());
        }
        if ($canDelete) {
            $this->addComponent(new GridFieldDeleteAction(true));
        }
        return $this;
    }
Example #12
0
 /**
  * @param $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent($columns = new GridFieldDataColumns());
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Name' => 'Name', 'Title' => 'Title'));
     $config->addComponent(new GridFieldPaginator(8));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->filter('ParentID', $folderID);
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
 /**
  * @param $folderID
  * @return CompositeField|FormField
  */
 protected function getListField($folderID)
 {
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent(new GridFieldPaginator(20));
     $config->addComponent($colsComponent = new GridFieldDataColumns());
     $colsComponent->setDisplayFields(array('StripThumbnail' => 'Thumbnail', 'Title' => 'Title', 'Size' => singleton('CloudinaryFile')->fieldLabel('Size')));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass);
     if ($this->parent->hasMethod('addFilterForFiles')) {
         $files = $this->parent->addFilterForFiles($files);
     }
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($fileField);
     return $selectComposite;
 }
 public function updateCMSFields(FieldList $f)
 {
     //clear all fields
     $oldFields = $f->toArray();
     foreach ($oldFields as $field) {
         $f->remove($field);
     }
     $_REQUEST['SummitID'] = $this->owner->ID;
     $f->add($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $summit_time_zone = null;
     if ($this->owner->TimeZone) {
         $time_zone_list = timezone_identifiers_list();
         $summit_time_zone = $time_zone_list[$this->owner->TimeZone];
     }
     if ($this->owner->RandomVotingLists()->exists()) {
         $f->addFieldToTab('Root.Main', HeaderField::create('The presentations in this summit have been randomised for voting', 4));
     }
     $f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $f->addFieldToTab('Root.Main', $link = new TextField('Link', 'Summit Page Link'));
     $link->setDescription('The link to the site page for this summit. Eg: <em>/summit/vancouver-2015/</em>');
     $f->addFieldToTab('Root.Main', new CheckboxField('Active', 'This is the active summit'));
     $f->addFieldToTab('Root.Main', $date_label = new TextField('DateLabel', 'Date label'));
     $date_label->setDescription('A readable piece of text representing the date, e.g. <em>May 12-20, 2015</em> or <em>December 2016</em>');
     $f->addFieldToTab('Root.Main', $registration_link = new TextField('RegistrationLink', 'Registration Link'));
     $registration_link->setDescription('Link to the site where tickets can be purchased.');
     $f->addFieldsToTab('Root.Dates', $ddl_timezone = new DropdownField('TimeZone', 'Time Zone', DateTimeZone::listIdentifiers()));
     $ddl_timezone->setEmptyString('-- Select a Timezone --');
     if ($summit_time_zone) {
         $f->addFieldToTab('Root.Dates', new HeaderField("All dates below are in <span style='color:red;'>{$summit_time_zone}</span> time."));
     } else {
         $f->addFieldToTab('Root.Dates', new HeaderField("All dates below in the timezone of the summit's venue."));
     }
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SummitBeginDate', "When does the summit begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SummitEndDate', "When does the summit end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('StartShowingVenuesDate', "When do you begin showing venues?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SubmissionBeginDate', "When do submissions begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SubmissionEndDate', "When do submissions end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('VotingBeginDate', "When does voting begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('VotingEndDate', "When does voting end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SelectionBeginDate', "When do selections begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SelectionEndDate', "When do selections end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('RegistrationBeginDate', "When does registration begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('RegistrationEndDate', "When does registration end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DateField('ScheduleDefaultStartDate', "Default Start Date to show on schedule page?"));
     $date->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldsToTab('Root.Main', new NumericField('MaxSubmissionAllowedPerUser', 'Max. Submission Allowed Per User'));
     $logo_field = new UploadField('Logo', 'Logo');
     $logo_field->setAllowedMaxFileNumber(1);
     $logo_field->setAllowedFileCategories('image');
     $logo_field->setFolderName('summits/logos/');
     $logo_field->getValidator()->setAllowedMaxFileSize(1024 * 1024 * 1);
     $f->addFieldToTab('Root.Main', $logo_field);
     $f->addFieldToTab('Root.Main', new TextField('ComingSoonBtnText', 'Coming Soon Btn Text'));
     $f->addFieldToTab('Root.Main', new TextField('ExternalEventId', 'Eventbrite Event Id'));
     if ($this->owner->ID > 0) {
         $summit_id = $this->owner->ID;
         // tracks
         $config = GridFieldConfig_RecordEditor::create(25);
         $categories = new GridField('Categories', 'Presentation Categories', $this->owner->getCategories(), $config);
         $f->addFieldToTab('Root.Presentation Categories', $categories);
         $config = GridFieldConfig_RelationEditor::create(25);
         $config->removeComponentsByType(new GridFieldDataColumns());
         $config->removeComponentsByType(new GridFieldDetailForm());
         $config->addComponent(new GridFieldUpdateDefaultCategoryTags());
         $default_tags = new GridField('CategoryDefaultTags', 'Category Default Tags', $this->owner->CategoryDefaultTags(), $config);
         $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());
         $f->addFieldToTab('Root.Presentation Categories', $default_tags);
         // track groups
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('PresentationCategoryGroup' => 'Category Group', 'PrivatePresentationCategoryGroup' => 'Private Category Group'));
         $config->addComponent($multi_class_selector);
         $categories = new GridField('CategoryGroups', 'Category Groups', $this->owner->CategoryGroups(), $config);
         $f->addFieldToTab('Root.Category Groups', $categories);
         // locations
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('SummitVenue' => 'Venue', 'SummitHotel' => 'Hotel', 'SummitAirport' => 'Airport', 'SummitExternalLocation' => 'External Location'));
         $config->addComponent($multi_class_selector);
         $config->addComponent($sort = new GridFieldSortableRows('Order'));
         $gridField = new GridField('Locations', 'Locations', $this->owner->Locations()->where("ClassName <> 'SummitVenueRoom' "), $config);
         $f->addFieldToTab('Root.Locations', $gridField);
         // types
         $config = GridFieldConfig_RecordEditor::create();
         $config->addComponent(new GridFieldAddDefaultSummitTypes());
         $gridField = new GridField('SummitTypes', 'SummitTypes', $this->owner->Types(), $config);
         $f->addFieldToTab('Root.SummitTypes', $gridField);
         // event types
         $config = GridFieldConfig_RecordEditor::create();
         $config->addComponent(new GridFieldAddDefaultEventTypes());
         $gridField = new GridField('EventTypes', 'EventTypes', $this->owner->EventTypes(), $config);
         $f->addFieldToTab('Root.EventTypes', $gridField);
         //schedule
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->removeComponentsByType('GridFieldDeleteAction');
         $gridField = new GridField('Schedule', 'Schedule', $this->owner->Events()->filter('Published', true)->sort(array('StartDate' => 'ASC', 'EndDate' => 'ASC')), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Description" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Schedule', $gridField);
         $config->addComponent(new GridFieldPublishSummitEventAction());
         // events
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldPublishSummitEventAction());
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->addComponent($bulk_summit_types = new GridFieldBulkActionAssignSummitTypeSummitEvents());
         $bulk_summit_types->setTitle('Set Summit Type');
         $gridField = new GridField('Events', 'Events', $this->owner->Events()->filter('ClassName', 'SummitEvent'), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Description" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Events', $gridField);
         //track selection list presentations
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('TrackChairsSelectionLists', 'TrackChairs Selection Lists', SummitSelectedPresentationList::get()->filter('ListType', 'Group')->where(' CategoryID IN ( SELECT ID FROM PresentationCategory WHERE SummitID = ' . $summit_id . ')'), $config);
         $f->addFieldToTab('Root.TrackChairs Selection Lists', $gridField);
         // attendees
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('Attendees', 'Attendees', $this->owner->Attendees(), $config);
         $f->addFieldToTab('Root.Attendees', $gridField);
         //tickets types
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('SummitTicketTypes', 'Ticket Types', $this->owner->SummitTicketTypes(), $config);
         $f->addFieldToTab('Root.TicketTypes', $gridField);
         // promo codes
         $config = GridFieldConfig_RecordEditor::create(50);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('SpeakerSummitRegistrationPromoCode' => 'Speaker Promo Code'));
         $config->addComponent($multi_class_selector);
         $promo_codes = new GridField('SummitRegistrationPromoCodes', 'Registration Promo Codes', $this->owner->SummitRegistrationPromoCodes(), $config);
         $f->addFieldToTab('Root.RegistrationPromoCodes', $promo_codes);
         // speakers
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('Speakers', 'Speakers', $this->owner->Speakers(false), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Bio" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Speakers', $gridField);
         // presentations
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldPublishSummitEventAction());
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->addComponent($bulk_summit_types = new GridFieldBulkActionAssignSummitTypeSummitEvents());
         $bulk_summit_types->setTitle('Set Summit Type');
         $gridField = new GridField('Presentations', 'Presentations', $this->owner->Presentations()->where(" Title IS NOT NULL AND Title <>'' "), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Description" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Presentations', $gridField);
         // push notifications
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Channel' => 'Channel', 'Message' => 'Message', 'Owner.FullName' => 'Owner', 'IsSent' => 'Is Sent?', 'SentDate' => 'Sent Date'));
         $config->getComponentByType('GridFieldDetailForm')->setItemRequestClass('GridFieldDetailFormPushNotification');
         $gridField = new GridField('Notifications', 'Notifications', $this->owner->Notifications(), $config);
         $f->addFieldToTab('Root.PushNotifications', $gridField);
         //entity events
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->addComponent(new GridFieldWipeDevicesDataAction());
         $config->addComponent(new GridFieldDeleteAllSummitEntityEventsAction());
         $config->removeComponentsByType('GridFieldAddNewButton');
         $gridField = new GridField('EntityEvents', 'EntityEvents', $this->owner->EntityEvents(), $config);
         $f->addFieldToTab('Root.EntityEvents', $gridField);
         //TrackChairs
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $gridField = new GridField('TrackChairs', 'TrackChairs', $this->owner->TrackChairs(), $config);
         $f->addFieldToTab('Root.TrackChairs', $gridField);
         //RSVP templates
         $config = GridFieldConfig_RecordEditor::create(40);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $gridField = new GridField('RSVPTemplates', 'RSVPTemplates', $this->owner->RSVPTemplates(), $config);
         $f->addFieldToTab('Root.RSVPTemplates', $gridField);
     }
 }
 /**
  * @param int $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HTMLEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent($colsComponent = new GridFieldDataColumns());
     $colsComponent->setDisplayFields(array('StripThumbnail' => '', 'Title' => singleton('File')->fieldLabel('Title'), 'Created' => singleton('File')->fieldLabel('Created'), 'Size' => singleton('File')->fieldLabel('Size')));
     $colsComponent->setFieldCasting(array('Created' => 'DBDatetime->Nice'));
     // Set configurable pagination for file list field
     $pageSize = Config::inst()->get(get_class($this), 'page_size');
     $config->addComponent(new GridFieldPaginator($pageSize));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->exclude('ClassName', 'Folder');
     if ($folderID) {
         $files = $files->filter('ParentID', $folderID);
     }
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
 /**
  * This will add the fallback value (val field after save) to the display fields component,
  * so it can be saved by @GridFieldEditableColumns
  *
  * @param GridField            $grid
  * @param GridFieldDataColumns $editable
  */
 private function addFallbackValueToDisplayFields(GridField $grid, GridFieldDataColumns $editable)
 {
     $fields = $editable->getDisplayFields($grid);
     if (!isset($fields[$this->valFieldAfterSave])) {
         $editable->setDisplayFields($fields + [$this->valFieldAfterSave => $this->valFieldAfterSave]);
     }
 }
Example #17
0
 /**
  * Returns a FieldList with which to create the CMS editing form
  *
  * @return FieldList The fields to be displayed in the CMS.
  */
 function getCMSFields()
 {
     Requirements::javascript("forum/javascript/ForumAccess.js");
     Requirements::css("forum/css/Forum_CMS.css");
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Access", new HeaderField(_t('Forum.ACCESSPOST', 'Who can post to the forum?'), 2));
     $fields->addFieldToTab("Root.Access", $optionSetField = new OptionsetField("CanPostType", "", array("Inherit" => "Inherit", "Anyone" => _t('Forum.READANYONE', 'Anyone'), "LoggedInUsers" => _t('Forum.READLOGGEDIN', 'Logged-in users'), "OnlyTheseUsers" => _t('Forum.READLIST', 'Only these people (choose from list)'), "NoOne" => _t('Forum.READNOONE', 'Nobody. Make Forum Read Only'))));
     $optionSetField->addExtraClass('ForumCanPostTypeSelector');
     $fields->addFieldsToTab("Root.Access", array(new TreeMultiselectField("PosterGroups", _t('Forum.GROUPS', "Groups")), new OptionsetField("CanAttachFiles", _t('Forum.ACCESSATTACH', 'Can users attach files?'), array("1" => _t('Forum.YES', 'Yes'), "0" => _t('Forum.NO', 'No')))));
     //Dropdown of forum category selection.
     $categories = ForumCategory::get()->map();
     $fields->addFieldsToTab("Root.Main", DropdownField::create('CategoryID', _t('Forum.FORUMCATEGORY', 'Forum Category'), $categories), 'Content');
     //GridField Config - only need to attach or detach Moderators with existing Member accounts.
     $moderatorsConfig = GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldAddExistingAutocompleter('buttons-before-right'))->addComponent(new GridFieldToolbarHeader())->addComponent($sort = new GridFieldSortableHeader())->addComponent($columns = new GridFieldDataColumns())->addComponent(new GridFieldDeleteAction(true))->addComponent(new GridFieldPageCount('toolbar-header-right'))->addComponent($pagination = new GridFieldPaginator());
     // Use GridField for Moderator management
     $moderators = GridField::create('Moderators', _t('MODERATORS', 'Moderators for this forum'), $this->Moderators(), $moderatorsConfig);
     $columns->setDisplayFields(array('Nickname' => 'Nickname', 'FirstName' => 'First name', 'Surname' => 'Surname', 'Email' => 'Email', 'LastVisited.Long' => 'Last Visit'));
     $sort->setThrowExceptionOnBadDataType(false);
     $pagination->setThrowExceptionOnBadDataType(false);
     $fields->addFieldToTab('Root.Moderators', $moderators);
     return $fields;
 }