From f1ffb728b9908e4981e6d7cf0fc7b4742ffbd880 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 25 Apr 2017 14:31:21 +0200 Subject: [PATCH] Allow meta info and icons Signed-off-by: Joas Schilling --- lib/private/Mail/EMailTemplate.php | 32 ++++++++++++++++++++++++------ lib/public/Mail/IEMailTemplate.php | 8 ++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index fa76a21546..3442e8e943 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -187,10 +187,10 @@ EOF; protected $listItem = << -

+

%s

-

%s

+

%s

@@ -421,20 +421,40 @@ EOF; * Adds a list item to the body of the email * * @param string $text + * @param string $metaInfo + * @param string $icon Absolute path, must be 16*16 pixels * @param string $plainText Text that is used in the plain text email - * if empty the $text is used + * if empty the $text is used, if false none will be used + * @param string $plainMetaInfo Meta info that is used in the plain text email + * if empty the $metaInfo is used, if false none will be used * @since 12.0.0 */ - public function addBodyListItem($text, $plainText = '') { + public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') { $this->ensureBodyListOpened(); if ($plainText === '') { $plainText = $text; } + if ($plainMetaInfo === '') { + $plainMetaInfo = $metaInfo; + } - $this->htmlBody .= vsprintf($this->listItem, [htmlspecialchars($text)]); + $htmlText = htmlspecialchars($text); + if ($metaInfo) { + $htmlText = '' . htmlspecialchars($metaInfo) . '
' . $htmlText; + } + if ($icon !== '') { + $icon = '•'; + } else { + $icon = '•'; + } + $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); if ($plainText !== false) { - $this->plainBody .= ' * ' . $plainText . PHP_EOL; + $this->plainBody .= ' * ' . $plainText; + if ($plainMetaInfo !== false) { + $this->plainBody .= ' (' . $plainMetaInfo . ')'; + } + $this->plainBody .= PHP_EOL; } } diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index d4010618b1..6df83b4d10 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -84,11 +84,15 @@ interface IEMailTemplate { * Adds a list item to the body of the email * * @param string $text + * @param string $metaInfo + * @param string $icon Absolute path, must be 16*16 pixels * @param string $plainText Text that is used in the plain text email - * if empty the $text is used + * if empty the $text is used, if false none will be used + * @param string $plainMetaInfo Meta info that is used in the plain text email + * if empty the $metaInfo is used, if false none will be used * @since 12.0.0 */ - public function addBodyListItem($text, $plainText = ''); + public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = ''); /** * Adds a button group of two buttons to the body of the email