Allow meta info and icons

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-04-25 14:31:21 +02:00
parent 35414884d3
commit f1ffb728b9
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 32 additions and 8 deletions

View File

@ -187,10 +187,10 @@ EOF;
protected $listItem = <<<EOF protected $listItem = <<<EOF
<tr style="padding:0;text-align:left;vertical-align:top"> <tr style="padding:0;text-align:left;vertical-align:top">
<td style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;width:15px;"> <td style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;width:15px;">
<p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;padding-left:10px;text-align:left">&bull;</p> <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;padding-left:10px;text-align:left">%s</p>
</td> </td>
<td style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> <td style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
<p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;padding-left:10px;text-align:left">%s</p> <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#555;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;padding-left:10px;text-align:left">%s</p>
</td> </td>
<td class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></td> <td class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></td>
</tr> </tr>
@ -421,20 +421,40 @@ EOF;
* Adds a list item to the body of the email * Adds a list item to the body of the email
* *
* @param string $text * @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 * @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 * @since 12.0.0
*/ */
public function addBodyListItem($text, $plainText = '') { public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') {
$this->ensureBodyListOpened(); $this->ensureBodyListOpened();
if ($plainText === '') { if ($plainText === '') {
$plainText = $text; $plainText = $text;
} }
if ($plainMetaInfo === '') {
$plainMetaInfo = $metaInfo;
}
$this->htmlBody .= vsprintf($this->listItem, [htmlspecialchars($text)]); $htmlText = htmlspecialchars($text);
if ($metaInfo) {
$htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText;
}
if ($icon !== '') {
$icon = '<img src="' . htmlspecialchars($icon) . '" alt="&bull;">';
} else {
$icon = '&bull;';
}
$this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);
if ($plainText !== false) { if ($plainText !== false) {
$this->plainBody .= ' * ' . $plainText . PHP_EOL; $this->plainBody .= ' * ' . $plainText;
if ($plainMetaInfo !== false) {
$this->plainBody .= ' (' . $plainMetaInfo . ')';
}
$this->plainBody .= PHP_EOL;
} }
} }

View File

@ -84,11 +84,15 @@ interface IEMailTemplate {
* Adds a list item to the body of the email * Adds a list item to the body of the email
* *
* @param string $text * @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 * @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 * @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 * Adds a button group of two buttons to the body of the email