Split email.tpl into email_html.tpl and email_plaintext.tpl
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 1 Jun 2016 22:23:50 +0000 (00:23 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 28 Jul 2016 20:06:18 +0000 (22:06 +0200)
com.woltlab.wcf/templates/email.tpl [deleted file]
com.woltlab.wcf/templates/email_html.tpl [new file with mode: 0644]
com.woltlab.wcf/templates/email_plaintext.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/system/email/mime/HtmlTextMimePart.class.php
wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php
wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php

diff --git a/com.woltlab.wcf/templates/email.tpl b/com.woltlab.wcf/templates/email.tpl
deleted file mode 100644 (file)
index a9ab267..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-{if $mimeType === 'text/plain'}
-{@$content}
-{hascontent}
-
--- {* The Space is important, do not remove *}
-{content}
-{@MAIL_SIGNATURE|language}
-{if $mailbox|is_a:'wcf\system\email\UserMailbox'}{if MAIL_SIGNATURE|language}{* add newlines *}
-
-
-{/if}This email was sent to you, because you registered on
-the {$mailbox->getUser()->registrationDate|plainTime} at {@PAGE_TITLE|language}.{/if} {* TODO: language item *}
-{/content}
-{/hascontent}
-
-{elseif $mimeType === 'text/html'}
-<html>
-<body>
-<div style="text-align: center;">
-<a href="{link}{/link}">
-{if $__wcf->getStyleHandler()->getStyle()->getPageLogo()}<img src="{$__wcf->getStyleHandler()->getStyle()->getPageLogo()}" alt="">{/if}
-{event name='headerLogo'}
-</a>
-</div>
-<div class="content">{@$content}</div>
-{hascontent}
-<div class="signature" style="color: grey; font-size: 10px;">
--- <br>
-{content}
-{@MAIL_SIGNATURE|language}
-{if $mailbox|is_a:'wcf\system\email\UserMailbox'}
-{if MAIL_SIGNATURE|language}<br><br>{/if}
-This email was sent to you, because you registered on the {$mailbox->getUser()->registrationDate|plainTime} at {@PAGE_TITLE|language}.{/if} {* TODO: language item *}
-{/content}
-</div>
-{/hascontent}
-</body>
-</html>
-{/if}
diff --git a/com.woltlab.wcf/templates/email_html.tpl b/com.woltlab.wcf/templates/email_html.tpl
new file mode 100644 (file)
index 0000000..7963288
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+       <body>
+       <div style="text-align: center;">
+               <a href="{link}{/link}">
+                       {if $__wcf->getStyleHandler()->getStyle()->getPageLogo()}
+                               <img src="{$__wcf->getStyleHandler()->getStyle()->getPageLogo()}" alt="">
+                       {/if}
+                       {event name='headerLogo'}
+               </a>
+       </div>
+       <div class="content">{@$content}</div>
+       {hascontent}
+       <div class="signature" style="color: grey; font-size: 10px;">
+       -- <br>
+       {content}
+       {@MAIL_SIGNATURE|language}
+       {if $mailbox|is_a:'wcf\system\email\UserMailbox'}
+       {if MAIL_SIGNATURE|language}<br><br>{/if}
+       This email was sent to you, because you registered on the {$mailbox->getUser()->registrationDate|plainTime} at {@PAGE_TITLE|language}.{/if} {* TODO: language item *}
+       {/content}
+       </div>
+       {/hascontent}
+       
+       <table>{* Do not remove: This table is needed by certain less able email clients to properly support background colors. Don't ask. *}</table>
+       </body>
+</html>
diff --git a/com.woltlab.wcf/templates/email_plaintext.tpl b/com.woltlab.wcf/templates/email_plaintext.tpl
new file mode 100644 (file)
index 0000000..ea467f6
--- /dev/null
@@ -0,0 +1,13 @@
+{@$content}
+{hascontent}
+
+-- {* The Space is important, do not remove *}
+{content}
+{@MAIL_SIGNATURE|language}
+{if $mailbox|is_a:'wcf\system\email\UserMailbox'}{if MAIL_SIGNATURE|language}{* add newlines *}
+
+
+{/if}This email was sent to you, because you registered on
+the {$mailbox->getUser()->registrationDate|plainTime} at {@PAGE_TITLE|language}.{/if} {* TODO: language item *}
+{/content}
+{/hascontent}
index d7f26ce4a4eb5b33a5f8f040884da26229b22f54..bfaabad003658fd4508850e89076327631bfc2f9 100644 (file)
@@ -17,6 +17,6 @@ class HtmlTextMimePart extends RecipientAwareTextMimePart {
         * @param       string  $content        Content of this text part.
         */
        public function __construct($content) {
-               parent::__construct($content, 'text/html', 'email');
+               parent::__construct($content, 'text/html', 'email_html');
        }
 }
index 5eea4aa6064b17c021da8887ca05b611c42e3547..3e3ba8494c633ca7769e5269d6dd187d133fcedc 100644 (file)
@@ -17,6 +17,6 @@ class PlainTextMimePart extends RecipientAwareTextMimePart {
         * @param       string  $content        Content of this text part.
         */
        public function __construct($content) {
-               parent::__construct($content, 'text/plain', 'email');
+               parent::__construct($content, 'text/plain', 'email_plaintext');
        }
 }
index aac3c6c78f4b8922ec92dc76e6e31f293cf0bade..14c4d7fbc90be6fc1536f49a5754ae323d8fe7c0 100644 (file)
@@ -67,14 +67,23 @@ class RecipientAwareTextMimePart extends TextMimePart implements IRecipientAware
                try {
                        if ($this->mailbox) WCF::setLanguage($this->mailbox->getLanguage()->languageID);
                        
-                       return EmailTemplateEngine::getInstance()->fetch($this->template, $this->application, [
-                               'content' => $this->content,
-                               'mimeType' => $this->mimeType,
-                               'mailbox' => $this->mailbox
-                       ], true);
+                       return EmailTemplateEngine::getInstance()->fetch($this->template, $this->application, $this->getTemplateVariables(), true);
                }
                finally {
                        WCF::setLanguage($language->languageID);
                }
        }
+       
+       /**
+        * Returns the templates variables to be passed to the EmailTemplateEngine.
+        * 
+        * @return      mixed[]
+        */
+       protected function getTemplateVariables() {
+               return [
+                       'content' => $this->content,
+                       'mimeType' => $this->mimeType,
+                       'mailbox' => $this->mailbox
+               ];
+       }
 }