@@ -42,33 +42,33 @@ discard block  | 
                                                    ||
| 42 | 42 | * @package OC\Mail  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | 44 |  class EMailTemplate implements IEMailTemplate { | 
                                                        
| 45 | - /** @var Defaults */  | 
                                                        |
| 46 | - protected $themingDefaults;  | 
                                                        |
| 47 | - /** @var IURLGenerator */  | 
                                                        |
| 48 | - protected $urlGenerator;  | 
                                                        |
| 49 | - /** @var IL10N */  | 
                                                        |
| 50 | - protected $l10n;  | 
                                                        |
| 51 | - /** @var string */  | 
                                                        |
| 52 | - protected $emailId;  | 
                                                        |
| 53 | - /** @var array */  | 
                                                        |
| 54 | - protected $data;  | 
                                                        |
| 55 | -  | 
                                                        |
| 56 | - /** @var string */  | 
                                                        |
| 57 | - protected $subject = '';  | 
                                                        |
| 58 | - /** @var string */  | 
                                                        |
| 59 | - protected $htmlBody = '';  | 
                                                        |
| 60 | - /** @var string */  | 
                                                        |
| 61 | - protected $plainBody = '';  | 
                                                        |
| 62 | - /** @var bool indicated if the footer is added */  | 
                                                        |
| 63 | - protected $headerAdded = false;  | 
                                                        |
| 64 | - /** @var bool indicated if the body is already opened */  | 
                                                        |
| 65 | - protected $bodyOpened = false;  | 
                                                        |
| 66 | - /** @var bool indicated if there is a list open in the body */  | 
                                                        |
| 67 | - protected $bodyListOpened = false;  | 
                                                        |
| 68 | - /** @var bool indicated if the footer is added */  | 
                                                        |
| 69 | - protected $footerAdded = false;  | 
                                                        |
| 70 | -  | 
                                                        |
| 71 | - protected $head = <<<EOF  | 
                                                        |
| 45 | + /** @var Defaults */  | 
                                                        |
| 46 | + protected $themingDefaults;  | 
                                                        |
| 47 | + /** @var IURLGenerator */  | 
                                                        |
| 48 | + protected $urlGenerator;  | 
                                                        |
| 49 | + /** @var IL10N */  | 
                                                        |
| 50 | + protected $l10n;  | 
                                                        |
| 51 | + /** @var string */  | 
                                                        |
| 52 | + protected $emailId;  | 
                                                        |
| 53 | + /** @var array */  | 
                                                        |
| 54 | + protected $data;  | 
                                                        |
| 55 | +  | 
                                                        |
| 56 | + /** @var string */  | 
                                                        |
| 57 | + protected $subject = '';  | 
                                                        |
| 58 | + /** @var string */  | 
                                                        |
| 59 | + protected $htmlBody = '';  | 
                                                        |
| 60 | + /** @var string */  | 
                                                        |
| 61 | + protected $plainBody = '';  | 
                                                        |
| 62 | + /** @var bool indicated if the footer is added */  | 
                                                        |
| 63 | + protected $headerAdded = false;  | 
                                                        |
| 64 | + /** @var bool indicated if the body is already opened */  | 
                                                        |
| 65 | + protected $bodyOpened = false;  | 
                                                        |
| 66 | + /** @var bool indicated if there is a list open in the body */  | 
                                                        |
| 67 | + protected $bodyListOpened = false;  | 
                                                        |
| 68 | + /** @var bool indicated if the footer is added */  | 
                                                        |
| 69 | + protected $footerAdded = false;  | 
                                                        |
| 70 | +  | 
                                                        |
| 71 | + protected $head = <<<EOF  | 
                                                        |
| 72 | 72 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  | 
                                                        
| 73 | 73 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#f3f3f3!important">  | 
                                                        
| 74 | 74 | <head>  | 
                                                        
@@ -86,7 +86,7 @@ discard block  | 
                                                    ||
| 86 | 86 | <center data-parsed="" style="min-width:580px;width:100%">  | 
                                                        
| 87 | 87 | EOF;  | 
                                                        
| 88 | 88 | |
| 89 | - protected $tail = <<<EOF  | 
                                                        |
| 89 | + protected $tail = <<<EOF  | 
                                                        |
| 90 | 90 | </center>  | 
                                                        
| 91 | 91 | </td>  | 
                                                        
| 92 | 92 | </tr>  | 
                                                        
@@ -97,7 +97,7 @@ discard block  | 
                                                    ||
| 97 | 97 | </html>  | 
                                                        
| 98 | 98 | EOF;  | 
                                                        
| 99 | 99 | |
| 100 | - protected $header = <<<EOF  | 
                                                        |
| 100 | + protected $header = <<<EOF  | 
                                                        |
| 101 | 101 | <table align="center" class="wrapper header float-center" style="Margin:0 auto;background:#8a8a8a;background-color:%s;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%%">  | 
                                                        
| 102 | 102 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
| 103 | 103 | <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:20px;text-align:left;vertical-align:top;word-wrap:break-word">  | 
                                                        
@@ -130,7 +130,7 @@ discard block  | 
                                                    ||
| 130 | 130 | </table>  | 
                                                        
| 131 | 131 | EOF;  | 
                                                        
| 132 | 132 | |
| 133 | - protected $heading = <<<EOF  | 
                                                        |
| 133 | + protected $heading = <<<EOF  | 
                                                        |
| 134 | 134 | <table align="center" class="container main-heading float-center" style="Margin:0 auto;background:0 0!important;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px">  | 
                                                        
| 135 | 135 | <tbody>  | 
                                                        
| 136 | 136 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
@@ -149,7 +149,7 @@ discard block  | 
                                                    ||
| 149 | 149 | </table>  | 
                                                        
| 150 | 150 | EOF;  | 
                                                        
| 151 | 151 | |
| 152 | - protected $bodyBegin = <<<EOF  | 
                                                        |
| 152 | + protected $bodyBegin = <<<EOF  | 
                                                        |
| 153 | 153 | <table align="center" class="wrapper content float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">  | 
                                                        
| 154 | 154 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
| 155 | 155 | <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">  | 
                                                        
@@ -166,7 +166,7 @@ discard block  | 
                                                    ||
| 166 | 166 | </table>  | 
                                                        
| 167 | 167 | EOF;  | 
                                                        
| 168 | 168 | |
| 169 | - protected $bodyText = <<<EOF  | 
                                                        |
| 169 | + protected $bodyText = <<<EOF  | 
                                                        |
| 170 | 170 | <table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%%">  | 
                                                        
| 171 | 171 | <tbody>  | 
                                                        
| 172 | 172 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
@@ -185,8 +185,8 @@ discard block  | 
                                                    ||
| 185 | 185 | </table>  | 
                                                        
| 186 | 186 | EOF;  | 
                                                        
| 187 | 187 | |
| 188 | - // note: listBegin (like bodyBegin) is not processed through sprintf, so "%" is not escaped as "%%". (bug #12151)  | 
                                                        |
| 189 | - protected $listBegin = <<<EOF  | 
                                                        |
| 188 | + // note: listBegin (like bodyBegin) is not processed through sprintf, so "%" is not escaped as "%%". (bug #12151)  | 
                                                        |
| 189 | + protected $listBegin = <<<EOF  | 
                                                        |
| 190 | 190 | <table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">  | 
                                                        
| 191 | 191 | <tbody>  | 
                                                        
| 192 | 192 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
@@ -194,7 +194,7 @@ discard block  | 
                                                    ||
| 194 | 194 | <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">  | 
                                                        
| 195 | 195 | EOF;  | 
                                                        
| 196 | 196 | |
| 197 | - protected $listItem = <<<EOF  | 
                                                        |
| 197 | + protected $listItem = <<<EOF  | 
                                                        |
| 198 | 198 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
| 199 | 199 | <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;">  | 
                                                        
| 200 | 200 | <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>  | 
                                                        
@@ -206,7 +206,7 @@ discard block  | 
                                                    ||
| 206 | 206 | </tr>  | 
                                                        
| 207 | 207 | EOF;  | 
                                                        
| 208 | 208 | |
| 209 | - protected $listEnd = <<<EOF  | 
                                                        |
| 209 | + protected $listEnd = <<<EOF  | 
                                                        |
| 210 | 210 | </table>  | 
                                                        
| 211 | 211 | </th>  | 
                                                        
| 212 | 212 | </tr>  | 
                                                        
@@ -214,7 +214,7 @@ discard block  | 
                                                    ||
| 214 | 214 | </table>  | 
                                                        
| 215 | 215 | EOF;  | 
                                                        
| 216 | 216 | |
| 217 | - protected $buttonGroup = <<<EOF  | 
                                                        |
| 217 | + protected $buttonGroup = <<<EOF  | 
                                                        |
| 218 | 218 | <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">  | 
                                                        
| 219 | 219 | <tbody>  | 
                                                        
| 220 | 220 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
@@ -267,7 +267,7 @@ discard block  | 
                                                    ||
| 267 | 267 | </table>  | 
                                                        
| 268 | 268 | EOF;  | 
                                                        
| 269 | 269 | |
| 270 | - protected $button = <<<EOF  | 
                                                        |
| 270 | + protected $button = <<<EOF  | 
                                                        |
| 271 | 271 | <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">  | 
                                                        
| 272 | 272 | <tbody>  | 
                                                        
| 273 | 273 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
@@ -307,7 +307,7 @@ discard block  | 
                                                    ||
| 307 | 307 | </table>  | 
                                                        
| 308 | 308 | EOF;  | 
                                                        
| 309 | 309 | |
| 310 | - protected $bodyEnd = <<<EOF  | 
                                                        |
| 310 | + protected $bodyEnd = <<<EOF  | 
                                                        |
| 311 | 311 | |
| 312 | 312 | </td>  | 
                                                        
| 313 | 313 | </tr>  | 
                                                        
@@ -318,7 +318,7 @@ discard block  | 
                                                    ||
| 318 | 318 | </table>  | 
                                                        
| 319 | 319 | EOF;  | 
                                                        
| 320 | 320 | |
| 321 | - protected $footer = <<<EOF  | 
                                                        |
| 321 | + protected $footer = <<<EOF  | 
                                                        |
| 322 | 322 | <table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%%">  | 
                                                        
| 323 | 323 | <tbody>  | 
                                                        
| 324 | 324 | <tr style="padding:0;text-align:left;vertical-align:top">  | 
                                                        
@@ -344,315 +344,315 @@ discard block  | 
                                                    ||
| 344 | 344 | </table>  | 
                                                        
| 345 | 345 | EOF;  | 
                                                        
| 346 | 346 | |
| 347 | - /**  | 
                                                        |
| 348 | - * @param Defaults $themingDefaults  | 
                                                        |
| 349 | - * @param IURLGenerator $urlGenerator  | 
                                                        |
| 350 | - * @param IL10N $l10n  | 
                                                        |
| 351 | - * @param string $emailId  | 
                                                        |
| 352 | - * @param array $data  | 
                                                        |
| 353 | - */  | 
                                                        |
| 354 | - public function __construct(Defaults $themingDefaults,  | 
                                                        |
| 355 | - IURLGenerator $urlGenerator,  | 
                                                        |
| 356 | - IL10N $l10n,  | 
                                                        |
| 357 | - $emailId,  | 
                                                        |
| 358 | -								array $data) { | 
                                                        |
| 359 | - $this->themingDefaults = $themingDefaults;  | 
                                                        |
| 360 | - $this->urlGenerator = $urlGenerator;  | 
                                                        |
| 361 | - $this->l10n = $l10n;  | 
                                                        |
| 362 | - $this->htmlBody .= $this->head;  | 
                                                        |
| 363 | - $this->emailId = $emailId;  | 
                                                        |
| 364 | - $this->data = $data;  | 
                                                        |
| 365 | - }  | 
                                                        |
| 366 | -  | 
                                                        |
| 367 | - /**  | 
                                                        |
| 368 | - * Sets the subject of the email  | 
                                                        |
| 369 | - *  | 
                                                        |
| 370 | - * @param string $subject  | 
                                                        |
| 371 | - */  | 
                                                        |
| 372 | -	public function setSubject(string $subject) { | 
                                                        |
| 373 | - $this->subject = $subject;  | 
                                                        |
| 374 | - }  | 
                                                        |
| 375 | -  | 
                                                        |
| 376 | - /**  | 
                                                        |
| 377 | - * Adds a header to the email  | 
                                                        |
| 378 | - */  | 
                                                        |
| 379 | -	public function addHeader() { | 
                                                        |
| 380 | -		if ($this->headerAdded) { | 
                                                        |
| 381 | - return;  | 
                                                        |
| 382 | - }  | 
                                                        |
| 383 | - $this->headerAdded = true;  | 
                                                        |
| 384 | -  | 
                                                        |
| 385 | - $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false));  | 
                                                        |
