Commit 31d8a763 authored by Fabio Stegmeyer's avatar Fabio Stegmeyer
Browse files

[TASK] Render mails as tables, add some styling

parent de697930
......@@ -874,6 +874,7 @@ class MailTemplateService {
$emailView->assignMultiple($this->markers);
$emailView->assign('all_fields', $this->getAllMarker($this->markers));
$emailView->assign('all_fields_html', $this->getAllMarkerHTML($this->markers));
//TODO: make this as the lines below the next block
$overwrittenEmailBody = $this->getOverwrittenEmailBody();
......@@ -989,6 +990,42 @@ class MailTemplateService {
return $allMarker;
}
/**
* Get a single variable containing a list of all markers in table markup
*
* @param array $markers
* @return string
*/
private function getAllMarkerHTML(array $markers): string {
$allMarker = '<table>';
$allMarker .= '<style> table { text-align: left; } table tr th, table tr td { border-bottom: 1px solid rgba(0,0,0,0.2); padding: 2px 6px 4px;} </style>';
foreach ($markers as $key => $value) {
if (\array_key_exists($key, $this->markerLabels) && $this->markerLabels[$key] !== NULL) {
$key = $this->markerLabels[$key];
}
if (\is_string($value)) {
$allMarker .= '<tr><th>' . $key . ': </th><td> ' . $value . '</td></tr>';
} elseif (\is_array($value)) {
foreach ($value as $innerKey => $innerValue) {
$allMarker .= '<tr><th>' . $key . '.' . $innerKey . ': </th><td> ' . $innerValue . '</td></tr>';
}
} elseif (\is_bool($value)) {
$valueAsString = $value ? 'true' : 'false';
$allMarker .= '<tr><th>' . $key . ': </th><td> ' . $valueAsString . '</td></tr>';
} elseif (\is_object($value)) {
if (\method_exists($value, '__toString')) {
$allMarker .= '<tr><th>' . $key . ': </th><td> ' . $value->__toString() . '</td></tr>';
}
}
}
$allMarker .= '</table>';
return $allMarker;
}
/**
* @return string
*/
......
......@@ -257,7 +257,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
'description' => $description,
'subject' => $subject,
'markers' => [],
'templateContent' => '{all_fields}'
'templateContent' => '<f:format.html>{all_fields_html}</f:format.html>',
];
foreach ($markers as $marker) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment