From 329de2771e40fe7550d4453375a6de7943a3857d Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Fri, 9 Dec 2022 01:42:02 +0100 Subject: [PATCH 1/3] [TASK] Mail: Add hr, right aligned table, debugging output --- Classes/Utility/MailUtility.php | 21 ++++++++++++++++++ .../Private/Partials/Mails/DefaultHtml.html | 22 ++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Classes/Utility/MailUtility.php b/Classes/Utility/MailUtility.php index 48149b2..79293dd 100644 --- a/Classes/Utility/MailUtility.php +++ b/Classes/Utility/MailUtility.php @@ -223,6 +223,7 @@ class MailUtility switch($row['type']) { case 'text': case 'table': + case 'tablelr': case 'tableLayout': case 'list': case 'textbold': @@ -233,6 +234,7 @@ class MailUtility case 'buttonleft': case 'buttoncenter': case 'buttonright': + case 'hr': $row['data'] = str_replace( "\\\n", '', @@ -457,4 +459,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); + } + } diff --git a/Resources/Private/Partials/Mails/DefaultHtml.html b/Resources/Private/Partials/Mails/DefaultHtml.html index a704f4d..94da85e 100644 --- a/Resources/Private/Partials/Mails/DefaultHtml.html +++ b/Resources/Private/Partials/Mails/DefaultHtml.html @@ -30,6 +30,7 @@ || {row.type} == 'buttonleft' || {row.type} == 'buttoncenter' || {row.type} == 'buttonright' + || {row.type} == 'hr' "> -
+ + + + + + + + +
- From 0f3e88ac961fbffa82f2bb3d34e5df495b8c22c4 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Fri, 4 Aug 2023 14:11:20 +0200 Subject: [PATCH 2/3] [BUGFIX] Fix hr layout in outlook --- .../Private/Partials/Mails/DefaultHtml.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Resources/Private/Partials/Mails/DefaultHtml.html b/Resources/Private/Partials/Mails/DefaultHtml.html index 94da85e..d3c4520 100644 --- a/Resources/Private/Partials/Mails/DefaultHtml.html +++ b/Resources/Private/Partials/Mails/DefaultHtml.html @@ -105,6 +105,25 @@

+

{row.data -> f:format.nl2br() -> f:format.raw()}

From 869b3df73845a72779fdb3601e8aeeebbf3544d9 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Fri, 8 Dec 2023 11:41:35 +0100 Subject: [PATCH 3/3] [FEATURE] Add contentBlockHtml and diver to mail utility --- Classes/Utility/MailUtility.php | 83 ++----------------- .../Private/Partials/Mails/DefaultHtml.html | 23 ++++- 2 files changed, 31 insertions(+), 75 deletions(-) diff --git a/Classes/Utility/MailUtility.php b/Classes/Utility/MailUtility.php index 48149b2..abb1ae7 100644 --- a/Classes/Utility/MailUtility.php +++ b/Classes/Utility/MailUtility.php @@ -79,6 +79,10 @@ class MailUtility $type = 'tableLayout'; $textPart = substr($textPart, 3); } + if (substr($textPart, 0, 3) === '---') { + $type = 'divider'; + $textPart = substr($textPart, 3); + } if (substr($textPart, 0, 9) === '%subject ') { $type = 'subject'; $textPart = substr($textPart, 9); @@ -233,6 +237,7 @@ class MailUtility case 'buttonleft': case 'buttoncenter': case 'buttonright': + case 'divider': $row['data'] = str_replace( "\\\n", '', @@ -308,77 +313,10 @@ class MailUtility $bodydataText[] = $textRow; $bodydataHtml[] = $htmlRow; break; - //case 'button': - // $row['data'] = str_replace( - // "\\\n", - // '', - // $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 '' - // . $matchesInner[2] - // . ''; - // }, - // $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 '' - // . substr($match, 1, -1) - // . ''; - // } - // }, - // $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 'contentBlockHtml': + $htmlRow = $row; + $bodydataHtml[] = $htmlRow; + break; case 'attachment': $mail->attach(new \Swift_Attachment( $row['data'][0], @@ -402,9 +340,6 @@ class MailUtility } $textView->assign('content', $bodydataText); $htmlView->assign('content', $bodydataHtml); - //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump( - // $bodydataHtml, null, 8, true, false - //); $domain = $settings['mailDomain']; if ($assetDomain) { $domain = $assetDomain; diff --git a/Resources/Private/Partials/Mails/DefaultHtml.html b/Resources/Private/Partials/Mails/DefaultHtml.html index a704f4d..4e50b64 100644 --- a/Resources/Private/Partials/Mails/DefaultHtml.html +++ b/Resources/Private/Partials/Mails/DefaultHtml.html @@ -24,12 +24,16 @@ + + {row.data -> f:format.raw()} + +

{row.data -> f:format.nl2br() -> f:format.raw()}

-
+
+
{row.data.1 -> f:format.nl2br() -> f:format.raw()}