From 57753a0cdcfa62c9db7b5f62df082366b31a11f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kie=C3=9Fling?= Date: Tue, 28 Jul 2020 23:08:20 +0200 Subject: [PATCH 1/2] =?UTF-8?q?[FEATURE]=C2=A0skip=20GridRows=20in=20data?= =?UTF-8?q?=20export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/DataExporter/DataExporter.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Classes/DataExporter/DataExporter.php b/Classes/DataExporter/DataExporter.php index d57b7e3..a946c9f 100644 --- a/Classes/DataExporter/DataExporter.php +++ b/Classes/DataExporter/DataExporter.php @@ -28,7 +28,7 @@ public function getExport($rowAnswers, FormEntryDemand $formEntryDemand, $useSub $rows[$uid][$formEntryDemand->getUidLabel()] = $uid; } foreach ($entry->getAnswers() as $fieldName => $field) { - if (!preg_match('/^fieldset/', $fieldName) && !preg_match('/^statictext/', $fieldName)) { + if ($this->isExportableType($field['conf']['inputType'])) { $rows[$uid][$fieldName] = (is_array($field['value']) ? implode(",", $field['value']) : $field['value']); } } @@ -54,9 +54,19 @@ protected function setHeaders($rowAnswers, FormEntryDemand $formEntryDemand, $he } foreach ($headerKeys as $field => $val) { - if ($val['conf']['inputType'] !== 'Fieldset' && $val['conf']['inputType'] !== 'StaticText') { + if ($this->isExportableType($val['conf']['inputType'])) { $header[] = ($val['conf']['label'] ? $val['conf']['label'] : $field); } } } + + private function isExportableType(string $inputType): bool + { + $typesToSkip = [ + 'Fieldset', + 'StaticText', + 'GridRow' + ]; + return !\in_array($inputType, $typesToSkip); + } } From 3281d1d802643e88fecf1629a816cd9128a6a006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kie=C3=9Fling?= Date: Tue, 28 Jul 2020 23:24:01 +0200 Subject: [PATCH 2/2] =?UTF-8?q?[BUGFIX]=C2=A0detect=20DateTime=20object=20?= =?UTF-8?q?in=20CSV=20export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/View/FormEntry/ExportCsv.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Classes/View/FormEntry/ExportCsv.php b/Classes/View/FormEntry/ExportCsv.php index f02a3c7..e08f6d2 100644 --- a/Classes/View/FormEntry/ExportCsv.php +++ b/Classes/View/FormEntry/ExportCsv.php @@ -63,7 +63,11 @@ public function initializeView() public function render() { foreach ($this->variables['rows'] as $fields) { - $this->fputcsv2($fields, $this->delimiter[$this->variables['formEntryDemand']->getDelimiter()], $this->enclosure[$this->variables['formEntryDemand']->getEnclosure()]); + $this->fputcsv2( + $fields, + $this->delimiter[$this->variables['formEntryDemand']->getDelimiter()], + $this->enclosure[$this->variables['formEntryDemand']->getEnclosure()] + ); } } @@ -88,6 +92,9 @@ private function fputcsv2(array $fields, $delimiter = ';', $enclosure = '"', $my $output[] = 'NULL'; continue; } + if ($field instanceof \DateTime) { + $field = $field->format('r'); + } $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field) ? ( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure