This commit is contained in:
Philipp Dieter 2024-02-09 11:04:10 +01:00
commit fe7b034599
2 changed files with 90 additions and 78 deletions

View File

@ -79,6 +79,10 @@ class MailUtility
$type = 'tableLayout'; $type = 'tableLayout';
$textPart = substr($textPart, 3); $textPart = substr($textPart, 3);
} }
if (substr($textPart, 0, 3) === '---') {
$type = 'divider';
$textPart = substr($textPart, 3);
}
if (substr($textPart, 0, 9) === '%subject ') { if (substr($textPart, 0, 9) === '%subject ') {
$type = 'subject'; $type = 'subject';
$textPart = substr($textPart, 9); $textPart = substr($textPart, 9);
@ -223,6 +227,7 @@ class MailUtility
switch($row['type']) { switch($row['type']) {
case 'text': case 'text':
case 'table': case 'table':
case 'tablelr':
case 'tableLayout': case 'tableLayout':
case 'list': case 'list':
case 'textbold': case 'textbold':
@ -233,6 +238,8 @@ class MailUtility
case 'buttonleft': case 'buttonleft':
case 'buttoncenter': case 'buttoncenter':
case 'buttonright': case 'buttonright':
case 'divider':
case 'hr':
$row['data'] = str_replace( $row['data'] = str_replace(
"\\\n", "\\\n",
'', '',
@ -308,77 +315,10 @@ class MailUtility
$bodydataText[] = $textRow; $bodydataText[] = $textRow;
$bodydataHtml[] = $htmlRow; $bodydataHtml[] = $htmlRow;
break; break;
//case 'button': case 'contentBlockHtml':
// $row['data'] = str_replace( $htmlRow = $row;
// "\\\n", $bodydataHtml[] = $htmlRow;
// '', break;
// $row['data']
// );
// $htmlRow = $row;
// $htmlRow['data'] = preg_replace_callback(
// '/\[.*\]/mU',
// function($matches) {
// foreach ($matches as $match) {
// $test = preg_replace_callback(
// '/\[(\S*)\s(.*)\]/mU',
// function($matchesInner) {
//
// return '<a href="'
// . $matchesInner[1]
// . '">'
// . $matchesInner[2]
// . '</a>';
// },
// $match
// );
// \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
// $test, null, 3, true, false
// );
// return $test;
// }
// },
// $htmlRow['data']
// );
// \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
// $htmlRow['data'], null, 3, true, false
// );
// $htmlRow['data'] = preg_replace_callback(
// '/\*.*\*/mU',
// function($matches) {
// foreach ($matches as $match) {
// return '<b>'
// . substr($match, 1, -1)
// . '</b>';
// }
// },
// $htmlRow['data']
// );
// $textRow = $row;
// $textRow['data'] = preg_replace_callback(
// '/\[.*\]/mU',
// function($matches) {
// foreach ($matches as $match) {
// return preg_replace_callback(
// '/\[(\S*)\s(.*)\]/mU',
// function($matchesInner) {
// if (
// $matchesInner[2] == $matchesInner[1]
// ) {
// return $matchesInner[1];
// }
// return $matchesInner[2]
// . ': '
// . $matchesInner[1];
// },
// $match
// );
// }
// },
// $textRow['data']
// );
// $bodydataText[] = $textRow;
// $bodydataHtml[] = $htmlRow;
// break;
case 'attachment': case 'attachment':
$mail->attach(new \Swift_Attachment( $mail->attach(new \Swift_Attachment(
$row['data'][0], $row['data'][0],
@ -402,9 +342,6 @@ class MailUtility
} }
$textView->assign('content', $bodydataText); $textView->assign('content', $bodydataText);
$htmlView->assign('content', $bodydataHtml); $htmlView->assign('content', $bodydataHtml);
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
// $bodydataHtml, null, 8, true, false
//);
$domain = $settings['mailDomain']; $domain = $settings['mailDomain'];
if ($assetDomain) { if ($assetDomain) {
$domain = $assetDomain; $domain = $assetDomain;
@ -457,4 +394,23 @@ class MailUtility
} }
} }
} }
/**
* Debug print
*/
public static function printMaildata($maildata)
{
foreach ($maildata as $row) {
if (!is_array($row['data'])) {
print($row['data']);
} else {
print($row['data'][0]);
print(PHP_EOL);
print($row['data'][1]);
}
print(PHP_EOL);
}
print(PHP_EOL);
}
} }

View File

@ -24,12 +24,17 @@
<f:for each="{content}" as="row" key="rowKey" iteration="rowI" > <f:for each="{content}" as="row" key="rowKey" iteration="rowI" >
<v:condition.type.isArray value="{row.data}"> <v:condition.type.isArray value="{row.data}">
<f:else> <f:else>
<f:if condition="{row.type} == 'contentBlockHtml'">
{row.data -> f:format.raw()}
</f:if>
<f:if condition="{v:condition.string.contains(haystack: '{row.type}', needle: 'headline', then: '1')} <f:if condition="{v:condition.string.contains(haystack: '{row.type}', needle: 'headline', then: '1')}
|| {row.type} == 'text' || {row.type} == 'text'
|| {row.type} == 'button' || {row.type} == 'button'
|| {row.type} == 'buttonleft' || {row.type} == 'buttonleft'
|| {row.type} == 'buttoncenter' || {row.type} == 'buttoncenter'
|| {row.type} == 'buttonright' || {row.type} == 'buttonright'
|| {row.type} == 'divider'
|| {row.type} == 'hr'
"> ">
<!--[if mso | IE]> <!--[if mso | IE]>
<table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:{width}px;" width="{width}" > <table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:{width}px;" width="{width}" >
@ -50,6 +55,14 @@
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"> <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody> <tbody>
<tr> <tr>
<f:switch expression="{row.type}">
<f:case value="divider">
<f:variable name='paddingTd' value='20px 0' />
</f:case>
<f:defaultCase>
<f:variable name='paddingTd' value='0' />
</f:defaultCase>
</f:switch>
<td style="vertical-align:top;padding:0;"> <td style="vertical-align:top;padding:0;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style width="100%"> <table border="0" cellpadding="0" cellspacing="0" role="presentation" style width="100%">
<tr> <tr>
@ -64,7 +77,7 @@
<f:variable name='align' value='left' /> <f:variable name='align' value='left' />
</f:defaultCase> </f:defaultCase>
</f:switch> </f:switch>
<td align="{align}" style="font-size:0px;padding:0;word-break:break-word;"> <td align="{align}" style="font-size:0px;padding:{paddingTd};word-break:break-word;">
<div style="font-family:Arial, sans-serif;font-size:16px;line-height:1.4;text-align:{align};color:#000000;"> <div style="font-family:Arial, sans-serif;font-size:16px;line-height:1.4;text-align:{align};color:#000000;">
<f:switch expression="{row.type}"> <f:switch expression="{row.type}">
<f:case value="headline"> <f:case value="headline">
@ -101,6 +114,38 @@
{row.data -> f:format.nl2br() -> f:format.raw()} {row.data -> f:format.nl2br() -> f:format.raw()}
</span> </span>
</f:case> </f:case>
<f:case value="hr">
<p style="border-top:solid 1px #bababa;font-size:1px;margin:13px auto;width:100%;">
</p>
<!--[if mso | IE]>
&nbsp;
<table
align="center"
border="0"
cellpadding="0"
cellspacing="0"
style="border-top:solid 1px #bababa;font-size:1px;margin:13px auto;width:100%;"
role="presentation"
width="550px"
>
<tr>
<td style="height:0;line-height:0;">
&nbsp;
</td>
</tr>
</table>
&nbsp;
<![endif]-->
</f:case>
<f:case value="divider">
<p style="border-top:solid 2px #025093;font-size:1px;margin:0px auto;width:100%;">
</p>
<!--[if mso | IE]>
<table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 2px #025093;font-size:1px;margin:0px auto;width:550px;" role="presentation" width="550px" >
<tr><td style="height:0;line-height:0;"> &nbsp; </td></tr>
</table>
<![endif]-->
</f:case>
<f:defaultCase> <f:defaultCase>
<p>{row.data -> f:format.nl2br() -> f:format.raw()}</p> <p>{row.data -> f:format.nl2br() -> f:format.raw()}</p>
</f:defaultCase> </f:defaultCase>
@ -137,6 +182,9 @@
<f:case value="table"> <f:case value="table">
<f:variable name="type" value="table" /> <f:variable name="type" value="table" />
</f:case> </f:case>
<f:case value="tablelr">
<f:variable name="type" value="table" />
</f:case>
<f:case value="tableLayout"> <f:case value="tableLayout">
<f:variable name="type" value="table" /> <f:variable name="type" value="table" />
</f:case> </f:case>
@ -178,11 +226,19 @@
</td> </td>
<td class="" style="vertical-align:top;width:{widthTableColumn}px;"> <td class="" style="vertical-align:top;width:{widthTableColumn}px;">
<![endif]--> <![endif]-->
<div class="mj-column-per-50 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"> <f:switch expression="{row.type}">
<f:case value="tablelr">
<f:variable name="align" value="right" />
</f:case>
<f:defaultCase>
<f:variable name="align" value="left" />
</f:defaultCase>
</f:switch>
<div class="mj-column-per-50 outlook-group-fix" style="font-size:13px;text-align:{align};direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"> <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tr> <tr>
<td align="left" style="font-size:0px;padding:0px 4px;word-break:break-word;"> <td align="{align}" style="font-size:0px;padding:0px 4px;word-break:break-word;">
<div style="font-family:Arial, sans-serif;font-size:16px;line-height:1.4;text-align:left;color:#000000;"> <div style="font-family:Arial, sans-serif;font-size:16px;line-height:1.4;text-align:{align};color:#000000;">
<div>{row.data.1 -> f:format.nl2br() -> f:format.raw()}</div> <div>{row.data.1 -> f:format.nl2br() -> f:format.raw()}</div>
</div> </div>
</td> </td>