Passed
Push — master ( 6d129e...1c8f5c )
by Lukas
15:54 queued 14s
created
lib/private/Mail/EMailTemplate.php 2 patches
Indentation   +359 added lines, -359 removed lines patch added patch discarded remove patch
@@ -52,33 +52,33 @@  discard block
 block discarded – undo
52 52
  * @package OC\Mail
53 53
  */
54 54
 class EMailTemplate implements IEMailTemplate {
55
-	/** @var Defaults */
56
-	protected $themingDefaults;
57
-	/** @var IURLGenerator */
58
-	protected $urlGenerator;
59
-	/** @var IFactory */
60
-	protected $l10nFactory;
61
-	/** @var string */
62
-	protected $emailId;
63
-	/** @var array */
64
-	protected $data;
65
-
66
-	/** @var string */
67
-	protected $subject = '';
68
-	/** @var string */
69
-	protected $htmlBody = '';
70
-	/** @var string */
71
-	protected $plainBody = '';
72
-	/** @var bool indicated if the footer is added */
73
-	protected $headerAdded = false;
74
-	/** @var bool indicated if the body is already opened */
75
-	protected $bodyOpened = false;
76
-	/** @var bool indicated if there is a list open in the body */
77
-	protected $bodyListOpened = false;
78
-	/** @var bool indicated if the footer is added */
79
-	protected $footerAdded = false;
80
-
81
-	protected $head = <<<EOF
55
+    /** @var Defaults */
56
+    protected $themingDefaults;
57
+    /** @var IURLGenerator */
58
+    protected $urlGenerator;
59
+    /** @var IFactory */
60
+    protected $l10nFactory;
61
+    /** @var string */
62
+    protected $emailId;
63
+    /** @var array */
64
+    protected $data;
65
+
66
+    /** @var string */
67
+    protected $subject = '';
68
+    /** @var string */
69
+    protected $htmlBody = '';
70
+    /** @var string */
71
+    protected $plainBody = '';
72
+    /** @var bool indicated if the footer is added */
73
+    protected $headerAdded = false;
74
+    /** @var bool indicated if the body is already opened */
75
+    protected $bodyOpened = false;
76
+    /** @var bool indicated if there is a list open in the body */
77
+    protected $bodyListOpened = false;
78
+    /** @var bool indicated if the footer is added */
79
+    protected $footerAdded = false;
80
+
81
+    protected $head = <<<EOF
82 82
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
83 83
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#fff!important">
84 84
 <head>
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 				<center data-parsed="" style="min-width:580px;width:100%">
97 97
 EOF;
98 98
 
99
-	protected $tail = <<<EOF
99
+    protected $tail = <<<EOF
100 100
 					</center>
101 101
 				</td>
102 102
 			</tr>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 EOF;
110 110
 
111
-	protected $header = <<<EOF
111
+    protected $header = <<<EOF
112 112
 <table align="center" class="wrapper header float-center" style="Margin:0 auto;background:#fff;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%%">
113 113
 	<tr style="padding:0;text-align:left;vertical-align:top">
114 114
 		<td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,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">
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 </table>
142 142
 EOF;
143 143
 
144
-	protected $heading = <<<EOF
144
+    protected $heading = <<<EOF
145 145
 <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">
146 146
 	<tbody>
147 147
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 </table>
161 161
 EOF;
162 162
 
163
-	protected $bodyBegin = <<<EOF
163
+    protected $bodyBegin = <<<EOF
164 164
 <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%">
165 165
 	<tr style="padding:0;text-align:left;vertical-align:top">
166 166
 		<td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,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">
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 					<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,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">
171 171
 EOF;
172 172
 
173
-	protected $bodyText = <<<EOF
173
+    protected $bodyText = <<<EOF
174 174
 <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%%">
175 175
 	<tbody>
176 176
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 </table>
190 190
 EOF;
191 191
 
192
-	// note: listBegin (like bodyBegin) is not processed through sprintf, so "%" is not escaped as "%%". (bug #12151)
193
-	protected $listBegin = <<<EOF
192
+    // note: listBegin (like bodyBegin) is not processed through sprintf, so "%" is not escaped as "%%". (bug #12151)
193
+    protected $listBegin = <<<EOF
194 194
 <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%">
195 195
 	<tbody>
196 196
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 			<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
199 199
 EOF;
200 200
 
201
-	protected $listItem = <<<EOF
201
+    protected $listItem = <<<EOF
202 202
 				<tr style="padding:0;text-align:left;vertical-align:top">
203 203
 					<td style="Margin:0;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;width:15px;">
204 204
 						<p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,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>
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 				</tr>
211 211
 EOF;
212 212
 
213
-	protected $listEnd = <<<EOF
213
+    protected $listEnd = <<<EOF
214 214
 			</table>
215 215
 		</th>
216 216
 	</tr>
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 </table>
219 219
 EOF;
220 220
 
221
-	protected $buttonGroup = <<<EOF
221
+    protected $buttonGroup = <<<EOF
222 222
 <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
223 223
 	<tbody>
224 224
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 </table>
272 272
 EOF;
273 273
 
274
-	protected $button = <<<EOF
274
+    protected $button = <<<EOF
275 275
 <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
276 276
 	<tbody>
277 277
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 </table>
312 312
 EOF;
313 313
 
314
-	protected $bodyEnd = <<<EOF
314
+    protected $bodyEnd = <<<EOF
315 315
 
316 316
 					</td>
317 317
 				</tr>
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 </table>
323 323
 EOF;
324 324
 
325
-	protected $footer = <<<EOF
325
+    protected $footer = <<<EOF
326 326
 <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%%">
327 327
 	<tbody>
328 328
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -348,331 +348,331 @@  discard block
 block discarded – undo
348 348
 </table>
349 349
 EOF;
350 350
 
351
-	public function __construct(Defaults $themingDefaults,
352
-								IURLGenerator $urlGenerator,
353
-								IFactory $l10nFactory,
354
-								$emailId,
355
-								array $data) {
356
-		$this->themingDefaults = $themingDefaults;
357
-		$this->urlGenerator = $urlGenerator;
358
-		$this->l10nFactory = $l10nFactory;
359
-		$this->htmlBody .= $this->head;
360
-		$this->emailId = $emailId;
361
-		$this->data = $data;
362
-	}
363
-
364
-	/**
365
-	 * Sets the subject of the email
366
-	 *
367
-	 * @param string $subject
368
-	 */
369
-	public function setSubject(string $subject) {
370
-		$this->subject = $subject;
371
-	}
372
-
373
-	/**
374
-	 * Adds a header to the email
375
-	 */
376
-	public function addHeader() {
377
-		if ($this->headerAdded) {
378
-			return;
379
-		}
380
-		$this->headerAdded = true;
381
-
382
-		$logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false));
383
-		$this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]);
384
-	}
385
-
386
-	/**
387
-	 * Adds a heading to the email
388
-	 *
389
-	 * @param string $title
390
-	 * @param string|bool $plainTitle Title that is used in the plain text email
391
-	 *   if empty the $title is used, if false none will be used
392
-	 */
393
-	public function addHeading(string $title, $plainTitle = '') {
394
-		if ($this->footerAdded) {
395
-			return;
396
-		}
397
-		if ($plainTitle === '') {
398
-			$plainTitle = $title;
399
-		}
400
-
401
-		$this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);
402
-		if ($plainTitle !== false) {
403
-			$this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;
404
-		}
405
-	}
406
-
407
-	/**
408
-	 * Open the HTML body when it is not already
409
-	 */
410
-	protected function ensureBodyIsOpened() {
411
-		if ($this->bodyOpened) {
412
-			return;
413
-		}
414
-
415
-		$this->htmlBody .= $this->bodyBegin;
416
-		$this->bodyOpened = true;
417
-	}
418
-
419
-	/**
420
-	 * Adds a paragraph to the body of the email
421
-	 *
422
-	 * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
423
-	 * @param string|bool $plainText Text that is used in the plain text email
424
-	 *   if empty the $text is used, if false none will be used
425
-	 */
426
-	public function addBodyText(string $text, $plainText = '') {
427
-		if ($this->footerAdded) {
428
-			return;
429
-		}
430
-		if ($plainText === '') {
431
-			$plainText = $text;
432
-			$text = htmlspecialchars($text);
433
-		}
434
-
435
-		$this->ensureBodyListClosed();
436
-		$this->ensureBodyIsOpened();
437
-
438
-		$this->htmlBody .= vsprintf($this->bodyText, [$text]);
439
-		if ($plainText !== false) {
440
-			$this->plainBody .= $plainText . PHP_EOL . PHP_EOL;
441
-		}
442
-	}
443
-
444
-	/**
445
-	 * Adds a list item to the body of the email
446
-	 *
447
-	 * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
448
-	 * @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email
449
-	 * @param string $icon Absolute path, must be 16*16 pixels
450
-	 * @param string|bool $plainText Text that is used in the plain text email
451
-	 *   if empty or true the $text is used, if false none will be used
452
-	 * @param string|bool $plainMetaInfo Meta info that is used in the plain text email
453
-	 *   if empty or true the $metaInfo is used, if false none will be used
454
-	 * @param integer plainIndent If > 0, Indent plainText by this amount.
455
-	 * @since 12.0.0
456
-	 */
457
-	public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '', $plainIndent = 0) {
458
-		$this->ensureBodyListOpened();
459
-
460
-		if ($plainText === '' || $plainText === true) {
461
-			$plainText = $text;
462
-			$text = htmlspecialchars($text);
463
-			$text = str_replace("\n", "<br/>", $text); // convert newlines to HTML breaks
464
-		}
465
-		if ($plainMetaInfo === '' || $plainMetaInfo === true) {
466
-			$plainMetaInfo = $metaInfo;
467
-			$metaInfo = htmlspecialchars($metaInfo);
468
-		}
469
-
470
-		$htmlText = $text;
471
-		if ($metaInfo) {
472
-			$htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText;
473
-		}
474
-		if ($icon !== '') {
475
-			$icon = '<img src="' . htmlspecialchars($icon) . '" alt="&bull;">';
476
-		} else {
477
-			$icon = '&bull;';
478
-		}
479
-		$this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);
480
-		if ($plainText !== false) {
481
-			if ($plainIndent === 0) {
482
-				/*
351
+    public function __construct(Defaults $themingDefaults,
352
+                                IURLGenerator $urlGenerator,
353
+                                IFactory $l10nFactory,
354
+                                $emailId,
355
+                                array $data) {
356
+        $this->themingDefaults = $themingDefaults;
357
+        $this->urlGenerator = $urlGenerator;
358
+        $this->l10nFactory = $l10nFactory;
359
+        $this->htmlBody .= $this->head;
360
+        $this->emailId = $emailId;
361
+        $this->data = $data;
362
+    }
363
+
364
+    /**
365
+     * Sets the subject of the email
366
+     *
367
+     * @param string $subject
368
+     */
369
+    public function setSubject(string $subject) {
370
+        $this->subject = $subject;
371
+    }
372
+
373
+    /**
374
+     * Adds a header to the email
375
+     */
376
+    public function addHeader() {
377
+        if ($this->headerAdded) {
378
+            return;
379
+        }
380
+        $this->headerAdded = true;
381
+
382
+        $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false));
383
+        $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]);
384
+    }
385
+
386
+    /**
387
+     * Adds a heading to the email
388
+     *
389
+     * @param string $title
390
+     * @param string|bool $plainTitle Title that is used in the plain text email
391
+     *   if empty the $title is used, if false none will be used
392
+     */
393
+    public function addHeading(string $title, $plainTitle = '') {
394
+        if ($this->footerAdded) {
395
+            return;
396
+        }
397
+        if ($plainTitle === '') {
398
+            $plainTitle = $title;
399
+        }
400
+
401
+        $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);
402
+        if ($plainTitle !== false) {
403
+            $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;
404
+        }
405
+    }
406
+
407
+    /**
408
+     * Open the HTML body when it is not already
409
+     */
410
+    protected function ensureBodyIsOpened() {
411
+        if ($this->bodyOpened) {
412
+            return;
413
+        }
414
+
415
+        $this->htmlBody .= $this->bodyBegin;
416
+        $this->bodyOpened = true;
417
+    }
418
+
419
+    /**
420
+     * Adds a paragraph to the body of the email
421
+     *
422
+     * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
423
+     * @param string|bool $plainText Text that is used in the plain text email
424
+     *   if empty the $text is used, if false none will be used
425
+     */
426
+    public function addBodyText(string $text, $plainText = '') {
427
+        if ($this->footerAdded) {
428
+            return;
429
+        }
430
+        if ($plainText === '') {
431
+            $plainText = $text;
432
+            $text = htmlspecialchars($text);
433
+        }
434
+
435
+        $this->ensureBodyListClosed();
436
+        $this->ensureBodyIsOpened();
437
+
438
+        $this->htmlBody .= vsprintf($this->bodyText, [$text]);
439
+        if ($plainText !== false) {
440
+            $this->plainBody .= $plainText . PHP_EOL . PHP_EOL;
441
+        }
442
+    }
443
+
444
+    /**
445
+     * Adds a list item to the body of the email
446
+     *
447
+     * @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
448
+     * @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email
449
+     * @param string $icon Absolute path, must be 16*16 pixels
450
+     * @param string|bool $plainText Text that is used in the plain text email
451
+     *   if empty or true the $text is used, if false none will be used
452
+     * @param string|bool $plainMetaInfo Meta info that is used in the plain text email
453
+     *   if empty or true the $metaInfo is used, if false none will be used
454
+     * @param integer plainIndent If > 0, Indent plainText by this amount.
455
+     * @since 12.0.0
456
+     */
457
+    public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '', $plainIndent = 0) {
458
+        $this->ensureBodyListOpened();
459
+
460
+        if ($plainText === '' || $plainText === true) {
461
+            $plainText = $text;
462
+            $text = htmlspecialchars($text);
463
+            $text = str_replace("\n", "<br/>", $text); // convert newlines to HTML breaks
464
+        }
465
+        if ($plainMetaInfo === '' || $plainMetaInfo === true) {
466
+            $plainMetaInfo = $metaInfo;
467
+            $metaInfo = htmlspecialchars($metaInfo);
468
+        }
469
+
470
+        $htmlText = $text;
471
+        if ($metaInfo) {
472
+            $htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText;
473
+        }
474
+        if ($icon !== '') {
475
+            $icon = '<img src="' . htmlspecialchars($icon) . '" alt="&bull;">';
476
+        } else {
477
+            $icon = '&bull;';
478
+        }
479
+        $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);
480
+        if ($plainText !== false) {
481
+            if ($plainIndent === 0) {
482
+                /*
483 483
 				 * If plainIndent is not set by caller, this is the old NC17 layout code.
484 484
 				 */
485
-				$this->plainBody .= '  * ' . $plainText;
486
-				if ($plainMetaInfo !== false) {
487
-					$this->plainBody .= ' (' . $plainMetaInfo . ')';
488
-				}
489
-				$this->plainBody .= PHP_EOL;
490
-			} else {
491
-				/*
485
+                $this->plainBody .= '  * ' . $plainText;
486
+                if ($plainMetaInfo !== false) {
487
+                    $this->plainBody .= ' (' . $plainMetaInfo . ')';
488
+                }
489
+                $this->plainBody .= PHP_EOL;
490
+            } else {
491
+                /*
492 492
 				 * Caller can set plainIndent > 0 to format plainText in tabular fashion.
493 493
 				 * with plainMetaInfo in column 1, and plainText in column 2.
494 494
 				 * The plainMetaInfo label is right justified in a field of width
495 495
 				 * "plainIndent". Multilines after the first are indented plainIndent+1
496 496
 				 * (to account for space after label).  Fixes: #12391
497 497
 				 */
498
-				/** @var string $label */
499
-				$label = ($plainMetaInfo !== false)? $plainMetaInfo : '';
500
-				$this->plainBody .= sprintf("%${plainIndent}s %s\n",
501
-					$label,
502
-					str_replace("\n", "\n" . str_repeat(' ', $plainIndent + 1), $plainText));
503
-			}
504
-		}
505
-	}
506
-
507
-	protected function ensureBodyListOpened() {
508
-		if ($this->bodyListOpened) {
509
-			return;
510
-		}
511
-
512
-		$this->ensureBodyIsOpened();
513
-		$this->bodyListOpened = true;
514
-		$this->htmlBody .= $this->listBegin;
515
-	}
516
-
517
-	protected function ensureBodyListClosed() {
518
-		if (!$this->bodyListOpened) {
519
-			return;
520
-		}
521
-
522
-		$this->bodyListOpened = false;
523
-		$this->htmlBody .= $this->listEnd;
524
-	}
525
-
526
-	/**
527
-	 * Adds a button group of two buttons to the body of the email
528
-	 *
529
-	 * @param string $textLeft Text of left button; Note: When $plainTextLeft falls back to this, HTML is automatically escaped in the HTML email
530
-	 * @param string $urlLeft URL of left button
531
-	 * @param string $textRight Text of right button; Note: When $plainTextRight falls back to this, HTML is automatically escaped in the HTML email
532
-	 * @param string $urlRight URL of right button
533
-	 * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used
534
-	 * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used
535
-	 */
536
-	public function addBodyButtonGroup(string $textLeft,
537
-									   string $urlLeft,
538
-									   string $textRight,
539
-									   string $urlRight,
540
-									   string $plainTextLeft = '',
541
-									   string $plainTextRight = '') {
542
-		if ($this->footerAdded) {
543
-			return;
544
-		}
545
-		if ($plainTextLeft === '') {
546
-			$plainTextLeft = $textLeft;
547
-			$textLeft = htmlspecialchars($textLeft);
548
-		}
549
-
550
-		if ($plainTextRight === '') {
551
-			$plainTextRight = $textRight;
552
-			$textRight = htmlspecialchars($textRight);
553
-		}
554
-
555
-		$this->ensureBodyIsOpened();
556
-		$this->ensureBodyListClosed();
557
-
558
-		$color = $this->themingDefaults->getColorPrimary();
559
-		$textColor = $this->themingDefaults->getTextColorPrimary();
560
-
561
-		$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);
562
-		$this->plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
563
-		$this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
564
-	}
565
-
566
-	/**
567
-	 * Adds a button to the body of the email
568
-	 *
569
-	 * @param string $text Text of button; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
570
-	 * @param string $url URL of button
571
-	 * @param string $plainText Text of button in plain text version
572
-	 * 		if empty the $text is used, if false none will be used
573
-	 *
574
-	 * @since 12.0.0
575
-	 */
576
-	public function addBodyButton(string $text, string $url, $plainText = '') {
577
-		if ($this->footerAdded) {
578
-			return;
579
-		}
580
-
581
-		$this->ensureBodyIsOpened();
582
-		$this->ensureBodyListClosed();
583
-
584
-		if ($plainText === '') {
585
-			$plainText = $text;
586
-			$text = htmlspecialchars($text);
587
-		}
588
-
589
-		$color = $this->themingDefaults->getColorPrimary();
590
-		$textColor = $this->themingDefaults->getTextColorPrimary();
591
-		$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]);
592
-
593
-		if ($plainText !== false) {
594
-			$this->plainBody .= $plainText . ': ';
595
-		}
596
-
597
-		$this->plainBody .= $url . PHP_EOL;
598
-	}
599
-
600
-	/**
601
-	 * Close the HTML body when it is open
602
-	 */
603
-	protected function ensureBodyIsClosed() {
604
-		if (!$this->bodyOpened) {
605
-			return;
606
-		}
607
-
608
-		$this->ensureBodyListClosed();
609
-
610
-		$this->htmlBody .= $this->bodyEnd;
611
-		$this->bodyOpened = false;
612
-	}
613
-
614
-	/**
615
-	 * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
616
-	 *
617
-	 * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
618
-	 */
619
-	public function addFooter(string $text = '', ?string $lang = null) {
620
-		if ($text === '') {
621
-			$l10n = $this->l10nFactory->get('lib', $lang);
622
-			$slogan = $this->themingDefaults->getSlogan($lang);
623
-			if ($slogan !== '') {
624
-				$slogan = ' - ' . $slogan;
625
-			}
626
-			$text = $this->themingDefaults->getName() . $slogan . '<br>' . $l10n->t('This is an automatically sent email, please do not reply.');
627
-		}
628
-
629
-		if ($this->footerAdded) {
630
-			return;
631
-		}
632
-		$this->footerAdded = true;
633
-
634
-		$this->ensureBodyIsClosed();
635
-
636
-		$this->htmlBody .= vsprintf($this->footer, [$text]);
637
-		$this->htmlBody .= $this->tail;
638
-		$this->plainBody .= PHP_EOL . '-- ' . PHP_EOL;
639
-		$this->plainBody .= str_replace('<br>', PHP_EOL, $text);
640
-	}
641
-
642
-	/**
643
-	 * Returns the rendered email subject as string
644
-	 *
645
-	 * @return string
646
-	 */
647
-	public function renderSubject(): string {
648
-		return $this->subject;
649
-	}
650
-
651
-	/**
652
-	 * Returns the rendered HTML email as string
653
-	 *
654
-	 * @return string
655
-	 */
656
-	public function renderHtml(): string {
657
-		if (!$this->footerAdded) {
658
-			$this->footerAdded = true;
659
-			$this->ensureBodyIsClosed();
660
-			$this->htmlBody .= $this->tail;
661
-		}
662
-		return $this->htmlBody;
663
-	}
664
-
665
-	/**
666
-	 * Returns the rendered plain text email as string
667
-	 *
668
-	 * @return string
669
-	 */
670
-	public function renderText(): string {
671
-		if (!$this->footerAdded) {
672
-			$this->footerAdded = true;
673
-			$this->ensureBodyIsClosed();
674
-			$this->htmlBody .= $this->tail;
675
-		}
676
-		return $this->plainBody;
677
-	}
498
+                /** @var string $label */
499
+                $label = ($plainMetaInfo !== false)? $plainMetaInfo : '';
500
+                $this->plainBody .= sprintf("%${plainIndent}s %s\n",
501
+                    $label,
502
+                    str_replace("\n", "\n" . str_repeat(' ', $plainIndent + 1), $plainText));
503
+            }
504
+        }
505
+    }
506
+
507
+    protected function ensureBodyListOpened() {
508
+        if ($this->bodyListOpened) {
509
+            return;
510
+        }
511
+
512
+        $this->ensureBodyIsOpened();
513
+        $this->bodyListOpened = true;
514
+        $this->htmlBody .= $this->listBegin;
515
+    }
516
+
517
+    protected function ensureBodyListClosed() {
518
+        if (!$this->bodyListOpened) {
519
+            return;
520
+        }
521
+
522
+        $this->bodyListOpened = false;
523
+        $this->htmlBody .= $this->listEnd;
524
+    }
525
+
526
+    /**
527
+     * Adds a button group of two buttons to the body of the email
528
+     *
529
+     * @param string $textLeft Text of left button; Note: When $plainTextLeft falls back to this, HTML is automatically escaped in the HTML email
530
+     * @param string $urlLeft URL of left button
531
+     * @param string $textRight Text of right button; Note: When $plainTextRight falls back to this, HTML is automatically escaped in the HTML email
532
+     * @param string $urlRight URL of right button
533
+     * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used
534
+     * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used
535
+     */
536
+    public function addBodyButtonGroup(string $textLeft,
537
+                                        string $urlLeft,
538
+                                        string $textRight,
539
+                                        string $urlRight,
540
+                                        string $plainTextLeft = '',
541
+                                        string $plainTextRight = '') {
542
+        if ($this->footerAdded) {
543
+            return;
544
+        }
545
+        if ($plainTextLeft === '') {
546
+            $plainTextLeft = $textLeft;
547
+            $textLeft = htmlspecialchars($textLeft);
548
+        }
549
+
550
+        if ($plainTextRight === '') {
551
+            $plainTextRight = $textRight;
552
+            $textRight = htmlspecialchars($textRight);
553
+        }
554
+
555
+        $this->ensureBodyIsOpened();
556
+        $this->ensureBodyListClosed();
557
+
558
+        $color = $this->themingDefaults->getColorPrimary();
559
+        $textColor = $this->themingDefaults->getTextColorPrimary();
560
+
561
+        $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);
562
+        $this->plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
563
+        $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
564
+    }
565
+
566
+    /**
567
+     * Adds a button to the body of the email
568
+     *
569
+     * @param string $text Text of button; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
570
+     * @param string $url URL of button
571
+     * @param string $plainText Text of button in plain text version
572
+     * 		if empty the $text is used, if false none will be used
573
+     *
574
+     * @since 12.0.0
575
+     */
576
+    public function addBodyButton(string $text, string $url, $plainText = '') {
577
+        if ($this->footerAdded) {
578
+            return;
579
+        }
580
+
581
+        $this->ensureBodyIsOpened();
582
+        $this->ensureBodyListClosed();
583
+
584
+        if ($plainText === '') {
585
+            $plainText = $text;
586
+            $text = htmlspecialchars($text);
587
+        }
588
+
589
+        $color = $this->themingDefaults->getColorPrimary();
590
+        $textColor = $this->themingDefaults->getTextColorPrimary();
591
+        $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]);
592
+
593
+        if ($plainText !== false) {
594
+            $this->plainBody .= $plainText . ': ';
595
+        }
596
+
597
+        $this->plainBody .= $url . PHP_EOL;
598
+    }
599
+
600
+    /**
601
+     * Close the HTML body when it is open
602
+     */
603
+    protected function ensureBodyIsClosed() {
604
+        if (!$this->bodyOpened) {
605
+            return;
606
+        }
607
+
608
+        $this->ensureBodyListClosed();
609
+
610
+        $this->htmlBody .= $this->bodyEnd;
611
+        $this->bodyOpened = false;
612
+    }
613
+
614
+    /**
615
+     * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
616
+     *
617
+     * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
618
+     */
619
+    public function addFooter(string $text = '', ?string $lang = null) {
620
+        if ($text === '') {
621
+            $l10n = $this->l10nFactory->get('lib', $lang);
622
+            $slogan = $this->themingDefaults->getSlogan($lang);
623
+            if ($slogan !== '') {
624
+                $slogan = ' - ' . $slogan;
625
+            }
626
+            $text = $this->themingDefaults->getName() . $slogan . '<br>' . $l10n->t('This is an automatically sent email, please do not reply.');
627
+        }
628
+
629
+        if ($this->footerAdded) {
630
+            return;
631
+        }
632
+        $this->footerAdded = true;
633
+
634
+        $this->ensureBodyIsClosed();
635
+
636
+        $this->htmlBody .= vsprintf($this->footer, [$text]);
637
+        $this->htmlBody .= $this->tail;
638
+        $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL;
639
+        $this->plainBody .= str_replace('<br>', PHP_EOL, $text);
640
+    }
641
+
642
+    /**
643
+     * Returns the rendered email subject as string
644
+     *
645
+     * @return string
646
+     */
647
+    public function renderSubject(): string {
648
+        return $this->subject;
649
+    }
650
+
651
+    /**
652
+     * Returns the rendered HTML email as string
653
+     *
654
+     * @return string
655
+     */
656
+    public function renderHtml(): string {
657
+        if (!$this->footerAdded) {
658
+            $this->footerAdded = true;
659
+            $this->ensureBodyIsClosed();
660
+            $this->htmlBody .= $this->tail;
661
+        }
662
+        return $this->htmlBody;
663
+    }
664
+
665
+    /**
666
+     * Returns the rendered plain text email as string
667
+     *
668
+     * @return string
669
+     */
670
+    public function renderText(): string {
671
+        if (!$this->footerAdded) {
672
+            $this->footerAdded = true;
673
+            $this->ensureBodyIsClosed();
674
+            $this->htmlBody .= $this->tail;
675
+        }
676
+        return $this->plainBody;
677
+    }
678 678
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 
401 401
 		$this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);
