From: Tim Düsterhus Date: Wed, 8 Jul 2015 21:21:15 +0000 (+0200) Subject: Add emailTextPlain.tpl X-Git-Tag: 3.0.0_Beta_1~2173^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1cbb15994d29e975445660e48645d966da2eb63f;p=GitHub%2FWoltLab%2FWCF.git Add emailTextPlain.tpl --- diff --git a/com.woltlab.wcf/templates/emailTextPlain.tpl b/com.woltlab.wcf/templates/emailTextPlain.tpl new file mode 100644 index 0000000000..ed60beab94 --- /dev/null +++ b/com.woltlab.wcf/templates/emailTextPlain.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/Email.class.php b/wcfsetup/install/files/lib/system/email/Email.class.php index 5a36a8bd43..84ec7324e8 100644 --- a/wcfsetup/install/files/lib/system/email/Email.class.php +++ b/wcfsetup/install/files/lib/system/email/Email.class.php @@ -581,8 +581,6 @@ class Email { $body .= $text; } - // TODO: Where to put the email signature? - return $body; } diff --git a/wcfsetup/install/files/lib/system/email/mime/AbstractRecipientAwareTextMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/AbstractRecipientAwareTextMimePart.class.php new file mode 100644 index 0000000000..f2df88e504 --- /dev/null +++ b/wcfsetup/install/files/lib/system/email/mime/AbstractRecipientAwareTextMimePart.class.php @@ -0,0 +1,68 @@ + + * @package com.woltlab.wcf + * @subpackage system.email.mime + * @category Community Framework + */ +abstract class AbstractRecipientAwareTextMimePart extends TextMimePart implements IRecipientAwareMimePart { + /** + * template to use for this email + * @var string + */ + protected $template = ''; + + /** + * application of this template + * @var string + */ + protected $application = 'wcf'; + + /** + * the recipient of the email containing this mime part + * @var \wcf\system\email\Mailbox + */ + protected $mailbox = null; + + /** + * @see \wcf\system\email\mime\IRecipientAwareMimePart::setRecipient() + */ + public function setRecipient(Mailbox $mailbox = null) { + $this->mailbox = $mailbox; + } + + /** + * @see \wcf\system\email\mime\AbstractMimePart::getContent() + */ + public function getContent() { + $language = WCF::getLanguage(); + + try { + if ($this->mailbox instanceof UserMailbox) { + WCF::setLanguage($this->mailbox->getUser()->getLanguage()->languageID); + } + + return WCF::getTPL()->fetch($this->template, $this->application, [ + 'content' => $this->content, + 'mailbox' => $this->mailbox + ], true); + } + finally { + WCF::setLanguage($language->languageID); + } + } +} diff --git a/wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php new file mode 100644 index 0000000000..226947ed65 --- /dev/null +++ b/wcfsetup/install/files/lib/system/email/mime/PlainTextMimePart.class.php @@ -0,0 +1,32 @@ + + * @package com.woltlab.wcf + * @subpackage system.email.mime + * @category Community Framework + */ +class PlainTextMimePart extends AbstractRecipientAwareTextMimePart { + /** + * template to use for this email + * @var string + */ + protected $template = 'emailTextPlain'; + + /** + * Creates a new PlainTextMimePart. + * + * @param string $content Content of this text part. + */ + public function __construct($content) { + parent::__construct($content, 'text/plain'); + } +}