Skip to content

Commit

Permalink
Add option to specify csv delimiter for export
Browse files Browse the repository at this point in the history
  • Loading branch information
joeke committed May 1, 2018
1 parent 2c7cc07 commit f1f5dd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions _build/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,12 @@
"type": "textfield",
"area": "system",
"value": ""
}
]
},{
"key": "export_csv_delimiter",
"type": "textfield",
"area": "system",
"value": ";"
}]
},
"database": {
"tables": [
Expand Down
6 changes: 3 additions & 3 deletions core/components/formit/processors/mgr/form/export.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function process()

public function createCsv($exportPath, $file, array $data)
{

$delimiter = $this->modx->getOption('formit.export_csv_delimiter', null, ';');
$keys = array('IP', 'Date', 'Form');

$handle = $exportPath.$file;
Expand All @@ -92,7 +92,7 @@ function () {
$defaultArr
);

fputcsv($fp, $keys, ';');
fputcsv($fp, $keys, $delimiter);
$dateFormat = $this->modx->getOption('manager_date_format').' '.$this->modx->getOption('manager_time_format');
foreach ($data['results'] as $object) {
$objectArray = $this->prepareRow($object);
Expand All @@ -103,7 +103,7 @@ function () {
foreach ($objectArray['values'] as $vk => $vv) {
$objectArray['values'][$vk] = (is_array($vv)) ? implode(',', $vv) : $vv;
}
fputcsv($fp, array_merge($defaultArr, $objectArray['values']), ';');
fputcsv($fp, array_merge($defaultArr, $objectArray['values']), $delimiter);
}
}
fclose($fp);
Expand Down

0 comments on commit f1f5dd1

Please sign in to comment.