summaryrefslogtreecommitdiffstats
path: root/lib/private/Mail/EMailTemplate.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Mail/EMailTemplate.php')
-rw-r--r--lib/private/Mail/EMailTemplate.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php
index 2c8efa7e010..054378c2afa 100644
--- a/lib/private/Mail/EMailTemplate.php
+++ b/lib/private/Mail/EMailTemplate.php
@@ -450,14 +450,16 @@ EOF;
* if empty 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 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 addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '') {
+ public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '', $plainIndent = 0) {
$this->ensureBodyListOpened();
if ($plainText === '') {
$plainText = $text;
$text = htmlspecialchars($text);
+ $text = str_replace("\n", "<br/>", $text); // convert newlines to HTML breaks
}
if ($plainMetaInfo === '') {
$plainMetaInfo = $metaInfo;
@@ -475,11 +477,27 @@ EOF;
}
$this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);
if ($plainText !== false) {
- $this->plainBody .= ' * ' . $plainText;
- if ($plainMetaInfo !== false) {
- $this->plainBody .= ' (' . $plainMetaInfo . ')';
+ 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
+ */
+ $this->plainBody .= sprintf("%${plainIndent}s %s\n",
+ $plainMetaInfo,
+ str_replace("\n", "\n" . str_repeat(' ', $plainIndent+1), $plainText));
}
- $this->plainBody .= PHP_EOL;
}
}
@@ -538,7 +556,7 @@ EOF;
$textColor = $this->themingDefaults->getTextColorPrimary();
$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);
- $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
+ $this->plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
$this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
}