| 386 | - $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]);  | 
                                                        |
| 387 | - }  | 
                                                        |
| 388 | -  | 
                                                        |
| 389 | - /**  | 
                                                        |
| 390 | - * Adds a heading to the email  | 
                                                        |
| 391 | - *  | 
                                                        |
| 392 | - * @param string $title  | 
                                                        |
| 393 | - * @param string|bool $plainTitle Title that is used in the plain text email  | 
                                                        |
| 394 | - * if empty the $title is used, if false none will be used  | 
                                                        |
| 395 | - */  | 
                                                        |
| 396 | -	public function addHeading(string $title, $plainTitle = '') { | 
                                                        |
| 397 | -		if ($this->footerAdded) { | 
                                                        |
| 398 | - return;  | 
                                                        |
| 399 | - }  | 
                                                        |
| 400 | -		if ($plainTitle === '') { | 
                                                        |
| 401 | - $plainTitle = $title;  | 
                                                        |
| 402 | - }  | 
                                                        |
| 403 | -  | 
                                                        |
| 404 | - $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);  | 
                                                        |
| 405 | -		if ($plainTitle !== false) { | 
                                                        |
| 406 | - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;  | 
                                                        |
| 407 | - }  | 
                                                        |
| 408 | - }  | 
                                                        |
