HTML to be embedded into the GridField.

@param GridField $gridField

@return array
5858
public function getHTMLFragments($gridField)
    {
        // permission check
        if (!singleton($gridField->getModelClass())->canEdit()) {
            return array();
        }

        // get uploadField
        $uploadField = $this->bulkUploadField($gridField);

        $data = ArrayData::create(array(
            'Colspan' => (count($gridField->getColumns())),
            'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
        ));

        Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/main.js');
        Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/main.css');
        Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:client/lang');

        return array(
            'before' => $data->renderWith('Colymba\\BulkUpload\\BulkUploader'),
        );
    }
495593
public function getHTMLFragments($gridField)
    {
        //Disable button if there is already a job running, and add a class to the progress button to trigger the display
        $jobs = FetchJob::get()->filter(['Status:not' => ['Done', 'Error']]);
        $current = $jobs->First();
        $global = $current && $current->ToFetch === "*" ? "global-fetch" : "";
        $disabled = $jobs->Count() > 0 ? "disabled" : "";
        $running = $jobs->Count() > 0 ? "hail-fetch-running" : "";
        $active = $jobs->Count() > 0 ? "state-active" : "";
        $vd = new ViewableData();
        $rendered = $vd
            ->customise([
                'Disabled' => $disabled,
                'Running' => $running,
                'Active' => $active,
                'Global' => $global,
            ])
            ->renderWith('GridFieldFetchButton')
            ->getValue();

        return [
            $this->targetFragment => $rendered,
        ];
    }
506328
public function augmentColumns($gridField, &$columns)
    {
        $baseColumns = array_keys($this->getDisplayFields($gridField));

        foreach ($baseColumns as $col) {
            $columns[] = $col;
        }

        $columns = array_unique($columns);
    }
674433
public function getCMSFields() {
        $langGridConfig=GridFieldConfig_RecordEditor::create(30);
        $langGridConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('CodeBankGridField_ItemRequest');
        $langGridConfig->getComponentByType('GridFieldDataColumns')->setFieldCasting(array(
                                                                                            'UserLanguage'=>'Boolean->Nice',
                                                                                            'Hidden'=>'Boolean->Nice'
                                                                                        ));
        
        $packageGridConfig=GridFieldConfig_RecordEditor::create(30);
        $packageGridConfig->addComponent(new ExportPackageButton());
        $packageGridConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('CodeBankGridField_ItemRequest')->setItemEditFormCallback(function(Form $form, GridFieldDetailForm_ItemRequest $itemRequest) {
                                                                                                    Requirements::javascript(CB_DIR.'/javascript/SnippetPackages.ItemEditForm.js');
                                                                                                    
                                                                                                    if($form->getRecord() && $form->getRecord()->ID>0) {
                                                                                                        $form->Actions()->push(FormAction::create('doExportPackage', _t('CodeBank.EXPORT', '_Export'))->setForm($form));
                                                                                                    }
                                                                                                    
                                                                                                    $form->addExtraClass('CodeBankPackages');
                                                                                                });
        
        if(Permission::check('ADMIN')) {
            $fields=new FieldList(
                                new TabSet('Root',
                                        new Tab('Main', _t('CodeBankConfig.MAIN', '_IP Message'),
                                                HtmlEditorField::create('IPMessage', _t('CodeBankConfig.IP_MESSAGE', '_Intellectual Property Message'))->addExtraClass('stacked')
                                            ),
                                        new Tab('Languages', _t('CodeBankConfig.LANGUAGES', '_Languages'),
                                                new GridField('Languages', _t('CodeBankConfig.LANGUAGES', '_Languages'), SnippetLanguage::get(), $langGridConfig)
                                            ),
                                        new Tab('Packages', _t('CodeBank.PACKAGES', '_Packages'),
                                                new GridField('Packages', _t('CodeBankConfig.MANAGE_PACKAGES', '_Manage Packages'), SnippetPackage::get(), $packageGridConfig)
                                            )
                                    )
                            );
        }else {
            $fields=new FieldList(
                                new TabSet('Root',
                                                new Tab('Packages', _t('CodeBank.PACKAGES', '_Packages'),
                                                        new GridField('Packages', _t('CodeBankConfig.MANAGE_PACKAGES', '_Manage Packages'), SnippetPackage::get(), $packageGridConfig)
                                                    )
                                            )
                            );
        }
        
        return $fields;
    }
