Loading lib/Mail/EMailTemplate.php +62 −0 Original line number Diff line number Diff line Loading @@ -191,7 +191,69 @@ EOF; } } } /** * Adds a list item to the body of the email * * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email * @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email * @param string $icon Absolute path, must be 16*16 pixels * @param string|bool $plainText Text that is used in the plain text email * if empty or true the $text is used, if false none will be used * @param string|bool $plainMetaInfo Meta info that is used in the plain text email * if empty or true the $metaInfo is used, if false none will be used * @param integer plainIndent If > 0, Indent plainText by this amount. * @since 12.0.0 */ public function addBodyListItemModified(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '', $plainIndent = 0) { $this->ensureBodyListOpened(); if ($plainText === '' || $plainText === true) { $plainText = $text; $text = htmlspecialchars($text); $text = str_replace("\n", "<br/>", $text); // convert newlines to HTML breaks } if ($plainMetaInfo === '' || $plainMetaInfo === true) { $plainMetaInfo = $metaInfo; $metaInfo = htmlspecialchars($metaInfo); } $htmlText = $text; if ($metaInfo) { $htmlText = '<span style="color:#6CA91C;font-weight:700;">' . $metaInfo . ' </span> '. $htmlText; } if ($icon !== '') { $icon = '<img style="padding-top: 3px;" src="' . htmlspecialchars($icon) . '" alt="•">'; } else { $icon = '•'; } $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); if ($plainText !== false) { if ($plainIndent === 0) { /* * If plainIndent is not set by caller, this is the old NC17 layout code. */ $this->plainBody .= ' * ' . $plainText; if ($plainMetaInfo !== false) { $this->plainBody .= ' (' . $plainMetaInfo . ')'; } $this->plainBody .= PHP_EOL; } else { /* * Caller can set plainIndent > 0 to format plainText in tabular fashion. * with plainMetaInfo in column 1, and plainText in column 2. * The plainMetaInfo label is right justified in a field of width * "plainIndent". Multilines after the first are indented plainIndent+1 * (to account for space after label). Fixes: #12391 */ /** @var string $label */ $label = ($plainMetaInfo !== false)? $plainMetaInfo : ''; $this->plainBody .= sprintf("%${plainIndent}s %s\n", $label, str_replace("\n", "\n" . str_repeat(' ', $plainIndent + 1), $plainText)); } } } /** * Adds a paragraph to the body of the email * Loading Loading
lib/Mail/EMailTemplate.php +62 −0 Original line number Diff line number Diff line Loading @@ -191,7 +191,69 @@ EOF; } } } /** * Adds a list item to the body of the email * * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email * @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email * @param string $icon Absolute path, must be 16*16 pixels * @param string|bool $plainText Text that is used in the plain text email * if empty or true the $text is used, if false none will be used * @param string|bool $plainMetaInfo Meta info that is used in the plain text email * if empty or true the $metaInfo is used, if false none will be used * @param integer plainIndent If > 0, Indent plainText by this amount. * @since 12.0.0 */ public function addBodyListItemModified(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '', $plainIndent = 0) { $this->ensureBodyListOpened(); if ($plainText === '' || $plainText === true) { $plainText = $text; $text = htmlspecialchars($text); $text = str_replace("\n", "<br/>", $text); // convert newlines to HTML breaks } if ($plainMetaInfo === '' || $plainMetaInfo === true) { $plainMetaInfo = $metaInfo; $metaInfo = htmlspecialchars($metaInfo); } $htmlText = $text; if ($metaInfo) { $htmlText = '<span style="color:#6CA91C;font-weight:700;">' . $metaInfo . ' </span> '. $htmlText; } if ($icon !== '') { $icon = '<img style="padding-top: 3px;" src="' . htmlspecialchars($icon) . '" alt="•">'; } else { $icon = '•'; } $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); if ($plainText !== false) { if ($plainIndent === 0) { /* * If plainIndent is not set by caller, this is the old NC17 layout code. */ $this->plainBody .= ' * ' . $plainText; if ($plainMetaInfo !== false) { $this->plainBody .= ' (' . $plainMetaInfo . ')'; } $this->plainBody .= PHP_EOL; } else { /* * Caller can set plainIndent > 0 to format plainText in tabular fashion. * with plainMetaInfo in column 1, and plainText in column 2. * The plainMetaInfo label is right justified in a field of width * "plainIndent". Multilines after the first are indented plainIndent+1 * (to account for space after label). Fixes: #12391 */ /** @var string $label */ $label = ($plainMetaInfo !== false)? $plainMetaInfo : ''; $this->plainBody .= sprintf("%${plainIndent}s %s\n", $label, str_replace("\n", "\n" . str_repeat(' ', $plainIndent + 1), $plainText)); } } } /** * Adds a paragraph to the body of the email * Loading