From b2b82588f2712c4d0390525732b92f5066273ffa Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 22 Jul 2017 21:49:48 +1000 Subject: [PATCH] Implement CSS to inline styles Refit system layout --- modules/system/classes/MailManager.php | 9 +++- modules/system/views/mail/layout-default.htm | 2 +- modules/system/views/mail/layout-system.htm | 52 +++++++++++++++----- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/modules/system/classes/MailManager.php b/modules/system/classes/MailManager.php index ff21d5231..ce15600eb 100644 --- a/modules/system/classes/MailManager.php +++ b/modules/system/classes/MailManager.php @@ -11,6 +11,7 @@ use System\Classes\PluginManager; use System\Classes\MarkupManager; use System\Twig\MailPartialTokenParser; use System\Twig\MailComponentTokenParser; +use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles; /** * This class manages Mail sending functions @@ -147,14 +148,20 @@ class MailManager $html = $this->render($template->content_html, $data); + $css = MailBrandSetting::renderCss(); + if ($template->layout) { $html = $this->renderTwig($template->layout->content_html, [ 'content' => $html, 'css' => $template->layout->content_css, - 'brandCss' => MailBrandSetting::renderCss() + 'brandCss' => $css ] + (array) $data); + + $css += PHP_EOL . $template->layout->content_css; } + $html = (new CssToInlineStyles)->convert($html, $css); + return $html; } diff --git a/modules/system/views/mail/layout-default.htm b/modules/system/views/mail/layout-default.htm index 96fe5ac5f..a6549550d 100644 --- a/modules/system/views/mail/layout-default.htm +++ b/modules/system/views/mail/layout-default.htm @@ -43,7 +43,7 @@ name = "Default layout" {% component 'footer' %} - © 2017 {{ appName }}. All rights reserved. + © {{ "now"|date("Y") }} {{ appName }}. All rights reserved. {% endcomponent %} diff --git a/modules/system/views/mail/layout-system.htm b/modules/system/views/mail/layout-system.htm index 8637d8abd..6ef0596a6 100644 --- a/modules/system/views/mail/layout-system.htm +++ b/modules/system/views/mail/layout-system.htm @@ -6,16 +6,44 @@ name = "System layout" --- This is an automatic message. Please do not reply to it. == - - - - - - {{ content|raw }} -
-

This is an automatic message. Please do not reply to it.

- + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ {{ content|raw }} + + + {% component 'subcopy' %} + **This is an automatic message. Please do not reply to it.** + {% endcomponent %} +
+
+
+ +