402 402
 		if ($plainTitle !== false) {
403
-			$this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;
403
+			$this->plainBody .= $plainTitle.PHP_EOL.PHP_EOL;
404 404
 		}
405 405
 	}
406 406
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 
438 438
 		$this->htmlBody .= vsprintf($this->bodyText, [$text]);
439 439
 		if ($plainText !== false) {
440
-			$this->plainBody .= $plainText . PHP_EOL . PHP_EOL;
440
+			$this->plainBody .= $plainText.PHP_EOL.PHP_EOL;
441 441
 		}
442 442
 	}
443 443
 
@@ -469,10 +469,10 @@  discard block
 block discarded – undo
469 469
 
470 470
 		$htmlText = $text;
471 471
 		if ($metaInfo) {
472
-			$htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText;
472
+			$htmlText = '<em style="color:#777;">'.$metaInfo.'</em><br>'.$htmlText;
473 473
 		}
474 474
 		if ($icon !== '') {
475
-			$icon = '<img src="' . htmlspecialchars($icon) . '" alt="&bull;">';
475
+			$icon = '<img src="'.htmlspecialchars($icon).'" alt="&bull;">';
476 476
 		} else {
477 477
 			$icon = '&bull;';
478 478
 		}
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
 				/*
483 483
 				 * If plainIndent is not set by caller, this is the old NC17 layout code.
484 484
 				 */