6136
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        if (!$this->isAllowedChildren()) {
            return $fields;
        }
        $fields->addFieldsToTab(
            'Root.' . _t(__CLASS__ . '.CHILDREN', 'Children'),
            [
                GridField::create(
                    'Children',
                    _t(__CLASS__ . '.CHILDREN', 'Children'),
                    $this->Children(),
                    GridFieldConfig_RecordEditor::create()
                        ->addComponent(new GridFieldOrderableRows())
                )
            ]
        );

        return $fields;
    }
643104
public function getTemplateParameters(GridField $gridField)
    {
        $state = $this->getGridPagerState();
        if (is_numeric($state->pageSize)) {
            $this->setItemsPerPage($state->pageSize);
        }
        $arguments = $this->getPagerArguments();

        // Figure out which page and record range we're on
        if (!$arguments['total-rows']) {
            return null;
        }

        // Define a list of the FormActions that should be generated for pager controls (see getPagerActions())
        $controls = array(
            'first' => array(
                'title' => 'First',
                'args' => array('first-shown' => 1),
                'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-left '
                    . 'ss-gridfield-pagination-action ss-gridfield-firstpage',
                'disable-previous' => ($this->getCurrentPage() == 1)
            ),
            'prev' => array(
                'title' => 'Previous',
                'args' => array('first-shown' => $arguments['first-shown'] - $this->getItemsPerPage()),
                'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-left '
                    . 'ss-gridfield-pagination-action ss-gridfield-previouspage',
                'disable-previous' => ($this->getCurrentPage() == 1)
            ),
            'next' => array(
                'title' => 'Next',
                'args' => array('first-shown' => $arguments['first-shown'] + $this->getItemsPerPage()),
                'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-right '
                .'ss-gridfield-pagination-action  ss-gridfield-nextpage',
                'disable-next' => ($this->getCurrentPage() == $arguments['total-pages'])
            ),
            'last' => array(
                'title' => 'Last',
                'args' => array('first-shown' => ($this->getTotalPages() - 1) * $this->getItemsPerPage() + 1),
                'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-right '
                    . 'ss-gridfield-pagination-action ss-gridfield-lastpage',
                'disable-next' => ($this->getCurrentPage() == $arguments['total-pages'])
            ),
            'pagesize' => array(
                'title' => 'Page Size',
                'args' => array('first-shown' => $arguments['first-shown']),
                'extra-class' => 'ss-gridfield-pagination-action ss-gridfield-pagesize-submit'
            ),
        );

        if ($controls['prev']['args']['first-shown'] < 1) {
            $controls['prev']['args']['first-shown'] = 1;
        }

        $actions = $this->getPagerActions($controls, $gridField);

        // Render in template
        return ArrayData::create(array(
            'OnlyOnePage' => ($arguments['total-pages'] == 1),
            'FirstPage' => $actions['first'],
            'PreviousPage' => $actions['prev'],
            'NextPage' => $actions['next'],
            'LastPage' => $actions['last'],
            'PageSizesSubmit' => $actions['pagesize'],
            'CurrentPageNum' => $this->getCurrentPage(),
            'NumPages' => $arguments['total-pages'],
            'FirstShownRecord' => $arguments['first-shown'],
            'LastShownRecord' => $arguments['last-shown'],
            'NumRecords' => $arguments['total-rows'],
            'PageSizes' => $this->getPageSizesAsList(),
            'PageSizesName' => $gridField->getName() . '[page-sizes]',
        ));
    }