| 409 | -  | 
                                                        |
| 410 | - /**  | 
                                                        |
| 411 | - * Open the HTML body when it is not already  | 
                                                        |
| 412 | - */  | 
                                                        |
| 413 | -	protected function ensureBodyIsOpened() { | 
                                                        |
| 414 | -		if ($this->bodyOpened) { | 
                                                        |
| 415 | - return;  | 
                                                        |
| 416 | - }  | 
                                                        |
| 417 | -  | 
                                                        |
| 418 | - $this->htmlBody .= $this->bodyBegin;  | 
                                                        |
| 419 | - $this->bodyOpened = true;  | 
                                                        |
| 420 | - }  | 
                                                        |
| 421 | -  | 
                                                        |
| 422 | - /**  | 
                                                        |
| 423 | - * Adds a paragraph to the body of the email  | 
                                                        |
| 424 | - *  | 
                                                        |
| 425 | - * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 426 | - * @param string|bool $plainText Text that is used in the plain text email  | 
                                                        |
| 427 | - * if empty the $text is used, if false none will be used  | 
                                                        |
| 428 | - */  | 
                                                        |
| 429 | -	public function addBodyText(string $text, $plainText = '') { | 
                                                        |
| 430 | -		if ($this->footerAdded) { | 
                                                        |
| 431 | - return;  | 
                                                        |
| 432 | - }  | 
                                                        |
| 433 | -		if ($plainText === '') { | 
                                                        |
| 434 | - $plainText = $text;  | 
                                                        |
| 435 | - $text = htmlspecialchars($text);  | 
                                                        |
| 436 | - }  | 
                                                        |
| 437 | -  | 
                                                        |
| 438 | - $this->ensureBodyListClosed();  | 
                                                        |
| 439 | - $this->ensureBodyIsOpened();  | 
                                                        |
| 440 | -  | 
                                                        |
| 441 | - $this->htmlBody .= vsprintf($this->bodyText, [$text]);  | 
                                                        |
| 442 | -		if ($plainText !== false) { | 
                                                        |
| 443 | - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL;  | 
                                                        |
| 444 | - }  | 
                                                        |
| 445 | - }  | 
                                                        |
| 446 | -  | 
                                                        |
| 447 | - /**  | 
                                                        |
| 448 | - * Adds a list item to the body of the email  | 
                                                        |
| 449 | - *  | 
                                                        |
| 450 | - * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 451 | - * @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 452 | - * @param string $icon Absolute path, must be 16*16 pixels  | 
                                                        |
| 453 | - * @param string|bool $plainText Text that is used in the plain text email  | 
                                                        |
| 454 | - * if empty the $text is used, if false none will be used  | 
                                                        |
| 455 | - * @param string|bool $plainMetaInfo Meta info that is used in the plain text email  | 
                                                        |
| 456 | - * if empty the $metaInfo is used, if false none will be used  | 
                                                        |
| 457 | - * @since 12.0.0  | 
                                                        |
| 458 | - */  | 
                                                        |
