From: Tim Düsterhus Date: Wed, 1 Jun 2016 22:23:50 +0000 (+0200) Subject: Split email.tpl into email_html.tpl and email_plaintext.tpl X-Git-Tag: 3.0.0_Beta_1~916^2~14 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4f0caad246e4413bee98ef9c4e0189d144147435;p=GitHub%2FWoltLab%2FWCF.git Split email.tpl into email_html.tpl and email_plaintext.tpl --- diff --git a/com.woltlab.wcf/templates/email.tpl b/com.woltlab.wcf/templates/email.tpl deleted file mode 100644 index a9ab2676e0..0000000000 --- a/com.woltlab.wcf/templates/email.tpl +++ /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'} - - -
- -{if $__wcf->getStyleHandler()->getStyle()->getPageLogo()}{/if} -{event name='headerLogo'} - -
-
{@$content}
-{hascontent} -
---
-{content} -{@MAIL_SIGNATURE|language} -{if $mailbox|is_a:'wcf\system\email\UserMailbox'} -{if MAIL_SIGNATURE|language}

{/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} - - -{/if} diff --git a/com.woltlab.wcf/templates/email_html.tpl b/com.woltlab.wcf/templates/email_html.tpl new file mode 100644 index 0000000000..796328871f --- /dev/null +++ b/com.woltlab.wcf/templates/email_html.tpl @@ -0,0 +1,26 @@ + + +
+ + {if $__wcf->getStyleHandler()->getStyle()->getPageLogo()} + + {/if} + {event name='headerLogo'} + +
+
{@$content}
+ {hascontent} +
+ --
+ {content} + {@MAIL_SIGNATURE|language} + {if $mailbox|is_a:'wcf\system\email\UserMailbox'} + {if MAIL_SIGNATURE|language}

{/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} + + {* Do not remove: This table is needed by certain less able email clients to properly support background colors. Don't ask. *}
+ + diff --git a/com.woltlab.wcf/templates/email_plaintext.tpl b/com.woltlab.wcf/templates/email_plaintext.tpl new file mode 100644 index 0000000000..ea467f66b6 --- /dev/null +++ b/com.woltlab.wcf/templates/email_plaintext.tpl @@ -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} diff --git a/wcfsetup/install/files/lib/system/email/mime/HtmlTextMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/HtmlTextMimePart.class.php index d7f26ce4a4..bfaabad003 100644 --- a/wcfsetup/install/files/lib/system/email/mime/HtmlTextMimePart.class.php +++ b/wcfsetup/install/files/lib/system/email/mime/HtmlTextMimePart.class.php @@ -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'); } } diff --git a/wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php index 5eea4aa606..3e3ba8494c 100644 --- a/wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php +++ b/wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php @@ -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'); } } diff --git a/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php index aac3c6c78f..14c4d7fbc9 100644 --- a/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php +++ b/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php @@ -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 + ]; + } }