904023
public function generateExportFileData($gridField)
    {
        $class = $gridField->getModelClass();
        $columns = ($this->exportColumns) ? $this->exportColumns : ExcelImportExport::exportFieldsForClass($class);
        $fileData = '';

        $singl = singleton($class);

        $singular = $class ? $singl->i18n_singular_name() : '';
        $plural = $class ? $singl->i18n_plural_name() : '';

        $filter = new FileNameFilter;
        if ($this->exportName) {
            $this->exportName = $filter->filter($this->exportName);
        } else {
            $this->exportName = $filter->filter('export-' . $plural);
        }

        $excel = new PHPExcel();
        $excelProperties = $excel->getProperties();
        $excelProperties->setTitle($this->exportName);

        $sheet = $excel->getActiveSheet();
        if ($plural) {
            $sheet->setTitle($plural);
        }

        $row = 1;
        $col = 0;

        if ($this->hasHeader) {
            $headers = array();

            // determine the headers. If a field is callable (e.g. anonymous function) then use the
            // source name as the header instead
            foreach ($columns as $columnSource => $columnHeader) {
                $headers[] = (!is_string($columnHeader) && is_callable($columnHeader))
                    ? $columnSource : $columnHeader;
            }

            foreach ($headers as $header) {
                $sheet->setCellValueByColumnAndRow($col, $row, $header);
                $col++;
            }

            $endcol = PHPExcel_Cell::stringFromColumnIndex($col - 1);
            $sheet->setAutoFilter("A1:{$endcol}1");
            $sheet->getStyle("A1:{$endcol}1")->getFont()->setBold(true);

            $col = 0;
            $row++;
        }

        // Autosize
        $cellIterator = $sheet->getRowIterator()->current()->getCellIterator();
        try {
            $cellIterator->setIterateOnlyExistingCells(true);
        } catch (Exception $ex) {
            // Ignore exceptions
        }
        foreach ($cellIterator as $cell) {
            $sheet->getColumnDimension($cell->getColumn())->setAutoSize(true);
        }

        //Remove GridFieldPaginator as we're going to export the entire list.
        $gridField->getConfig()->removeComponentsByType('GridFieldPaginator');

        $items = $gridField->getManipulatedList();

        // @todo should GridFieldComponents change behaviour based on whether others are available in the config?
        foreach ($gridField->getConfig()->getComponents() as $component) {
            if ($component instanceof GridFieldFilterHeader || $component instanceof GridFieldSortableHeader) {
                $items = $component->getManipulatedData($gridField, $items);
            }
        }

        $list = $items->limit(null);
        if (!empty($this->listFilters)) {
            $list = $list->filter($this->listFilters);
        }

        /** @var Attendee $item */
        foreach ($list as $item) {
            if (!$this->checkCanView || !$item->hasMethod('canView') || $item->canView()) {
                foreach ($columns as $columnSource => $columnHeader) {
                    if (!is_string($columnHeader) && is_callable($columnHeader)) {
                        if ($item->hasMethod($columnSource)) {
                            $relObj = $item->{$columnSource}();
                        } else {
                            $relObj = $item->relObject($columnSource);
                        }
                        $value = $columnHeader($relObj);
                    } elseif ($field = $item->Fields()->byID($columnSource)) {
                        $value = $field->getValue();
                    } else {
                        $value = $gridField->getDataFieldValue($item, $columnSource);
                    }

                    $sheet->setCellValueByColumnAndRow($col, $row, $value);
                    $col++;
                }
            }

            if ($item->hasMethod('destroy')) {
                $item->destroy();
            }

            $col = 0;
            $row++;
        }

        return $excel;
    }