| 459 | -	public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '') { | 
                                                        |
| 460 | - $this->ensureBodyListOpened();  | 
                                                        |
| 461 | -  | 
                                                        |
| 462 | -		if ($plainText === '') { | 
                                                        |
| 463 | - $plainText = $text;  | 
                                                        |
| 464 | - $text = htmlspecialchars($text);  | 
                                                        |
| 465 | - }  | 
                                                        |
| 466 | -		if ($plainMetaInfo === '') { | 
                                                        |
| 467 | - $plainMetaInfo = $metaInfo;  | 
                                                        |
| 468 | - $metaInfo = htmlspecialchars($metaInfo);  | 
                                                        |
| 469 | - }  | 
                                                        |
| 470 | -  | 
                                                        |
| 471 | - $htmlText = $text;  | 
                                                        |
| 472 | -		if ($metaInfo) { | 
                                                        |
| 473 | - $htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText;  | 
                                                        |
| 474 | - }  | 
                                                        |
| 475 | -		if ($icon !== '') { | 
                                                        |
| 476 | - $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">';  | 
                                                        |
| 477 | -		} else { | 
                                                        |
| 478 | - $icon = '•';  | 
                                                        |
| 479 | - }  | 
                                                        |
| 480 | - $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);  | 
                                                        |
| 481 | -		if ($plainText !== false) { | 
                                                        |
| 482 | - $this->plainBody .= ' * ' . $plainText;  | 
                                                        |
| 483 | -			if ($plainMetaInfo !== false) { | 
                                                        |
| 484 | -				$this->plainBody .= ' (' . $plainMetaInfo . ')'; | 
                                                        |
| 485 | - }  | 
                                                        |
| 486 | - $this->plainBody .= PHP_EOL;  | 
                                                        |
| 487 | - }  | 
                                                        |
| 488 | - }  | 
                                                        |
| 489 | -  | 
                                                        |
| 490 | -	protected function ensureBodyListOpened() { | 
                                                        |
| 491 | -		if ($this->bodyListOpened) { | 
                                                        |
| 492 | - return;  | 
                                                        |
| 493 | - }  | 
                                                        |
| 494 | -  | 
                                                        |
| 495 | - $this->ensureBodyIsOpened();  | 
                                                        |
| 496 | - $this->bodyListOpened = true;  | 
                                                        |
| 497 | - $this->htmlBody .= $this->listBegin;  | 
                                                        |
| 498 | - }  | 
                                                        |
| 499 | -  | 
                                                        |
| 500 | -	protected function ensureBodyListClosed() { | 
                                                        |
| 501 | -		if (!$this->bodyListOpened) { | 
                                                        |
| 502 | - return;  | 
                                                        |
| 503 | - }  | 
                                                        |
| 504 | -  | 
                                                        |
| 505 | - $this->bodyListOpened = false;  | 
                                                        |
| 506 | - $this->htmlBody .= $this->listEnd;  | 
                                                        |
| 507 | - }  | 
                                                        |
| 508 | -  | 
                                                        |
| 509 | - /**  | 
                                                        |
| 510 | - * Adds a button group of two buttons to the body of the email  | 
                                                        |
| 511 | - *  | 
                                                        |
| 512 | - * @param string $textLeft Text of left button; Note: When $plainTextLeft falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 513 | - * @param string $urlLeft URL of left button  | 
                                                        |
| 514 | - * @param string $textRight Text of right button; Note: When $plainTextRight falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 515 | - * @param string $urlRight URL of right button  | 
                                                        |
| 516 | - * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used  | 
                                                        |
| 517 | - * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used  | 
                                                        |
| 518 | - */  | 
                                                        |
| 519 | - public function addBodyButtonGroup(string $textLeft,  | 
                                                        |
| 520 | - string $urlLeft,  | 
                                                        |
| 521 | - string $textRight,  | 
                                                        |
| 522 | - string $urlRight,  | 
                                                        |
| 523 | - string $plainTextLeft = '',  | 
                                                        |
| 524 | -									   string $plainTextRight = '') { | 
                                                        |
| 525 | -		if ($this->footerAdded) { | 
                                                        |
| 526 | - return;  | 
                                                        |
| 527 | - }  | 
                                                        |
| 528 | -		if ($plainTextLeft === '') { | 
                                                        |
| 529 | - $plainTextLeft = $textLeft;  | 
                                                        |
| 530 | - $textLeft = htmlspecialchars($textLeft);  | 
                                                        |
| 531 | - }  | 
                                                        |
| 532 | -  | 
                                                        |
| 533 | -		if ($plainTextRight === '') { | 
                                                        |
| 534 | - $plainTextRight = $textRight;  | 
                                                        |
| 535 | - $textRight = htmlspecialchars($textRight);  | 
                                                        |
| 536 | - }  | 
                                                        |
| 537 | -  | 
                                                        |
| 538 | - $this->ensureBodyIsOpened();  | 
                                                        |
| 539 | - $this->ensureBodyListClosed();  | 
                                                        |
| 540 | -  | 
                                                        |
| 541 | - $color = $this->themingDefaults->getColorPrimary();  | 
                                                        |
| 542 | - $textColor = $this->themingDefaults->getTextColorPrimary();  | 
                                                        |
| 543 | -  | 
                                                        |
| 544 | - $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);  | 
                                                        |
| 545 | - $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;  | 
                                                        |
| 546 | - $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;  | 
                                                        |
| 547 | -  | 
                                                        |
| 548 | - }  | 
                                                        |
| 549 | -  | 
                                                        |
| 550 | - /**  | 
                                                        |
| 551 | - * Adds a button to the body of the email  | 
                                                        |
| 552 | - *  | 
                                                        |
| 553 | - * @param string $text Text of button; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 554 | - * @param string $url URL of button  | 
                                                        |
| 555 | - * @param string $plainText Text of button in plain text version  | 
                                                        |
| 556 | - * if empty the $text is used, if false none will be used  | 
                                                        |
| 557 | - *  | 
                                                        |
| 558 | - * @since 12.0.0  | 
                                                        |
| 559 | - */  | 
                                                        |
