filter export filenames

This commit is contained in:
Daniel Seifert 2021-04-19 14:36:25 +02:00
parent 6e421753fd
commit 68a440a53c
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
4 changed files with 15 additions and 5 deletions

View File

@ -68,7 +68,7 @@ abstract class ExportBase implements QueryBase
/** @var $oFS d3filesystem */ /** @var $oFS d3filesystem */
$oFS = oxNew(d3filesystem::class); $oFS = oxNew(d3filesystem::class);
$oFS->startDirectDownload( $oFS->startDirectDownload(
$this->getExportFilenameBase().'.'.$this->getFileExtension($format), $oFS->filterFilename($this->getExportFileName($format)),
$content $content
); );
} }
@ -105,4 +105,14 @@ abstract class ExportBase implements QueryBase
$renderer = $this->getRenderer($format); $renderer = $this->getRenderer($format);
return $renderer->getContent($rows, $fieldnames); return $renderer->getContent($rows, $fieldnames);
} }
/**
* @param $format
*
* @return string
*/
public function getExportFileName($format) : string
{
return $this->getExportFilenameBase().'_'.date('Y-m-d_H-i-s').'.'.$this->getFileExtension($format);
}
} }

View File

@ -31,7 +31,7 @@ class Csv implements RendererInterface
* @throws Exception * @throws Exception
* @throws CannotInsertRecord * @throws CannotInsertRecord
*/ */
public function getContent($rows, $fieldNames) public function getContent($rows, $fieldNames): string
{ {
$csv = $this->getCsv(); $csv = $this->getCsv();
$csv->insertOne($fieldNames); $csv->insertOne($fieldNames);

View File

@ -19,7 +19,7 @@ use MathieuViossat\Util\ArrayToTextTable;
class Pretty implements RendererInterface class Pretty implements RendererInterface
{ {
public function getContent($rows, $fieldnames) public function getContent($rows, $fieldNames) : string
{ {
$renderer = oxNew(ArrayToTextTable::class, $rows); $renderer = oxNew(ArrayToTextTable::class, $rows);
return $renderer->getTable(); return $renderer->getTable();

View File

@ -17,7 +17,7 @@ namespace D3\DataWizard\Application\Model\ExportRenderer;
interface RendererInterface interface RendererInterface
{ {
public function getContent($rows, $fieldnames); public function getContent($rows, $fieldNames) : string;
public function getFileExtension(); public function getFileExtension() : string;
} }