146036
public function getSearchForm(GridField $gridField)
    {
        $searchContext = $this->getSearchContext($gridField);
        $searchFields = $searchContext->getSearchFields();

        if ($searchFields->count() === 0) {
            return null;
        }

        if ($this->searchForm) {
            return $this->searchForm;
        }

        // Append a prefix to search field names to prevent conflicts with other fields in the search form
        foreach ($searchFields as $field) {
            $field->setName('Search__' . $field->getName());
        }

        $columns = $gridField->getColumns();

        // Update field titles to match column titles
        foreach ($columns as $columnField) {
            $metadata = $gridField->getColumnMetadata($columnField);
            // Get the field name, without any modifications
            $name = explode('.', $columnField);
            $title = $metadata['title'];
            $field = $searchFields->fieldByName($name[0]);

            if ($field) {
                $field->setTitle($title);
            }
        }

        foreach ($searchFields->getIterator() as $field) {
            $field->addExtraClass('stacked');
        }

        $name = $gridField->Title ?: singleton($gridField->getModelClass())->i18n_plural_name();

        $this->searchForm = $form = new Form(
            $gridField,
            $name . "SearchForm",
            $searchFields,
            new FieldList()
        );

        $form->setFormMethod('get');
        $form->setFormAction($gridField->Link());
        $form->addExtraClass('cms-search-form form--no-dividers');
        $form->disableSecurityToken(); // This form is not tied to session so we disable this
        $form->loadDataFrom($searchContext->getSearchParams());

        if ($this->updateSearchFormCallback) {
            call_user_func($this->updateSearchFormCallback, $form);
        }

        return $this->searchForm;
    }
