Returns the Fetch Button html

@param GridField $gridField
@return array
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,
        ];
    }
806734
public function getGroup($gridField, $record, $columnName)
    {
        if (!$this->canUnlink($record)) {
            return null;
        }

        return parent::getGroup($gridField, $record, $columnName);
    }
805743
public function getForm(GridField $grid, DataObjectInterface $record)
    {
        $fields = $this->getFields($grid, $record);

        $form = new Form($grid, null, $fields, new FieldList());
        $form->loadDataFrom($record);

        $form->setFormAction(Controller::join_links(
            $grid->Link(),
            'editable/form',
            $record->ID
        ));

        return $form;
    }
209311
public function getManipulatedData(GridField $gridField, SS_List $dataList)
    {
        //Detect and correct items with a sort column value of 0 (push to bottom)
        $this->fixSortColumn($gridField, $dataList);


        $headerState = $gridField->State->GridFieldSortableHeader;
        $state = $gridField->State->GridFieldSortableRows;
        if ((!is_bool($state->sortableToggle) || $state->sortableToggle === false) && $headerState && is_string($headerState->SortColumn) && is_string($headerState->SortDirection)) {
            return $dataList->sort($headerState->SortColumn, $headerState->SortDirection);
        }

        if ($state->sortableToggle === true) {
            $gridField->getConfig()->removeComponentsByType(GridFieldFilterHeader::class);
            $gridField->getConfig()->removeComponentsByType(GridFieldSortableHeader::class);
        }

        return $dataList->sort($this->sortColumn);
    }
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;
    }
1250995
public function getHTMLFragments($gridField)
    {
        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');

        if (!count($this->config['actions'])) {
            user_error('Trying to use BulkManager without any bulk action.', E_USER_ERROR);
        }

        $actionsListSource = array();
        $actionsConfig = array();

        foreach ($this->config['actions'] as $urlSegment => $handlerClassName) {
            $handler = Injector::inst()->get($handlerClassName);
            $handlerConfig = $handler->getConfig();

            $actionsListSource[$urlSegment] = $handlerConfig['label'];
            $actionsConfig[$urlSegment] = $handlerConfig;
        }

        $dropDownActionsList = DropdownField::create(
            'bulkActionName',
            false
        )
            ->setSource($actionsListSource)
            ->addExtraClass('bulkActionName no-change-track form-group--no-label')
            ->setAttribute('id', '')
            ->setEmptyString(_t('SilverStripe\Admin\LeftAndMain.DropdownBatchActionsDefault', 'Choose an action...'));
            

        $templateData = array(
            'Menu' => $dropDownActionsList->FieldHolder(),
            'Button' => array(
                'Label' => _t('GRIDFIELD_BULK_MANAGER.ACTION_BTN_LABEL', 'Go'),
                'DataURL' => $gridField->Link('bulkAction'),
                'DataConfig' => json_encode($actionsConfig)
            ),
            'Select' => array(
                'Label' => _t('GRIDFIELD_BULK_MANAGER.SELECT_ALL_LABEL', 'Select all'),
            ),
            'Colspan' => (count($gridField->getColumns()) - 1),
        );

        $templateData = new ArrayData($templateData);

        return array(
            'header' => $templateData->renderWith('Colymba\\BulkManager\\BulkManagerButtons'),
        );
    }
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;
    }
693091
protected function getItemRequestHandler($gridField, $record, $requestHandler)
    {
        $class = $this->getItemRequestClass();
        $assignedClass = $this->itemRequestClass;
        $this->extend('updateItemRequestClass', $class, $gridField, $record, $requestHandler, $assignedClass);
        /** @var GridFieldDetailForm_ItemRequest $handler */
        $handler = Injector::inst()->createWithArgs(
            $class,
            array($gridField, $this, $record, $requestHandler, $this->name)
        );
        if ($template = $this->getTemplate()) {
            $handler->setTemplate($template);
        }
        $this->extend('updateItemRequestHandler', $handler);
        return $handler;
    }
1217622
public function handlePrint($gridField, $request = null)
    {
        set_time_limit(60);
        Requirements::clear();

        $data = $this->generatePrintData($gridField);

        $this->extend('updatePrintData', $data);

        if ($data) {
            return $data->renderWith([
                get_class($gridField) . '_print',
                GridField::class . '_print',
            ]);
        }

        return null;
    }