485
-				$this->plainBody .= '  * ' . $plainText;
485
+				$this->plainBody .= '  * '.$plainText;
486 486
 				if ($plainMetaInfo !== false) {
487
-					$this->plainBody .= ' (' . $plainMetaInfo . ')';
487
+					$this->plainBody .= ' ('.$plainMetaInfo.')';
488 488
 				}
489 489
 				$this->plainBody .= PHP_EOL;
490 490
 			} else {
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
 				 * (to account for space after label).  Fixes: #12391
497 497
 				 */
498 498
 				/** @var string $label */
499
-				$label = ($plainMetaInfo !== false)? $plainMetaInfo : '';
499
+				$label = ($plainMetaInfo !== false) ? $plainMetaInfo : '';
500 500
 				$this->plainBody .= sprintf("%${plainIndent}s %s\n",
501 501
 					$label,
502
-					str_replace("\n", "\n" . str_repeat(' ', $plainIndent + 1), $plainText));
502
+					str_replace("\n", "\n".str_repeat(' ', $plainIndent + 1), $plainText));
503 503
 			}
504 504
 		}
505 505
 	}
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 		$textColor = $this->themingDefaults->getTextColorPrimary();
560 560
 
561 561
 		$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);
562
-		$this->plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
563
-		$this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
562
+		$this->plainBody .= PHP_EOL.$plainTextLeft.': '.$urlLeft.PHP_EOL;
563
+		$this->plainBody .= $plainTextRight.': '.$urlRight.PHP_EOL.PHP_EOL;
564 564
 	}