| 560 | -	public function addBodyButton(string $text, string $url, $plainText = '') { | 
                                                        |
| 561 | -		if ($this->footerAdded) { | 
                                                        |
| 562 | - return;  | 
                                                        |
| 563 | - }  | 
                                                        |
| 564 | -  | 
                                                        |
| 565 | - $this->ensureBodyIsOpened();  | 
                                                        |
| 566 | - $this->ensureBodyListClosed();  | 
                                                        |
| 567 | -  | 
                                                        |
| 568 | -		if ($plainText === '') { | 
                                                        |
| 569 | - $plainText = $text;  | 
                                                        |
| 570 | - $text = htmlspecialchars($text);  | 
                                                        |
| 571 | - }  | 
                                                        |
| 572 | -  | 
                                                        |
| 573 | - $color = $this->themingDefaults->getColorPrimary();  | 
                                                        |
| 574 | - $textColor = $this->themingDefaults->getTextColorPrimary();  | 
                                                        |
| 575 | - $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]);  | 
                                                        |
| 576 | -  | 
                                                        |
| 577 | -		if ($plainText !== false) { | 
                                                        |
| 578 | - $this->plainBody .= $plainText . ': ';  | 
                                                        |
| 579 | - }  | 
                                                        |
| 580 | -  | 
                                                        |
| 581 | - $this->plainBody .= $url . PHP_EOL;  | 
                                                        |
| 582 | -  | 
                                                        |
| 583 | - }  | 
                                                        |
| 584 | -  | 
                                                        |
| 585 | - /**  | 
                                                        |
| 586 | - * Close the HTML body when it is open  | 
                                                        |
| 587 | - */  | 
                                                        |
| 588 | -	protected function ensureBodyIsClosed() { | 
                                                        |
| 589 | -		if (!$this->bodyOpened) { | 
                                                        |
| 590 | - return;  | 
                                                        |
| 591 | - }  | 
                                                        |
| 592 | -  | 
                                                        |
| 593 | - $this->ensureBodyListClosed();  | 
                                                        |
| 594 | -  | 
                                                        |
| 595 | - $this->htmlBody .= $this->bodyEnd;  | 
                                                        |
| 596 | - $this->bodyOpened = false;  | 
                                                        |
| 597 | - }  | 
                                                        |
| 598 | -  | 
                                                        |
| 599 | - /**  | 
                                                        |
| 600 | - * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email  | 
                                                        |
| 601 | - *  | 
                                                        |
| 602 | - * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used  | 
                                                        |
| 603 | - */  | 
                                                        |
| 604 | -	public function addFooter(string $text = '') { | 
                                                        |
| 605 | -		if($text === '') { | 
                                                        |
| 606 | -			$text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); | 
                                                        |
| 607 | - }  | 
                                                        |
| 608 | -  | 
                                                        |
| 609 | -		if ($this->footerAdded) { | 
                                                        |
| 610 | - return;  | 
                                                        |
| 611 | - }  | 
                                                        |
| 612 | - $this->footerAdded = true;  | 
                                                        |
| 613 | -  | 
                                                        |
| 614 | - $this->ensureBodyIsClosed();  | 
                                                        |
| 615 | -  | 
                                                        |
| 616 | - $this->htmlBody .= vsprintf($this->footer, [$text]);  | 
                                                        |
| 617 | - $this->htmlBody .= $this->tail;  | 
                                                        |
| 618 | - $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL;  | 
                                                        |
| 619 | -		$this->plainBody .= str_replace('<br>', PHP_EOL, $text); | 
                                                        |
| 620 | - }  | 
                                                        |
| 621 | -  | 
                                                        |
| 622 | - /**  | 
                                                        |
| 623 | - * Returns the rendered email subject as string  | 
                                                        |
| 624 | - *  | 
                                                        |
| 625 | - * @return string  | 
                                                        |
| 626 | - */  | 
                                                        |
| 627 | -	public function renderSubject(): string { | 
                                                        |
| 628 | - return $this->subject;  | 
                                                        |
| 629 | - }  | 
                                                        |
| 630 | -  | 
                                                        |
| 631 | - /**  | 
                                                        |
| 632 | - * Returns the rendered HTML email as string  | 
                                                        |
| 633 | - *  | 
                                                        |
| 634 | - * @return string  | 
                                                        |
| 635 | - */  | 
                                                        |
| 636 | -	public function renderHtml(): string { | 
                                                        |
| 637 | -		if (!$this->footerAdded) { | 
                                                        |
| 638 | - $this->footerAdded = true;  | 
                                                        |
| 639 | - $this->ensureBodyIsClosed();  | 
                                                        |
| 640 | - $this->htmlBody .= $this->tail;  | 
                                                        |
| 641 | - }  | 
                                                        |
| 642 | - return $this->htmlBody;  | 
                                                        |
| 643 | - }  | 
                                                        |
| 644 | -  | 
                                                        |
| 645 | - /**  | 
                                                        |
| 646 | - * Returns the rendered plain text email as string  | 
                                                        |
| 647 | - *  | 
                                                        |
| 648 | - * @return string  | 
                                                        |
| 649 | - */  | 
                                                        |
| 650 | -	public function renderText(): string { | 
                                                        |
| 651 | -		if (!$this->footerAdded) { | 
                                                        |
| 652 | - $this->footerAdded = true;  | 
                                                        |
| 653 | - $this->ensureBodyIsClosed();  | 
                                                        |
| 654 | - $this->htmlBody .= $this->tail;  | 
                                                        |
| 655 | - }  | 
                                                        |
| 656 | - return $this->plainBody;  | 
                                                        |
| 657 | - }  | 
                                                        |
| 347 | + /**  | 
                                                        |
| 348 | + * @param Defaults $themingDefaults  | 
                                                        |
| 349 | + * @param IURLGenerator $urlGenerator  | 
                                                        |
| 350 | + * @param IL10N $l10n  | 
                                                        |
| 351 | + * @param string $emailId  | 
                                                        |
| 352 | + * @param array $data  | 
                                                        |
| 353 | + */  | 
                                                        |