1120251
public function getReportField()
    {
        Requirements::css('bringyourownideas/silverstripe-maintenance: client/dist/styles/bundle.css');
        Requirements::javascript('bringyourownideas/silverstripe-maintenance: client/dist/js/bundle.js');

        /** @var GridField $grid */
        $grid = parent::getReportField();

        /** @var GridFieldConfig $config */
        $config = $grid->getConfig();

        $grid->addExtraClass('site-summary');

        $summaryFields = Package::create()->summaryFields();
        /** @var GridFieldExportButton $exportButton */
        $exportButton = $config->getComponentByType(GridFieldExportButton::class);
        $exportButton->setExportColumns($summaryFields);
        /** @var GridFieldPrintButton $printButton */
        $printButton = $config->getComponentByType(GridFieldPrintButton::class);
        $printButton->setPrintColumns($summaryFields);

        $versionHtml = ArrayData::create([
            'Title' => _t(__CLASS__ . '.VERSION', 'Version'),
            'Version' => $this->resolveCmsVersion(),
            'LastUpdated' => $this->getLastUpdated(),
        ])->renderWith(__CLASS__ . '/VersionHeader');

        $config->addComponents(
            Injector::inst()->create(GridFieldRefreshButton::class, 'buttons-before-left'),
            Injector::inst()->create(
                GridFieldLinkButton::class,
                'https://addons.silverstripe.org',
                _t(__CLASS__ . '.LINK_TO_ADDONS', 'Explore Addons'),
                'buttons-before-left'
            ),
            $this->getDropdownFilter(),
            $this->getInfoLink(),
            Injector::inst()->create(GridFieldHtmlFragment::class, 'header', $versionHtml)
        );

        // Re-order the paginator to ensure it counts correctly, and reorder the buttons
        $paginator = $config->getComponentByType(GridFieldPaginator::class);
        $config->removeComponent($paginator)->addComponent($paginator);

        $exportButton = $config->getComponentByType(GridFieldExportButton::class);
        $config->removeComponent($exportButton)->addComponent($exportButton);

        $printButton = $config->getComponentByType(GridFieldPrintButton::class);
        $config->removeComponentsByType($printButton)->addComponent($printButton);

        return $grid;
    }
1161339
public function getColumnContent($gridField, $record, $columnName) {
        if(!$record->canView()) return;

        $field = GridField_FormAction::create($gridField, 'ExportSingle'.$record->ID, false,
                "exportsingle", array('RecordID' => $record->ID))
            ->addExtraClass('gridfield-button-export-single no-ajax')
            ->setAttribute('title', _t('firebrandhq.EXCELEXPORT', "Export"))
            ->setAttribute('data-icon', 'download-csv');
        return $field->Field();
    }