565 565
 
566 566
 	/**
@@ -591,10 +591,10 @@  discard block
 block discarded – undo
591 591
 		$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]);
592 592
 
593 593
 		if ($plainText !== false) {
594
-			$this->plainBody .= $plainText . ': ';
594
+			$this->plainBody .= $plainText.': ';
595 595
 		}
596 596
 
597
-		$this->plainBody .= $url . PHP_EOL;
597
+		$this->plainBody .= $url.PHP_EOL;
598 598
 	}
599 599
 
600 600
 	/**
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 			$l10n = $this->l10nFactory->get('lib', $lang);
622 622
 			$slogan = $this->themingDefaults->getSlogan($lang);
623 623
 			if ($slogan !== '') {
624
-				$slogan = ' - ' . $slogan;
624
+				$slogan = ' - '.$slogan;
625 625
 			}
626
-			$text = $this->themingDefaults->getName() . $slogan . '<br>' . $l10n->t('This is an automatically sent email, please do not reply.');
626
+			$text = $this->themingDefaults->getName().$slogan.'<br>'.$l10n->t('This is an automatically sent email, please do not reply.');
627 627
 		}
628 628
 
629 629
 		if ($this->footerAdded) {
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 
636 636
 		$this->htmlBody .= vsprintf($this->footer, [$text]);
637 637
 		$this->htmlBody .= $this->tail;
638
-		$this->plainBody .= PHP_EOL . '-- ' . PHP_EOL;
638
+		$this->plainBody .= PHP_EOL.'-- '.PHP_EOL;
639 639
 		$this->plainBody .= str_replace('<br>', PHP_EOL, $text);
640 640
 	}
641 641
 
Please login to merge, or discard this patch.