| 354 | + public function __construct(Defaults $themingDefaults,  | 
                                                        |
| 355 | + IURLGenerator $urlGenerator,  | 
                                                        |
| 356 | + IL10N $l10n,  | 
                                                        |
| 357 | + $emailId,  | 
                                                        |
| 358 | +                                array $data) { | 
                                                        |
| 359 | + $this->themingDefaults = $themingDefaults;  | 
                                                        |
| 360 | + $this->urlGenerator = $urlGenerator;  | 
                                                        |
| 361 | + $this->l10n = $l10n;  | 
                                                        |
| 362 | + $this->htmlBody .= $this->head;  | 
                                                        |
| 363 | + $this->emailId = $emailId;  | 
                                                        |
| 364 | + $this->data = $data;  | 
                                                        |
| 365 | + }  | 
                                                        |
| 366 | +  | 
                                                        |
| 367 | + /**  | 
                                                        |
| 368 | + * Sets the subject of the email  | 
                                                        |
| 369 | + *  | 
                                                        |
| 370 | + * @param string $subject  | 
                                                        |
| 371 | + */  | 
                                                        |
| 372 | +    public function setSubject(string $subject) { | 
                                                        |
| 373 | + $this->subject = $subject;  | 
                                                        |
| 374 | + }  | 
                                                        |
| 375 | +  | 
                                                        |
| 376 | + /**  | 
                                                        |
| 377 | + * Adds a header to the email  | 
                                                        |
| 378 | + */  | 
                                                        |
| 379 | +    public function addHeader() { | 
                                                        |
| 380 | +        if ($this->headerAdded) { | 
                                                        |
| 381 | + return;  | 
                                                        |
| 382 | + }  | 
                                                        |
| 383 | + $this->headerAdded = true;  | 
                                                        |
| 384 | +  | 
                                                        |
| 385 | + $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false));  | 
                                                        |
| 386 | + $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]);  | 
                                                        |
| 387 | + }  | 
                                                        |
| 388 | +  | 
                                                        |
| 389 | + /**  | 
                                                        |
| 390 | + * Adds a heading to the email  | 
                                                        |
| 391 | + *  | 
                                                        |
| 392 | + * @param string $title  | 
                                                        |
| 393 | + * @param string|bool $plainTitle Title that is used in the plain text email  | 
                                                        |
| 394 | + * if empty the $title is used, if false none will be used  | 
                                                        |
| 395 | + */  | 
                                                        |
| 396 | +    public function addHeading(string $title, $plainTitle = '') { | 
                                                        |
| 397 | +        if ($this->footerAdded) { | 
                                                        |
| 398 | + return;  | 
                                                        |
| 399 | + }  | 
                                                        |
| 400 | +        if ($plainTitle === '') { | 
                                                        |
| 401 | + $plainTitle = $title;  | 
                                                        |
| 402 | + }  | 
                                                        |
| 403 | +  | 
                                                        |
| 404 | + $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);  | 
                                                        |
| 405 | +        if ($plainTitle !== false) { | 
                                                        |
| 406 | + $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;  | 
                                                        |
| 407 | + }  | 
                                                        |
| 408 | + }  | 
                                                        |
| 409 | +  | 
                                                        |
| 410 | + /**  | 
                                                        |
| 411 | + * Open the HTML body when it is not already  | 
                                                        |
| 412 | + */  | 
                                                        |
| 413 | +    protected function ensureBodyIsOpened() { | 
                                                        |
| 414 | +        if ($this->bodyOpened) { | 
                                                        |
| 415 | + return;  | 
                                                        |
| 416 | + }  | 
                                                        |
| 417 | +  | 
                                                        |
| 418 | + $this->htmlBody .= $this->bodyBegin;  | 
                                                        |
| 419 | + $this->bodyOpened = true;  | 
                                                        |
| 420 | + }  | 
                                                        |
| 421 | +  | 
                                                        |
| 422 | + /**  | 
                                                        |
| 423 | + * Adds a paragraph to the body of the email  | 
                                                        |
| 424 | + *  | 
                                                        |
| 425 | + * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 426 | + * @param string|bool $plainText Text that is used in the plain text email  | 
                                                        |
| 427 | + * if empty the $text is used, if false none will be used  | 
                                                        |
| 428 | + */  | 
                                                        |
| 429 | +    public function addBodyText(string $text, $plainText = '') { | 
                                                        |
| 430 | +        if ($this->footerAdded) { | 
                                                        |
| 431 | + return;  | 
                                                        |
| 432 | + }  | 
                                                        |
| 433 | +        if ($plainText === '') { | 
                                                        |
| 434 | + $plainText = $text;  | 
                                                        |
| 435 | + $text = htmlspecialchars($text);  | 
                                                        |
| 436 | + }  | 
                                                        |
| 437 | +  | 
                                                        |
| 438 | + $this->ensureBodyListClosed();  | 
                                                        |
| 439 | + $this->ensureBodyIsOpened();  | 
                                                        |
| 440 | +  | 
                                                        |
| 441 | + $this->htmlBody .= vsprintf($this->bodyText, [$text]);  | 
                                                        |
| 442 | +        if ($plainText !== false) { | 
                                                        |
| 443 | + $this->plainBody .= $plainText . PHP_EOL . PHP_EOL;  | 
                                                        |
| 444 | + }  | 
                                                        |
| 445 | + }  | 
                                                        |
| 446 | +  | 
                                                        |
| 447 | + /**  | 
                                                        |
| 448 | + * Adds a list item to the body of the email  | 
                                                        |
| 449 | + *  | 
                                                        |
| 450 | + * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 451 | + * @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 452 | + * @param string $icon Absolute path, must be 16*16 pixels  | 
                                                        |
| 453 | + * @param string|bool $plainText Text that is used in the plain text email  | 
                                                        |
| 454 | + * if empty the $text is used, if false none will be used  | 
                                                        |
| 455 | + * @param string|bool $plainMetaInfo Meta info that is used in the plain text email  | 
                                                        |
| 456 | + * if empty the $metaInfo is used, if false none will be used  | 
                                                        |
| 457 | + * @since 12.0.0  | 
                                                        |
| 458 | + */  | 
                                                        |
