Skip to content
Snippets Groups Projects
Commit 2379a528 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] CSV export

parent 51baf6fb
No related branches found
No related tags found
1 merge request!3New version 4 1
<?php
namespace SGalinski\SgMail\Controller;
/***************************************************************
......@@ -166,13 +167,41 @@ class QueueController extends ActionController {
/**
* Download the queue data as a csv file, respecting the filter settings
*
* @param string $selectedTemplate
* @param string $selectedExtension
* @param array $filters
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function exportAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []) {
$this->redirect('index', NULL, NULL, $this->request->getArguments());
public function exportAction(array $filters = []) {
$pageUid = (int) GeneralUtility::_GP('id');
$queue = $this->mailRepository->findAllEntries($pageUid, 0, $filters);
$exportString = 'Subject;Body;To;From;From Name;CC;BCC;Reply To;Extension;Template;Language' . LF;
foreach ($queue as $item) {
$exportString .= $item['mail_subject'] . ',';
if (strpos($item['mail_body'], ',') !== FALSE || strpos($item['mail_body'], '"') !== FALSE || strpos(
$item['mail_body'], "\n"
) !== FALSE) {
$item['mail_body'] = '"' . str_replace('"', '""', $item['mail_body']) . '"';
}
$exportString .= trim(preg_replace('/\s\s+/', ' ', strip_tags($item['mail_body']) . ';'));
$exportString .= $item['to_address'] . ';';
$exportString .= $item['from_address'] . ';';
$exportString .= $item['from_name'] . ';';
$exportString .= $item['cc_addresses'] . ';';
$exportString .= $item['bcc_addresses'] . ';';
$exportString .= $item['reply_to'] . ';';
$exportString .= $item['extension_key'] . ';';
$exportString .= $item['template_name'] . ';';
$exportString .= $item['language'] . LF;
}
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-Disposition: attachment; filename="export.csv"');
header('Content-Length: ' . strlen($exportString));
echo $exportString;
exit(0);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment