Merge pull request #4164 from wilr/fixssreportarraylist

FIX: Modifications to GridFieldExportButton to allow ArrayList use in SS_Report
This commit is contained in:
Damian Mooyman 2015-05-11 19:17:40 +12:00
commit 3907688f7d

View File

@ -132,7 +132,7 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
}
foreach($items->limit(null) as $item) {
if($item->hasMethod('canView') && $item->canView()) {
if(!$item->hasMethod('canView') || $item->canView()) {
$columnData = array();
foreach($csvColumns as $columnSource => $columnHeader) {
@ -146,16 +146,23 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
$value = $columnHeader($relObj);
} else {
$value = $gridField->getDataFieldValue($item, $columnSource);
if(!$value) {
$value = $gridField->getDataFieldValue($item, $columnHeader);
}
}
$value = str_replace(array("\r", "\n"), "\n", $value);
$columnData[] = '"' . str_replace('"', '""', $value) . '"';
}
$fileData .= implode($separator, $columnData);
$fileData .= "\n";
}
$item->destroy();
if($item->hasMethod('destroy')) {
$item->destroy();
}
}
return $fileData;