filter export filenames
This commit is contained in:
parent
6e421753fd
commit
68a440a53c
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -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);
|
||||||
|
@ -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();
|
||||||
|
@ -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;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user