From 5faca9ca2f24902c146f9395449866efa9a7a41d Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 30 Jan 2012 16:48:15 +0100 Subject: [PATCH] MINOR Accessors, documentation and i18n for GridFieldExporter --- forms/gridfield/GridFieldExporter.php | 76 +++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/forms/gridfield/GridFieldExporter.php b/forms/gridfield/GridFieldExporter.php index 47cde9c94..7dd6a7328 100644 --- a/forms/gridfield/GridFieldExporter.php +++ b/forms/gridfield/GridFieldExporter.php @@ -1,4 +1,8 @@ exportColumns = $exportColumns; } @@ -20,7 +39,13 @@ class GridFieldExporter implements GridField_HTMLProvider, GridField_ActionProvi * Place the export button in a

tag below the field */ public function getHTMLFragments($gridField) { - $button = new GridField_Action($gridField, 'export', 'Export to CSV', 'export', null); + $button = new GridField_Action( + $gridField, + 'export', + _t('TableListField.CSVEXPORT', 'Export to CSV'), + 'export', + null + ); return array( 'after' => '

' . htmlentities($button->Field()) . '

', ); @@ -65,7 +90,7 @@ class GridFieldExporter implements GridField_HTMLProvider, GridField_ActionProvi */ function generateExportFileData($gridField) { $separator = $this->csvSeparator; - $csvColumns = ($this->exportColumns) ? $this->exportColumns : $gridField->getDisplayFields(); + $csvColumns = $this->getExportColumns(); $fileData = ''; $columnData = array(); $fieldItems = new ArrayList(); @@ -91,5 +116,50 @@ class GridFieldExporter implements GridField_HTMLProvider, GridField_ActionProvi return $fileData; } + + /** + * Returns exported columns, defaults to {@link GridField->getDisplayFields()}. + * + * @return array + */ + function getExportColumns() { + return ($this->exportColumns) ? $this->exportColumns : $gridField->getDisplayFields(); + } + + /** + * @param array + */ + function setExportColumns($cols) { + $this->exportColumns = $cols; + } + /** + * @return string + */ + function getCsvSeparator() { + return $this->csvSeparator; + } + + /** + * @param string + */ + function setCsvSeparator($separator) { + $this->csvSeparator = $separator; + } + + /** + * @return boolean + */ + function getCsvHasHeader() { + return $this->csvHasHeader; + } + + /** + * @param boolean + */ + function setCsvHasHeader($bool) { + $this->csvHasHeader = $bool; + } + + } \ No newline at end of file