| 459 | +    public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '') { | 
                                                        |
| 460 | + $this->ensureBodyListOpened();  | 
                                                        |
| 461 | +  | 
                                                        |
| 462 | +        if ($plainText === '') { | 
                                                        |
| 463 | + $plainText = $text;  | 
                                                        |
| 464 | + $text = htmlspecialchars($text);  | 
                                                        |
| 465 | + }  | 
                                                        |
| 466 | +        if ($plainMetaInfo === '') { | 
                                                        |
| 467 | + $plainMetaInfo = $metaInfo;  | 
                                                        |
| 468 | + $metaInfo = htmlspecialchars($metaInfo);  | 
                                                        |
| 469 | + }  | 
                                                        |
| 470 | +  | 
                                                        |
| 471 | + $htmlText = $text;  | 
                                                        |
| 472 | +        if ($metaInfo) { | 
                                                        |
| 473 | + $htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText;  | 
                                                        |
| 474 | + }  | 
                                                        |
| 475 | +        if ($icon !== '') { | 
                                                        |
| 476 | + $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">';  | 
                                                        |
| 477 | +        } else { | 
                                                        |
| 478 | + $icon = '•';  | 
                                                        |
| 479 | + }  | 
                                                        |
| 480 | + $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);  | 
                                                        |
| 481 | +        if ($plainText !== false) { | 
                                                        |
| 482 | + $this->plainBody .= ' * ' . $plainText;  | 
                                                        |
| 483 | +            if ($plainMetaInfo !== false) { | 
                                                        |
| 484 | +                $this->plainBody .= ' (' . $plainMetaInfo . ')'; | 
                                                        |
| 485 | + }  | 
                                                        |
| 486 | + $this->plainBody .= PHP_EOL;  | 
                                                        |
| 487 | + }  | 
                                                        |
| 488 | + }  | 
                                                        |
| 489 | +  | 
                                                        |
| 490 | +    protected function ensureBodyListOpened() { | 
                                                        |
| 491 | +        if ($this->bodyListOpened) { | 
                                                        |
| 492 | + return;  | 
                                                        |
| 493 | + }  | 
                                                        |
| 494 | +  | 
                                                        |
| 495 | + $this->ensureBodyIsOpened();  | 
                                                        |
| 496 | + $this->bodyListOpened = true;  | 
                                                        |
| 497 | + $this->htmlBody .= $this->listBegin;  | 
                                                        |
| 498 | + }  | 
                                                        |
| 499 | +  | 
                                                        |
| 500 | +    protected function ensureBodyListClosed() { | 
                                                        |
| 501 | +        if (!$this->bodyListOpened) { | 
                                                        |
| 502 | + return;  | 
                                                        |
| 503 | + }  | 
                                                        |
| 504 | +  | 
                                                        |
| 505 | + $this->bodyListOpened = false;  | 
                                                        |
| 506 | + $this->htmlBody .= $this->listEnd;  | 
                                                        |
| 507 | + }  | 
                                                        |
| 508 | +  | 
                                                        |
| 509 | + /**  | 
                                                        |
| 510 | + * Adds a button group of two buttons to the body of the email  | 
                                                        |
| 511 | + *  | 
                                                        |
| 512 | + * @param string $textLeft Text of left button; Note: When $plainTextLeft falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 513 | + * @param string $urlLeft URL of left button  | 
                                                        |
| 514 | + * @param string $textRight Text of right button; Note: When $plainTextRight falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 515 | + * @param string $urlRight URL of right button  | 
                                                        |
| 516 | + * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used  | 
                                                        |
| 517 | + * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used  | 
                                                        |
| 518 | + */  | 
                                                        |
| 519 | + public function addBodyButtonGroup(string $textLeft,  | 
                                                        |
| 520 | + string $urlLeft,  | 
                                                        |
| 521 | + string $textRight,  | 
                                                        |
| 522 | + string $urlRight,  | 
                                                        |
| 523 | + string $plainTextLeft = '',  | 
                                                        |
| 524 | +                                        string $plainTextRight = '') { | 
                                                        |
| 525 | +        if ($this->footerAdded) { | 
                                                        |
| 526 | + return;  | 
                                                        |
| 527 | + }  | 
                                                        |
| 528 | +        if ($plainTextLeft === '') { | 
                                                        |
| 529 | + $plainTextLeft = $textLeft;  | 
                                                        |
| 530 | + $textLeft = htmlspecialchars($textLeft);  | 
                                                        |
| 531 | + }  | 
                                                        |
| 532 | +  | 
                                                        |
| 533 | +        if ($plainTextRight === '') { | 
                                                        |
| 534 | + $plainTextRight = $textRight;  | 
                                                        |
| 535 | + $textRight = htmlspecialchars($textRight);  | 
                                                        |
| 536 | + }  | 
                                                        |
| 537 | +  | 
                                                        |
| 538 | + $this->ensureBodyIsOpened();  | 
                                                        |
| 539 | + $this->ensureBodyListClosed();  | 
                                                        |
| 540 | +  | 
                                                        |
| 541 | + $color = $this->themingDefaults->getColorPrimary();  | 
                                                        |
| 542 | + $textColor = $this->themingDefaults->getTextColorPrimary();  | 
                                                        |
| 543 | +  | 
                                                        |
| 544 | + $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);  | 
                                                        |
| 545 | + $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;  | 
                                                        |
| 546 | + $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;  | 
                                                        |
| 547 | +  | 
                                                        |
| 548 | + }  | 
                                                        |
| 549 | +  | 
                                                        |
| 550 | + /**  | 
                                                        |
| 551 | + * Adds a button to the body of the email  | 
                                                        |
| 552 | + *  | 
                                                        |
| 553 | + * @param string $text Text of button; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email  | 
                                                        |
| 554 | + * @param string $url URL of button  | 
                                                        |
| 555 | + * @param string $plainText Text of button in plain text version  | 
                                                        |
| 556 | + * if empty the $text is used, if false none will be used  | 
                                                        |
| 557 | + *  | 
                                                        |
| 558 | + * @since 12.0.0  | 
                                                        |
| 559 | + */  | 
                                                        |