851492
public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $listGridConfig = GridFieldConfig_RelationEditor::create();
        if ($this->Items()->Count() > 0) {
            $listGridConfig->addComponent(new GridFieldOrderableRows());
        }

        $fields->addFieldToTab(
            'Root.Main',
            GridField::create(
                'Items',
                'List',
                $this->Items(),
                $listGridConfig
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
713152
public function getHTMLFragments($gridField)
    {
        $modalID = $gridField->ID() . '_ImportModal';

        // Check for form message prior to rendering form (which clears session messages)
        $form = $this->getImportForm();
        $hasMessage = $form && $form->getMessage();

        // Render modal
        $template = SSViewer::get_templates_by_class(static::class, '_Modal');
        $viewer = new ArrayData([
            'ImportModalTitle' => $this->getModalTitle(),
            'ImportModalID' => $modalID,
            'ImportIframe' => $this->getImportIframe(),
            'ImportForm' => $this->getImportForm(),
        ]);
        $modal = $viewer->renderWith($template)->forTemplate();

        // Build action button
        $button = new GridField_FormAction(
            $gridField,
            'import',
            _t('SilverStripe\\Forms\\GridField\\GridField.CSVIMPORT', 'Import CSV'),
            'import',
            null
        );
        $button
            ->addExtraClass('btn btn-secondary font-icon-upload btn--icon-large action_import')
            ->setForm($gridField->getForm())
            ->setAttribute('data-toggle', 'modal')
            ->setAttribute('aria-controls', $modalID)
            ->setAttribute('data-target', "#{$modalID}")
            ->setAttribute('data-modal', $modal);

        // If form has a message, trigger it to automatically open
        if ($hasMessage) {
            $button->setAttribute('data-state', 'open');
        }

        return array(
            $this->targetFragment => $button->Field()
        );
    }
1055306
public function generateExportFileData($gridField)
    {
        $separator = $this->csvSeparator;
        $singl     = singleton($gridField->getModelClass());
        if ($singl->hasMethod('exportedFields')) {
            $fallbackColumns = $singl->exportedFields();
        } else {
            $fields          = array_keys(DataObject::database_fields($gridField->getModelClass()));
            $fallbackColumns = array_combine($fields, $fields);
        }
        $csvColumns = ($this->exportColumns) ? $this->exportColumns : $fallbackColumns;
        $fileData   = '';
        $columnData = array();
        $fieldItems = new ArrayList();

        if ($this->csvHasHeader) {
            $headers = array();

            // determine the CSV headers. If a field is callable (e.g. anonymous function) then use the
            // source name as the header instead
            foreach ($csvColumns as $columnSource => $columnHeader) {
                $headers[] = (!is_string($columnHeader) && is_callable($columnHeader))
                        ? utf8_decode($columnSource) : utf8_decode($columnHeader);
            }

            $fileData .= "\"".implode("\"{$separator}\"", array_values($headers))."\"";
            $fileData .= "\n";
        }

        $cb = $this->beforeListCallback;
        if ($cb) {
            $cb($gridField);
        }

        $items = $gridField->getList();

        $count        = $items->count();

        $speed = $this->speedMode;
        $fastMode     = false;
        $veryFastMode = false;
        
        if (!$speed) {
            // If you export too much, you need some boost!
            if ($count > 1500) {
                $fastMode = true;
            }
            if ($count > 7500) {
                $veryFastMode = true;
            }
        } else {
            switch ($speed) {
                case self::SPEED_NORMAL:
                    break;
                case self::SPEED_FAST:
                    $fastMode = true;
                    break;
                case self::SPEED_VERY_FAST:
                    $fastMode     = true;
                    $veryFastMode = true;
                    break;
                default:
                    throw new Exception("Speed $speed is not handled");
            }
        }

        foreach ($items as $item) {
            if ($fastMode || !$item->hasMethod('canView') || $item->canView()) {
                $columnData = array();

                foreach ($csvColumns as $columnSource => $columnHeader) {
                    if (!$veryFastMode && !is_string($columnHeader) && is_callable($columnHeader)) {
                        if ($item->hasMethod($columnSource)) {
                            $relObj = $item->{$columnSource}();
                        } else {
                            $relObj = $item->relObject($columnSource);
                        }

                        $value = $columnHeader($relObj);
                    } else {
                        if ($veryFastMode) {
                            $value = $item->$columnSource;
                        } else {
                            $value = $gridField->getDataFieldValue($item, $columnSource);

                            if (!$value) {
                                $value = $gridField->getDataFieldValue($item, $columnHeader);
                            }
                        }
                    }

                    $value        = str_replace(array("\r", "\n"), "\n", $value);
                    $columnData[] = '"'.str_replace('"', '""',
                            utf8_decode($value)).'"';
                }

                $fileData .= implode($separator, $columnData);
                $fileData .= "\n";
            }

            if ($item->hasMethod('destroy')) {
                $item->destroy();
            }
        }

        $cb = $this->afterListCallback;
        if ($cb) {
            $result = $cb($gridField, $list, $fileData);
            if ($result) {
                $fileData = $result;
            }
        }

        return $fileData;
    }
689517
protected function textarea(array $field)
    {
        $output = '';

        // Tag around input element.
        $output .= $this->getWrapper('input');
        $attributes = $field['attributes'];
        $attributes = $this->addAttribute($attributes, 'id', $field['id']);
        $attributes = $this->addAttribute($attributes, 'name', $field['name']);
        $output .= $this->getOpenTag('textarea', $attributes);
        $output .= htmlspecialchars($field['value'], $this->htmlSpecialCharsFlag, 'UTF-8');
        $output .= $this->getCloseTag('textarea');

        // Tag around input element.
        $output .= $this->getWrapperEnd('input');

        return $output;
    }
1038277
public function getColumns()
    {
        $columns = array();

        foreach ($this->getComponents() as $item) {
            if ($item instanceof GridField_ColumnProvider) {
                $item->augmentColumns($this, $columns);
            }
        }

        return $columns;
    }
479688
public function getFieldEditorGrid()
    {
        Requirements::javascript('silverstripe/userforms:client/dist/js/userforms-cms.js');

        $fields = $this->owner->Fields();

        $this->createInitialFormStep(true);

        $editableColumns = new GridFieldEditableColumns();
        $fieldClasses = singleton(EditableFormField::class)->getEditableFieldClasses();
        $editableColumns->setDisplayFields([
            'ClassName' => function ($record, $column, $grid) use ($fieldClasses) {
                if ($record instanceof EditableFormField) {
                    return $record->getInlineClassnameField($column, $fieldClasses);
                }
            },
            'Title' => function ($record, $column, $grid) {
                if ($record instanceof EditableFormField) {
                    return $record->getInlineTitleField($column);
                }
            }
        ]);

        $config = GridFieldConfig::create()
            ->addComponents(
                $editableColumns,
                new GridFieldButtonRow(),
                (new GridFieldAddClassesButton(EditableTextField::class))
                    ->setButtonName(_t(__CLASS__.'.ADD_FIELD', 'Add Field'))
                    ->setButtonClass('btn-primary'),
                (new GridFieldAddClassesButton(EditableFormStep::class))
                    ->setButtonName(_t(__CLASS__.'.ADD_PAGE_BREAK', 'Add Page Break'))
                    ->setButtonClass('btn-secondary'),
                (new GridFieldAddClassesButton([EditableFieldGroup::class, EditableFieldGroupEnd::class]))
                    ->setButtonName(_t(__CLASS__.'.ADD_FIELD_GROUP', 'Add Field Group'))
                    ->setButtonClass('btn-secondary'),
                $editButton = new GridFieldEditButton(),
                new GridFieldDeleteAction(),
                new GridFieldToolbarHeader(),
                new GridFieldOrderableRows('Sort'),
                new GridFieldDetailForm()
            );

        $editButton->removeExtraClass('grid-field__icon-action--hidden-on-hover');

        $fieldEditor = GridField::create(
            'Fields',
            '',
            $fields,
            $config
        )->addExtraClass('uf-field-editor');

        return $fieldEditor;
    }
1035718
public function getColumnMetadata($gridField, $column)
    {
        if ($column === self::CHECKBOX_COLUMN) {
            $title = _t('GridFieldMultiSelect.SelectAllVisibleRows', 'Select all visible rows');
            return array(
                'title' => '<input class="multiselect-all no-change-track" type="checkbox"
								title="' . htmlentities($title) . '">',
            );
        }
    }
727980
protected function getPaginator($gridField)
    {
        /** @var GridFieldPaginator $paginator */
        $paginator = $gridField->getConfig()->getComponentByType(GridFieldPaginator::class);

        if (!$paginator && GridFieldPageCount::config()->uninherited('require_paginator')) {
            throw new LogicException(
                static::class . " relies on a GridFieldPaginator to be added " . "to the same GridField, but none are present."
            );
        }

        return $paginator;
    }
1169050
public function getClasses(GridField $grid)
    {
        $result = array();

        if (is_null($this->classes)) {
            $classes = array_values(ClassInfo::subclassesFor($grid->getModelClass()));
            sort($classes);
        } else {
            $classes = $this->classes;
        }

        $kill_ancestors = array();
        foreach ($classes as $class => $title) {
            if (!is_string($class)) {
                $class = $title;
            }
            if (!class_exists($class)) {
                continue;
            }
            $is_abstract = (($reflection = new ReflectionClass($class)) && $reflection->isAbstract());
            if (!$is_abstract && $class === $title) {
                $title = singleton($class)->i18n_singular_name();
            }

            if ($ancestor_to_hide = Config::inst()->get($class, 'hide_ancestor')) {
                $kill_ancestors[$ancestor_to_hide] = true;
            }

            if ($is_abstract || !singleton($class)->canCreate()) {
                continue;
            }

            $result[$class] = $title;
        }

        if ($kill_ancestors) {
            foreach ($kill_ancestors as $class => $bool) {
                unset($result[$class]);
            }
        }

        $sanitised = array();
        foreach ($result as $class => $title) {
            $sanitised[$this->sanitiseClassName($class)] = $title;
        }

        return $sanitised;
    }