1298044
public function getLegacyFilterHeader(GridField $gridField)
    {
        Deprecation::notice('5.0', 'Table row based filter header will be removed in favor of search field in 5.0');

        $list = $gridField->getList();
        if (!$this->checkDataType($list)) {
            return null;
        }

        $columns = $gridField->getColumns();
        $filterArguments = $gridField->State->GridFieldFilterHeader->Columns->toArray();
        $currentColumn = 0;
        $canFilter = false;
        $fieldsList = new ArrayList();

        foreach ($columns as $columnField) {
            $currentColumn++;
            $metadata = $gridField->getColumnMetadata($columnField);
            $title = $metadata['title'];
            $fields = new FieldGroup();

            if ($title && $list->canFilterBy($columnField)) {
                $canFilter = true;

                $value = '';
                if (isset($filterArguments[$columnField])) {
                    $value = $filterArguments[$columnField];
                }
                $field = new TextField('filter[' . $gridField->getName() . '][' . $columnField . ']', '', $value);
                $field->addExtraClass('grid-field__sort-field');
                $field->addExtraClass('no-change-track');

                $field->setAttribute(
                    'placeholder',
                    _t('SilverStripe\\Forms\\GridField\\GridField.FilterBy', "Filter by ") . _t('SilverStripe\\Forms\\GridField\\GridField.' . $metadata['title'], $metadata['title'])
                );

                $fields->push($field);
                $fields->push(
                    GridField_FormAction::create($gridField, 'reset', false, 'reset', null)
                        ->addExtraClass('btn font-icon-cancel btn-secondary btn--no-text ss-gridfield-button-reset')
                        ->setAttribute('title', _t('SilverStripe\\Forms\\GridField\\GridField.ResetFilter', "Reset"))
                        ->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField)
                );
            }

            if ($currentColumn == count($columns)) {
                $fields->push(
                    GridField_FormAction::create($gridField, 'filter', false, 'filter', null)
                        ->addExtraClass('btn font-icon-search btn--no-text btn--icon-large grid-field__filter-submit ss-gridfield-button-filter')
                        ->setAttribute('title', _t('SilverStripe\\Forms\\GridField\\GridField.Filter', 'Filter'))
                        ->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $columnField)
                );
                $fields->push(
                    GridField_FormAction::create($gridField, 'reset', false, 'reset', null)
                        ->addExtraClass('btn font-icon-cancel btn--no-text grid-field__filter-clear btn--icon-md ss-gridfield-button-close')
                        ->setAttribute('title', _t('SilverStripe\\Forms\\GridField\\GridField.ResetFilter', "Reset"))
                        ->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField)
                );
                $fields->addExtraClass('grid-field__filter-buttons');
                $fields->addExtraClass('no-change-track');
            }

            $fieldsList->push($fields);
        }

        return $canFilter ? $fieldsList : null;
    }
780325
private function _getGridView(bool $isCount = false): \Assurrussa\GridView\Helpers\GridViewResult
    {
        $this->_fetch();

        $gridViewResult = new \Assurrussa\GridView\Helpers\GridViewResult();
        $gridViewResult->id = $this->getId();
        $gridViewResult->ajax = $this->ajax;
        $gridViewResult->formAction = $this->getFormAction();
        $gridViewResult->requestParams = $this->requestParams;
        $gridViewResult->headers = $this->columns->toArray();
        $gridViewResult->buttonCreate = $this->buttons->getButtonCreate();
        $gridViewResult->buttonExport = $this->buttons->getButtonExport();
        $gridViewResult->buttonCustoms = $this->buttons->render();
        $gridViewResult->inputCustoms = $this->inputs->render();
        $gridViewResult->filter = $this->_request->toArray();
        $gridViewResult->page = $this->page;
        $gridViewResult->orderBy = $this->orderBy;
        $gridViewResult->search = $this->search;
        $gridViewResult->limit = $this->limit;
        $gridViewResult->sortName = $this->sortName;
        $gridViewResult->counts = $this->counts;
        $gridViewResult->searchInput = $this->searchInput;

        return $gridViewResult;
    }
233730
public function bulkUploadField($gridField)
    {
        $fileRelationName = $this->getFileRelationName($gridField);
        $fieldName = $fileRelationName . '_' . $this->getRecordClassName($gridField) . '_BU';
        $uploadField = BulkUploadField::create($gridField, $fieldName, '')
            ->setForm($gridField->getForm())
            ->setRecord(DataObject::create()) // avoid UploadField to get auto-config from the Page (e.g fix allowedMaxFileNumber)
            ;

        //UploadField setup
        foreach ($this->ufSetup as $fn => $param) {
            $uploadField->{$fn}($param);
        }

        $schema['data']['createFileEndpoint'] = [
            'url' => $gridField->Link('bulkupload/upload'),
            'method' => 'post',
            'payloadFormat' => 'urlencoded',
        ];

        $schema['data']['attachFileEndpoint'] = [
            'url' => $gridField->Link('bulkupload/attach'),
            'method' => 'post'
        ];

        $uploadField->setSchemaData($schema);

        return $uploadField;
    }
589600
public function getDisplayFields($gridField)
    {
        if (!$this->displayFields) {
            return singleton($gridField->getModelClass())->summaryFields();
        }
        return $this->displayFields;
    }
1370509
protected function getGridPagerState(GridField $gridField)
    {
        $state = $gridField->State->GridFieldPaginator;

        // Force the state to the initial page if none is set
        $state->currentPage(1);
        $state->itemsPerPage($this->getItemsPerPage());

        return $state;
    }
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;
    }