| 560 | +    public function addBodyButton(string $text, string $url, $plainText = '') { | 
                                                        |
| 561 | +        if ($this->footerAdded) { | 
                                                        |
| 562 | + return;  | 
                                                        |
| 563 | + }  | 
                                                        |
| 564 | +  | 
                                                        |
| 565 | + $this->ensureBodyIsOpened();  | 
                                                        |
| 566 | + $this->ensureBodyListClosed();  | 
                                                        |
| 567 | +  | 
                                                        |
| 568 | +        if ($plainText === '') { | 
                                                        |
| 569 | + $plainText = $text;  | 
                                                        |
| 570 | + $text = htmlspecialchars($text);  | 
                                                        |
| 571 | + }  | 
                                                        |
| 572 | +  | 
                                                        |
| 573 | + $color = $this->themingDefaults->getColorPrimary();  | 
                                                        |
| 574 | + $textColor = $this->themingDefaults->getTextColorPrimary();  | 
                                                        |
| 575 | + $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]);  | 
                                                        |
| 576 | +  | 
                                                        |
| 577 | +        if ($plainText !== false) { | 
                                                        |
| 578 | + $this->plainBody .= $plainText . ': ';  | 
                                                        |
| 579 | + }  | 
                                                        |
| 580 | +  | 
                                                        |
| 581 | + $this->plainBody .= $url . PHP_EOL;  | 
                                                        |
| 582 | +  | 
                                                        |
| 583 | + }  | 
                                                        |
| 584 | +  | 
                                                        |
| 585 | + /**  | 
                                                        |
| 586 | + * Close the HTML body when it is open  | 
                                                        |
| 587 | + */  | 
                                                        |
| 588 | +    protected function ensureBodyIsClosed() { | 
                                                        |
| 589 | +        if (!$this->bodyOpened) { | 
                                                        |
| 590 | + return;  | 
                                                        |
| 591 | + }  | 
                                                        |
| 592 | +  | 
                                                        |
| 593 | + $this->ensureBodyListClosed();  | 
                                                        |
| 594 | +  | 
                                                        |
| 595 | + $this->htmlBody .= $this->bodyEnd;  | 
                                                        |
| 596 | + $this->bodyOpened = false;  | 
                                                        |
| 597 | + }  | 
                                                        |
| 598 | +  | 
                                                        |
| 599 | + /**  | 
                                                        |
| 600 | + * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email  | 
                                                        |
| 601 | + *  | 
                                                        |
| 602 | + * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used  | 
                                                        |
| 603 | + */  | 
                                                        |
| 604 | +    public function addFooter(string $text = '') { | 
                                                        |
| 605 | +        if($text === '') { | 
                                                        |
| 606 | +            $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); | 
                                                        |
| 607 | + }  | 
                                                        |
| 608 | +  | 
                                                        |
| 609 | +        if ($this->footerAdded) { | 
                                                        |
| 610 | + return;  | 
                                                        |
| 611 | + }  | 
                                                        |
| 612 | + $this->footerAdded = true;  | 
                                                        |
| 613 | +  | 
                                                        |
| 614 | + $this->ensureBodyIsClosed();  | 
                                                        |
| 615 | +  | 
                                                        |
| 616 | + $this->htmlBody .= vsprintf($this->footer, [$text]);  | 
                                                        |
| 617 | + $this->htmlBody .= $this->tail;  | 
                                                        |
| 618 | + $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL;  | 
                                                        |
| 619 | +        $this->plainBody .= str_replace('<br>', PHP_EOL, $text); | 
                                                        |
| 620 | + }  | 
                                                        |
| 621 | +  | 
                                                        |
| 622 | + /**  | 
                                                        |
| 623 | + * Returns the rendered email subject as string  | 
                                                        |
| 624 | + *  | 
                                                        |
| 625 | + * @return string  | 
                                                        |
| 626 | + */  | 
                                                        |
| 627 | +    public function renderSubject(): string { | 
                                                        |
| 628 | + return $this->subject;  | 
                                                        |
| 629 | + }  | 
                                                        |
| 630 | +  | 
                                                        |
| 631 | + /**  | 
                                                        |
| 632 | + * Returns the rendered HTML email as string  | 
                                                        |
| 633 | + *  | 
                                                        |
| 634 | + * @return string  | 
                                                        |
| 635 | + */  | 
                                                        |
| 636 | +    public function renderHtml(): string { | 
                                                        |
| 637 | +        if (!$this->footerAdded) { | 
                                                        |
| 638 | + $this->footerAdded = true;  | 
                                                        |
| 639 | + $this->ensureBodyIsClosed();  | 
                                                        |
| 640 | + $this->htmlBody .= $this->tail;  | 
                                                        |
| 641 | + }  | 
                                                        |
| 642 | + return $this->htmlBody;  | 
                                                        |
| 643 | + }  | 
                                                        |
| 644 | +  | 
                                                        |
| 645 | + /**  | 
                                                        |
| 646 | + * Returns the rendered plain text email as string  | 
                                                        |
| 647 | + *  | 
                                                        |
| 648 | + * @return string  | 
                                                        |
| 649 | + */  | 
                                                        |
| 650 | +    public function renderText(): string { | 
                                                        |
| 651 | +        if (!$this->footerAdded) { | 
                                                        |
| 652 | + $this->footerAdded = true;  | 
                                                        |
| 653 | + $this->ensureBodyIsClosed();  | 
                                                        |
| 654 | + $this->htmlBody .= $this->tail;  | 
                                                        |
| 655 | + }  | 
                                                        |
| 656 | + return $this->plainBody;  | 
                                                        |
| 657 | + }  | 
                                                        |
| 658 | 658 | }  |