@@ -55,6 +55,7 @@ discard block |
||
| 55 | 55 | * Adds a header to the email |
| 56 | 56 | * |
| 57 | 57 | * @since 12.0.0 |
| 58 | + * @return void |
|
| 58 | 59 | */ |
| 59 | 60 | public function addHeader(); |
| 60 | 61 | |
@@ -62,10 +63,11 @@ discard block |
||
| 62 | 63 | * Adds a heading to the email |
| 63 | 64 | * |
| 64 | 65 | * @param string $title |
| 65 | - * @param string $plainTitle|bool Title that is used in the plain text email |
|
| 66 | + * @param string $plainTitle Title that is used in the plain text email |
|
| 66 | 67 | * if empty the $title is used, if false none will be used |
| 67 | 68 | * |
| 68 | 69 | * @since 12.0.0 |
| 70 | + * @return void |
|
| 69 | 71 | */ |
| 70 | 72 | public function addHeading($title, $plainTitle = ''); |
| 71 | 73 | |
@@ -77,6 +79,7 @@ discard block |
||
| 77 | 79 | * if empty the $text is used, if false none will be used |
| 78 | 80 | * |
| 79 | 81 | * @since 12.0.0 |
| 82 | + * @return void |
|
| 80 | 83 | */ |
| 81 | 84 | public function addBodyText($text, $plainText = ''); |
| 82 | 85 | |
@@ -91,6 +94,7 @@ discard block |
||
| 91 | 94 | * @param string $plainMetaInfo Meta info that is used in the plain text email |
| 92 | 95 | * if empty the $metaInfo is used, if false none will be used |
| 93 | 96 | * @since 12.0.0 |
| 97 | + * @return void |
|
| 94 | 98 | */ |
| 95 | 99 | public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = ''); |
| 96 | 100 | |
@@ -105,6 +109,7 @@ discard block |
||
| 105 | 109 | * @param string $plainTextRight Text of right button that is used in the plain text version - if empty the $textRight is used |
| 106 | 110 | * |
| 107 | 111 | * @since 12.0.0 |
| 112 | + * @return void |
|
| 108 | 113 | */ |
| 109 | 114 | public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = ''); |
| 110 | 115 | |
@@ -117,6 +122,7 @@ discard block |
||
| 117 | 122 | * if empty the $text is used, if false none will be used |
| 118 | 123 | * |
| 119 | 124 | * @since 12.0.0 |
| 125 | + * @return void |
|
| 120 | 126 | */ |
| 121 | 127 | public function addBodyButton($text, $url, $plainText = ''); |
| 122 | 128 | |
@@ -126,6 +132,7 @@ discard block |
||
| 126 | 132 | * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
| 127 | 133 | * |
| 128 | 134 | * @since 12.0.0 |
| 135 | + * @return void |
|
| 129 | 136 | */ |
| 130 | 137 | public function addFooter($text = ''); |
| 131 | 138 | |
@@ -51,99 +51,99 @@ |
||
| 51 | 51 | * @since 12.0.0 |
| 52 | 52 | */ |
| 53 | 53 | interface IEMailTemplate { |
| 54 | - /** |
|
| 55 | - * Adds a header to the email |
|
| 56 | - * |
|
| 57 | - * @since 12.0.0 |
|
| 58 | - */ |
|
| 59 | - public function addHeader(); |
|
| 54 | + /** |
|
| 55 | + * Adds a header to the email |
|
| 56 | + * |
|
| 57 | + * @since 12.0.0 |
|
| 58 | + */ |
|
| 59 | + public function addHeader(); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Adds a heading to the email |
|
| 63 | - * |
|
| 64 | - * @param string $title |
|
| 65 | - * @param string $plainTitle|bool Title that is used in the plain text email |
|
| 66 | - * if empty the $title is used, if false none will be used |
|
| 67 | - * |
|
| 68 | - * @since 12.0.0 |
|
| 69 | - */ |
|
| 70 | - public function addHeading($title, $plainTitle = ''); |
|
| 61 | + /** |
|
| 62 | + * Adds a heading to the email |
|
| 63 | + * |
|
| 64 | + * @param string $title |
|
| 65 | + * @param string $plainTitle|bool Title that is used in the plain text email |
|
| 66 | + * if empty the $title is used, if false none will be used |
|
| 67 | + * |
|
| 68 | + * @since 12.0.0 |
|
| 69 | + */ |
|
| 70 | + public function addHeading($title, $plainTitle = ''); |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Adds a paragraph to the body of the email |
|
| 74 | - * |
|
| 75 | - * @param string $text |
|
| 76 | - * @param string|bool $plainText Text that is used in the plain text email |
|
| 77 | - * if empty the $text is used, if false none will be used |
|
| 78 | - * |
|
| 79 | - * @since 12.0.0 |
|
| 80 | - */ |
|
| 81 | - public function addBodyText($text, $plainText = ''); |
|
| 72 | + /** |
|
| 73 | + * Adds a paragraph to the body of the email |
|
| 74 | + * |
|
| 75 | + * @param string $text |
|
| 76 | + * @param string|bool $plainText Text that is used in the plain text email |
|
| 77 | + * if empty the $text is used, if false none will be used |
|
| 78 | + * |
|
| 79 | + * @since 12.0.0 |
|
| 80 | + */ |
|
| 81 | + public function addBodyText($text, $plainText = ''); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Adds a list item to the body of the email |
|
| 85 | - * |
|
| 86 | - * @param string $text |
|
| 87 | - * @param string $metaInfo |
|
| 88 | - * @param string $icon Absolute path, must be 16*16 pixels |
|
| 89 | - * @param string $plainText Text that is used in the plain text email |
|
| 90 | - * if empty the $text is used, if false none will be used |
|
| 91 | - * @param string $plainMetaInfo Meta info that is used in the plain text email |
|
| 92 | - * if empty the $metaInfo is used, if false none will be used |
|
| 93 | - * @since 12.0.0 |
|
| 94 | - */ |
|
| 95 | - public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = ''); |
|
| 83 | + /** |
|
| 84 | + * Adds a list item to the body of the email |
|
| 85 | + * |
|
| 86 | + * @param string $text |
|
| 87 | + * @param string $metaInfo |
|
| 88 | + * @param string $icon Absolute path, must be 16*16 pixels |
|
| 89 | + * @param string $plainText Text that is used in the plain text email |
|
| 90 | + * if empty the $text is used, if false none will be used |
|
| 91 | + * @param string $plainMetaInfo Meta info that is used in the plain text email |
|
| 92 | + * if empty the $metaInfo is used, if false none will be used |
|
| 93 | + * @since 12.0.0 |
|
| 94 | + */ |
|
| 95 | + public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = ''); |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Adds a button group of two buttons to the body of the email |
|
| 99 | - * |
|
| 100 | - * @param string $textLeft Text of left button |
|
| 101 | - * @param string $urlLeft URL of left button |
|
| 102 | - * @param string $textRight Text of right button |
|
| 103 | - * @param string $urlRight URL of right button |
|
| 104 | - * @param string $plainTextLeft Text of left button that is used in the plain text version - if empty the $textLeft is used |
|
| 105 | - * @param string $plainTextRight Text of right button that is used in the plain text version - if empty the $textRight is used |
|
| 106 | - * |
|
| 107 | - * @since 12.0.0 |
|
| 108 | - */ |
|
| 109 | - public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = ''); |
|
| 97 | + /** |
|
| 98 | + * Adds a button group of two buttons to the body of the email |
|
| 99 | + * |
|
| 100 | + * @param string $textLeft Text of left button |
|
| 101 | + * @param string $urlLeft URL of left button |
|
| 102 | + * @param string $textRight Text of right button |
|
| 103 | + * @param string $urlRight URL of right button |
|
| 104 | + * @param string $plainTextLeft Text of left button that is used in the plain text version - if empty the $textLeft is used |
|
| 105 | + * @param string $plainTextRight Text of right button that is used in the plain text version - if empty the $textRight is used |
|
| 106 | + * |
|
| 107 | + * @since 12.0.0 |
|
| 108 | + */ |
|
| 109 | + public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = ''); |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Adds a button to the body of the email |
|
| 113 | - * |
|
| 114 | - * @param string $text Text of button |
|
| 115 | - * @param string $url URL of button |
|
| 116 | - * @param string $plainText Text of button in plain text version |
|
| 117 | - * if empty the $text is used, if false none will be used |
|
| 118 | - * |
|
| 119 | - * @since 12.0.0 |
|
| 120 | - */ |
|
| 121 | - public function addBodyButton($text, $url, $plainText = ''); |
|
| 111 | + /** |
|
| 112 | + * Adds a button to the body of the email |
|
| 113 | + * |
|
| 114 | + * @param string $text Text of button |
|
| 115 | + * @param string $url URL of button |
|
| 116 | + * @param string $plainText Text of button in plain text version |
|
| 117 | + * if empty the $text is used, if false none will be used |
|
| 118 | + * |
|
| 119 | + * @since 12.0.0 |
|
| 120 | + */ |
|
| 121 | + public function addBodyButton($text, $url, $plainText = ''); |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
| 125 | - * |
|
| 126 | - * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
|
| 127 | - * |
|
| 128 | - * @since 12.0.0 |
|
| 129 | - */ |
|
| 130 | - public function addFooter($text = ''); |
|
| 123 | + /** |
|
| 124 | + * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
| 125 | + * |
|
| 126 | + * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
|
| 127 | + * |
|
| 128 | + * @since 12.0.0 |
|
| 129 | + */ |
|
| 130 | + public function addFooter($text = ''); |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Returns the rendered HTML email as string |
|
| 134 | - * |
|
| 135 | - * @return string |
|
| 136 | - * |
|
| 137 | - * @since 12.0.0 |
|
| 138 | - */ |
|
| 139 | - public function renderHtml(); |
|
| 132 | + /** |
|
| 133 | + * Returns the rendered HTML email as string |
|
| 134 | + * |
|
| 135 | + * @return string |
|
| 136 | + * |
|
| 137 | + * @since 12.0.0 |
|
| 138 | + */ |
|
| 139 | + public function renderHtml(); |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Returns the rendered plain text email as string |
|
| 143 | - * |
|
| 144 | - * @return string |
|
| 145 | - * |
|
| 146 | - * @since 12.0.0 |
|
| 147 | - */ |
|
| 148 | - public function renderText(); |
|
| 141 | + /** |
|
| 142 | + * Returns the rendered plain text email as string |
|
| 143 | + * |
|
| 144 | + * @return string |
|
| 145 | + * |
|
| 146 | + * @since 12.0.0 |
|
| 147 | + */ |
|
| 148 | + public function renderText(); |
|
| 149 | 149 | } |
@@ -39,27 +39,27 @@ discard block |
||
| 39 | 39 | * @package OC\Mail |
| 40 | 40 | */ |
| 41 | 41 | class EMailTemplate implements IEMailTemplate { |
| 42 | - /** @var Defaults */ |
|
| 43 | - protected $themingDefaults; |
|
| 44 | - /** @var IURLGenerator */ |
|
| 45 | - protected $urlGenerator; |
|
| 46 | - /** @var IL10N */ |
|
| 47 | - protected $l10n; |
|
| 48 | - |
|
| 49 | - /** @var string */ |
|
| 50 | - protected $htmlBody = ''; |
|
| 51 | - /** @var string */ |
|
| 52 | - protected $plainBody = ''; |
|
| 53 | - /** @var bool indicated if the footer is added */ |
|
| 54 | - protected $headerAdded = false; |
|
| 55 | - /** @var bool indicated if the body is already opened */ |
|
| 56 | - protected $bodyOpened = false; |
|
| 57 | - /** @var bool indicated if there is a list open in the body */ |
|
| 58 | - protected $bodyListOpened = false; |
|
| 59 | - /** @var bool indicated if the footer is added */ |
|
| 60 | - protected $footerAdded = false; |
|
| 61 | - |
|
| 62 | - protected $head = <<<EOF |
|
| 42 | + /** @var Defaults */ |
|
| 43 | + protected $themingDefaults; |
|
| 44 | + /** @var IURLGenerator */ |
|
| 45 | + protected $urlGenerator; |
|
| 46 | + /** @var IL10N */ |
|
| 47 | + protected $l10n; |
|
| 48 | + |
|
| 49 | + /** @var string */ |
|
| 50 | + protected $htmlBody = ''; |
|
| 51 | + /** @var string */ |
|
| 52 | + protected $plainBody = ''; |
|
| 53 | + /** @var bool indicated if the footer is added */ |
|
| 54 | + protected $headerAdded = false; |
|
| 55 | + /** @var bool indicated if the body is already opened */ |
|
| 56 | + protected $bodyOpened = false; |
|
| 57 | + /** @var bool indicated if there is a list open in the body */ |
|
| 58 | + protected $bodyListOpened = false; |
|
| 59 | + /** @var bool indicated if the footer is added */ |
|
| 60 | + protected $footerAdded = false; |
|
| 61 | + |
|
| 62 | + protected $head = <<<EOF |
|
| 63 | 63 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 64 | 64 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#f3f3f3!important"> |
| 65 | 65 | <head> |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | <center data-parsed="" style="min-width:580px;width:100%"> |
| 78 | 78 | EOF; |
| 79 | 79 | |
| 80 | - protected $tail = <<<EOF |
|
| 80 | + protected $tail = <<<EOF |
|
| 81 | 81 | </center> |
| 82 | 82 | </td> |
| 83 | 83 | </tr> |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | </html> |
| 89 | 89 | EOF; |
| 90 | 90 | |
| 91 | - protected $header = <<<EOF |
|
| 91 | + protected $header = <<<EOF |
|
| 92 | 92 | <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%%"> |
| 93 | 93 | <tr style="padding:0;text-align:left;vertical-align:top"> |
| 94 | 94 | <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"> |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | </table> |
| 122 | 122 | EOF; |
| 123 | 123 | |
| 124 | - protected $heading = <<<EOF |
|
| 124 | + protected $heading = <<<EOF |
|
| 125 | 125 | <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"> |
| 126 | 126 | <tbody> |
| 127 | 127 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | </table> |
| 141 | 141 | EOF; |
| 142 | 142 | |
| 143 | - protected $bodyBegin = <<<EOF |
|
| 143 | + protected $bodyBegin = <<<EOF |
|
| 144 | 144 | <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%"> |
| 145 | 145 | <tr style="padding:0;text-align:left;vertical-align:top"> |
| 146 | 146 | <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"> |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | </table> |
| 158 | 158 | EOF; |
| 159 | 159 | |
| 160 | - protected $bodyText = <<<EOF |
|
| 160 | + protected $bodyText = <<<EOF |
|
| 161 | 161 | <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%%"> |
| 162 | 162 | <tbody> |
| 163 | 163 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | </table> |
| 177 | 177 | EOF; |
| 178 | 178 | |
| 179 | - protected $listBegin = <<<EOF |
|
| 179 | + protected $listBegin = <<<EOF |
|
| 180 | 180 | <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%%"> |
| 181 | 181 | <tbody> |
| 182 | 182 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%"> |
| 185 | 185 | EOF; |
| 186 | 186 | |
| 187 | - protected $listItem = <<<EOF |
|
| 187 | + protected $listItem = <<<EOF |
|
| 188 | 188 | <tr style="padding:0;text-align:left;vertical-align:top"> |
| 189 | 189 | <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;"> |
| 190 | 190 | <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> |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | </tr> |
| 197 | 197 | EOF; |
| 198 | 198 | |
| 199 | - protected $listEnd = <<<EOF |
|
| 199 | + protected $listEnd = <<<EOF |
|
| 200 | 200 | </table> |
| 201 | 201 | </th> |
| 202 | 202 | </tr> |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | </table> |
| 205 | 205 | EOF; |
| 206 | 206 | |
| 207 | - protected $buttonGroup = <<<EOF |
|
| 207 | + protected $buttonGroup = <<<EOF |
|
| 208 | 208 | <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%"> |
| 209 | 209 | <tbody> |
| 210 | 210 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | </table> |
| 258 | 258 | EOF; |
| 259 | 259 | |
| 260 | - protected $button = <<<EOF |
|
| 260 | + protected $button = <<<EOF |
|
| 261 | 261 | <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%"> |
| 262 | 262 | <tbody> |
| 263 | 263 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | </table> |
| 298 | 298 | EOF; |
| 299 | 299 | |
| 300 | - protected $bodyEnd = <<<EOF |
|
| 300 | + protected $bodyEnd = <<<EOF |
|
| 301 | 301 | |
| 302 | 302 | </td> |
| 303 | 303 | </tr> |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | </table> |
| 309 | 309 | EOF; |
| 310 | 310 | |
| 311 | - protected $footer = <<<EOF |
|
| 311 | + protected $footer = <<<EOF |
|
| 312 | 312 | <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%%"> |
| 313 | 313 | <tbody> |
| 314 | 314 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -334,282 +334,282 @@ discard block |
||
| 334 | 334 | </table> |
| 335 | 335 | EOF; |
| 336 | 336 | |
| 337 | - /** |
|
| 338 | - * @param Defaults $themingDefaults |
|
| 339 | - * @param IURLGenerator $urlGenerator |
|
| 340 | - * @param IL10N $l10n |
|
| 341 | - */ |
|
| 342 | - public function __construct(Defaults $themingDefaults, |
|
| 343 | - IURLGenerator $urlGenerator, |
|
| 344 | - IL10N $l10n) { |
|
| 345 | - $this->themingDefaults = $themingDefaults; |
|
| 346 | - $this->urlGenerator = $urlGenerator; |
|
| 347 | - $this->l10n = $l10n; |
|
| 348 | - $this->htmlBody .= $this->head; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * Adds a header to the email |
|
| 353 | - */ |
|
| 354 | - public function addHeader() { |
|
| 355 | - if ($this->headerAdded) { |
|
| 356 | - return; |
|
| 357 | - } |
|
| 358 | - $this->headerAdded = true; |
|
| 359 | - |
|
| 360 | - $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo()); |
|
| 361 | - $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Adds a heading to the email |
|
| 366 | - * |
|
| 367 | - * @param string $title |
|
| 368 | - * @param string $plainTitle|bool Title that is used in the plain text email |
|
| 369 | - * if empty the $title is used, if false none will be used |
|
| 370 | - */ |
|
| 371 | - public function addHeading($title, $plainTitle = '') { |
|
| 372 | - if ($this->footerAdded) { |
|
| 373 | - return; |
|
| 374 | - } |
|
| 375 | - if ($plainTitle === '') { |
|
| 376 | - $plainTitle = $title; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
|
| 380 | - if ($plainTitle !== false) { |
|
| 381 | - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
| 382 | - } |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * Open the HTML body when it is not already |
|
| 387 | - */ |
|
| 388 | - protected function ensureBodyIsOpened() { |
|
| 389 | - if ($this->bodyOpened) { |
|
| 390 | - return; |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - $this->htmlBody .= $this->bodyBegin; |
|
| 394 | - $this->bodyOpened = true; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * Adds a paragraph to the body of the email |
|
| 399 | - * |
|
| 400 | - * @param string $text |
|
| 401 | - * @param string|bool $plainText Text that is used in the plain text email |
|
| 402 | - * if empty the $text is used, if false none will be used |
|
| 403 | - */ |
|
| 404 | - public function addBodyText($text, $plainText = '') { |
|
| 405 | - if ($this->footerAdded) { |
|
| 406 | - return; |
|
| 407 | - } |
|
| 408 | - if ($plainText === '') { |
|
| 409 | - $plainText = $text; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - $this->ensureBodyIsOpened(); |
|
| 413 | - |
|
| 414 | - $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); |
|
| 415 | - if ($plainText !== false) { |
|
| 416 | - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
| 417 | - } |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * Adds a list item to the body of the email |
|
| 422 | - * |
|
| 423 | - * @param string $text |
|
| 424 | - * @param string $metaInfo |
|
| 425 | - * @param string $icon Absolute path, must be 16*16 pixels |
|
| 426 | - * @param string $plainText Text that is used in the plain text email |
|
| 427 | - * if empty the $text is used, if false none will be used |
|
| 428 | - * @param string $plainMetaInfo Meta info that is used in the plain text email |
|
| 429 | - * if empty the $metaInfo is used, if false none will be used |
|
| 430 | - * @since 12.0.0 |
|
| 431 | - */ |
|
| 432 | - public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') { |
|
| 433 | - $this->ensureBodyListOpened(); |
|
| 434 | - |
|
| 435 | - if ($plainText === '') { |
|
| 436 | - $plainText = $text; |
|
| 437 | - } |
|
| 438 | - if ($plainMetaInfo === '') { |
|
| 439 | - $plainMetaInfo = $metaInfo; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - $htmlText = htmlspecialchars($text); |
|
| 443 | - if ($metaInfo) { |
|
| 444 | - $htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText; |
|
| 445 | - } |
|
| 446 | - if ($icon !== '') { |
|
| 447 | - $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
| 448 | - } else { |
|
| 449 | - $icon = '•'; |
|
| 450 | - } |
|
| 451 | - $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
|
| 452 | - if ($plainText !== false) { |
|
| 453 | - $this->plainBody .= ' * ' . $plainText; |
|
| 454 | - if ($plainMetaInfo !== false) { |
|
| 455 | - $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
| 456 | - } |
|
| 457 | - $this->plainBody .= PHP_EOL; |
|
| 458 | - } |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - protected function ensureBodyListOpened() { |
|
| 462 | - if ($this->bodyListOpened) { |
|
| 463 | - return; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - $this->ensureBodyIsOpened(); |
|
| 467 | - $this->bodyListOpened = true; |
|
| 468 | - $this->htmlBody .= $this->listBegin; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - protected function ensureBodyListClosed() { |
|
| 472 | - if (!$this->bodyListOpened) { |
|
| 473 | - return; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - $this->bodyListOpened = false; |
|
| 477 | - $this->htmlBody .= $this->listEnd; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - /** |
|
| 481 | - * Adds a button group of two buttons to the body of the email |
|
| 482 | - * |
|
| 483 | - * @param string $textLeft Text of left button |
|
| 484 | - * @param string $urlLeft URL of left button |
|
| 485 | - * @param string $textRight Text of right button |
|
| 486 | - * @param string $urlRight URL of right button |
|
| 487 | - * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used |
|
| 488 | - * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used |
|
| 489 | - */ |
|
| 490 | - public function addBodyButtonGroup($textLeft, |
|
| 491 | - $urlLeft, |
|
| 492 | - $textRight, |
|
| 493 | - $urlRight, |
|
| 494 | - $plainTextLeft = '', |
|
| 495 | - $plainTextRight = '') { |
|
| 496 | - if ($this->footerAdded) { |
|
| 497 | - return; |
|
| 498 | - } |
|
| 499 | - if ($plainTextLeft === '') { |
|
| 500 | - $plainTextLeft = $textLeft; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - if ($plainTextRight === '') { |
|
| 504 | - $plainTextRight = $textRight; |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - $this->ensureBodyIsOpened(); |
|
| 508 | - $this->ensureBodyListClosed(); |
|
| 509 | - |
|
| 510 | - $color = $this->themingDefaults->getColorPrimary(); |
|
| 511 | - |
|
| 512 | - $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]); |
|
| 513 | - $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
| 514 | - $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
| 515 | - |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * Adds a button to the body of the email |
|
| 520 | - * |
|
| 521 | - * @param string $text Text of button |
|
| 522 | - * @param string $url URL of button |
|
| 523 | - * @param string $plainText Text of button in plain text version |
|
| 524 | - * if empty the $text is used, if false none will be used |
|
| 525 | - * |
|
| 526 | - * @since 12.0.0 |
|
| 527 | - */ |
|
| 528 | - public function addBodyButton($text, $url, $plainText = '') { |
|
| 529 | - if ($this->footerAdded) { |
|
| 530 | - return; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - $this->ensureBodyIsOpened(); |
|
| 534 | - $this->ensureBodyListClosed(); |
|
| 535 | - |
|
| 536 | - if ($plainText === '') { |
|
| 537 | - $plainText = $text; |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - $color = $this->themingDefaults->getColorPrimary(); |
|
| 541 | - $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]); |
|
| 542 | - |
|
| 543 | - if ($plainText !== false) { |
|
| 544 | - $this->plainBody .= $plainText . ': '; |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - $this->plainBody .= $url . PHP_EOL; |
|
| 548 | - |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - /** |
|
| 552 | - * Close the HTML body when it is open |
|
| 553 | - */ |
|
| 554 | - protected function ensureBodyIsClosed() { |
|
| 555 | - if (!$this->bodyOpened) { |
|
| 556 | - return; |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - $this->ensureBodyListClosed(); |
|
| 560 | - |
|
| 561 | - $this->htmlBody .= $this->bodyEnd; |
|
| 562 | - $this->bodyOpened = false; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
| 567 | - * |
|
| 568 | - * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
|
| 569 | - */ |
|
| 570 | - public function addFooter($text = '') { |
|
| 571 | - if($text === '') { |
|
| 572 | - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - if ($this->footerAdded) { |
|
| 576 | - return; |
|
| 577 | - } |
|
| 578 | - $this->footerAdded = true; |
|
| 579 | - |
|
| 580 | - $this->ensureBodyIsClosed(); |
|
| 581 | - |
|
| 582 | - $this->htmlBody .= vsprintf($this->footer, [$text]); |
|
| 583 | - $this->htmlBody .= $this->tail; |
|
| 584 | - $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
| 585 | - $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * Returns the rendered HTML email as string |
|
| 590 | - * |
|
| 591 | - * @return string |
|
| 592 | - */ |
|
| 593 | - public function renderHtml() { |
|
| 594 | - if (!$this->footerAdded) { |
|
| 595 | - $this->footerAdded = true; |
|
| 596 | - $this->ensureBodyIsClosed(); |
|
| 597 | - $this->htmlBody .= $this->tail; |
|
| 598 | - } |
|
| 599 | - return $this->htmlBody; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * Returns the rendered plain text email as string |
|
| 604 | - * |
|
| 605 | - * @return string |
|
| 606 | - */ |
|
| 607 | - public function renderText() { |
|
| 608 | - if (!$this->footerAdded) { |
|
| 609 | - $this->footerAdded = true; |
|
| 610 | - $this->ensureBodyIsClosed(); |
|
| 611 | - $this->htmlBody .= $this->tail; |
|
| 612 | - } |
|
| 613 | - return $this->plainBody; |
|
| 614 | - } |
|
| 337 | + /** |
|
| 338 | + * @param Defaults $themingDefaults |
|
| 339 | + * @param IURLGenerator $urlGenerator |
|
| 340 | + * @param IL10N $l10n |
|
| 341 | + */ |
|
| 342 | + public function __construct(Defaults $themingDefaults, |
|
| 343 | + IURLGenerator $urlGenerator, |
|
| 344 | + IL10N $l10n) { |
|
| 345 | + $this->themingDefaults = $themingDefaults; |
|
| 346 | + $this->urlGenerator = $urlGenerator; |
|
| 347 | + $this->l10n = $l10n; |
|
| 348 | + $this->htmlBody .= $this->head; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * Adds a header to the email |
|
| 353 | + */ |
|
| 354 | + public function addHeader() { |
|
| 355 | + if ($this->headerAdded) { |
|
| 356 | + return; |
|
| 357 | + } |
|
| 358 | + $this->headerAdded = true; |
|
| 359 | + |
|
| 360 | + $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo()); |
|
| 361 | + $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Adds a heading to the email |
|
| 366 | + * |
|
| 367 | + * @param string $title |
|
| 368 | + * @param string $plainTitle|bool Title that is used in the plain text email |
|
| 369 | + * if empty the $title is used, if false none will be used |
|
| 370 | + */ |
|
| 371 | + public function addHeading($title, $plainTitle = '') { |
|
| 372 | + if ($this->footerAdded) { |
|
| 373 | + return; |
|
| 374 | + } |
|
| 375 | + if ($plainTitle === '') { |
|
| 376 | + $plainTitle = $title; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
|
| 380 | + if ($plainTitle !== false) { |
|
| 381 | + $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
| 382 | + } |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * Open the HTML body when it is not already |
|
| 387 | + */ |
|
| 388 | + protected function ensureBodyIsOpened() { |
|
| 389 | + if ($this->bodyOpened) { |
|
| 390 | + return; |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + $this->htmlBody .= $this->bodyBegin; |
|
| 394 | + $this->bodyOpened = true; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * Adds a paragraph to the body of the email |
|
| 399 | + * |
|
| 400 | + * @param string $text |
|
| 401 | + * @param string|bool $plainText Text that is used in the plain text email |
|
| 402 | + * if empty the $text is used, if false none will be used |
|
| 403 | + */ |
|
| 404 | + public function addBodyText($text, $plainText = '') { |
|
| 405 | + if ($this->footerAdded) { |
|
| 406 | + return; |
|
| 407 | + } |
|
| 408 | + if ($plainText === '') { |
|
| 409 | + $plainText = $text; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + $this->ensureBodyIsOpened(); |
|
| 413 | + |
|
| 414 | + $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); |
|
| 415 | + if ($plainText !== false) { |
|
| 416 | + $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * Adds a list item to the body of the email |
|
| 422 | + * |
|
| 423 | + * @param string $text |
|
| 424 | + * @param string $metaInfo |
|
| 425 | + * @param string $icon Absolute path, must be 16*16 pixels |
|
| 426 | + * @param string $plainText Text that is used in the plain text email |
|
| 427 | + * if empty the $text is used, if false none will be used |
|
| 428 | + * @param string $plainMetaInfo Meta info that is used in the plain text email |
|
| 429 | + * if empty the $metaInfo is used, if false none will be used |
|
| 430 | + * @since 12.0.0 |
|
| 431 | + */ |
|
| 432 | + public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') { |
|
| 433 | + $this->ensureBodyListOpened(); |
|
| 434 | + |
|
| 435 | + if ($plainText === '') { |
|
| 436 | + $plainText = $text; |
|
| 437 | + } |
|
| 438 | + if ($plainMetaInfo === '') { |
|
| 439 | + $plainMetaInfo = $metaInfo; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + $htmlText = htmlspecialchars($text); |
|
| 443 | + if ($metaInfo) { |
|
| 444 | + $htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText; |
|
| 445 | + } |
|
| 446 | + if ($icon !== '') { |
|
| 447 | + $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
| 448 | + } else { |
|
| 449 | + $icon = '•'; |
|
| 450 | + } |
|
| 451 | + $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
|
| 452 | + if ($plainText !== false) { |
|
| 453 | + $this->plainBody .= ' * ' . $plainText; |
|
| 454 | + if ($plainMetaInfo !== false) { |
|
| 455 | + $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
| 456 | + } |
|
| 457 | + $this->plainBody .= PHP_EOL; |
|
| 458 | + } |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + protected function ensureBodyListOpened() { |
|
| 462 | + if ($this->bodyListOpened) { |
|
| 463 | + return; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + $this->ensureBodyIsOpened(); |
|
| 467 | + $this->bodyListOpened = true; |
|
| 468 | + $this->htmlBody .= $this->listBegin; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + protected function ensureBodyListClosed() { |
|
| 472 | + if (!$this->bodyListOpened) { |
|
| 473 | + return; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + $this->bodyListOpened = false; |
|
| 477 | + $this->htmlBody .= $this->listEnd; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * Adds a button group of two buttons to the body of the email |
|
| 482 | + * |
|
| 483 | + * @param string $textLeft Text of left button |
|
| 484 | + * @param string $urlLeft URL of left button |
|
| 485 | + * @param string $textRight Text of right button |
|
| 486 | + * @param string $urlRight URL of right button |
|
| 487 | + * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used |
|
| 488 | + * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used |
|
| 489 | + */ |
|
| 490 | + public function addBodyButtonGroup($textLeft, |
|
| 491 | + $urlLeft, |
|
| 492 | + $textRight, |
|
| 493 | + $urlRight, |
|
| 494 | + $plainTextLeft = '', |
|
| 495 | + $plainTextRight = '') { |
|
| 496 | + if ($this->footerAdded) { |
|
| 497 | + return; |
|
| 498 | + } |
|
| 499 | + if ($plainTextLeft === '') { |
|
| 500 | + $plainTextLeft = $textLeft; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + if ($plainTextRight === '') { |
|
| 504 | + $plainTextRight = $textRight; |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + $this->ensureBodyIsOpened(); |
|
| 508 | + $this->ensureBodyListClosed(); |
|
| 509 | + |
|
| 510 | + $color = $this->themingDefaults->getColorPrimary(); |
|
| 511 | + |
|
| 512 | + $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]); |
|
| 513 | + $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
| 514 | + $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
| 515 | + |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * Adds a button to the body of the email |
|
| 520 | + * |
|
| 521 | + * @param string $text Text of button |
|
| 522 | + * @param string $url URL of button |
|
| 523 | + * @param string $plainText Text of button in plain text version |
|
| 524 | + * if empty the $text is used, if false none will be used |
|
| 525 | + * |
|
| 526 | + * @since 12.0.0 |
|
| 527 | + */ |
|
| 528 | + public function addBodyButton($text, $url, $plainText = '') { |
|
| 529 | + if ($this->footerAdded) { |
|
| 530 | + return; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + $this->ensureBodyIsOpened(); |
|
| 534 | + $this->ensureBodyListClosed(); |
|
| 535 | + |
|
| 536 | + if ($plainText === '') { |
|
| 537 | + $plainText = $text; |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + $color = $this->themingDefaults->getColorPrimary(); |
|
| 541 | + $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]); |
|
| 542 | + |
|
| 543 | + if ($plainText !== false) { |
|
| 544 | + $this->plainBody .= $plainText . ': '; |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + $this->plainBody .= $url . PHP_EOL; |
|
| 548 | + |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * Close the HTML body when it is open |
|
| 553 | + */ |
|
| 554 | + protected function ensureBodyIsClosed() { |
|
| 555 | + if (!$this->bodyOpened) { |
|
| 556 | + return; |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + $this->ensureBodyListClosed(); |
|
| 560 | + |
|
| 561 | + $this->htmlBody .= $this->bodyEnd; |
|
| 562 | + $this->bodyOpened = false; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
| 567 | + * |
|
| 568 | + * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
|
| 569 | + */ |
|
| 570 | + public function addFooter($text = '') { |
|
| 571 | + if($text === '') { |
|
| 572 | + $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + if ($this->footerAdded) { |
|
| 576 | + return; |
|
| 577 | + } |
|
| 578 | + $this->footerAdded = true; |
|
| 579 | + |
|
| 580 | + $this->ensureBodyIsClosed(); |
|
| 581 | + |
|
| 582 | + $this->htmlBody .= vsprintf($this->footer, [$text]); |
|
| 583 | + $this->htmlBody .= $this->tail; |
|
| 584 | + $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
| 585 | + $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * Returns the rendered HTML email as string |
|
| 590 | + * |
|
| 591 | + * @return string |
|
| 592 | + */ |
|
| 593 | + public function renderHtml() { |
|
| 594 | + if (!$this->footerAdded) { |
|
| 595 | + $this->footerAdded = true; |
|
| 596 | + $this->ensureBodyIsClosed(); |
|
| 597 | + $this->htmlBody .= $this->tail; |
|
| 598 | + } |
|
| 599 | + return $this->htmlBody; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + /** |
|
| 603 | + * Returns the rendered plain text email as string |
|
| 604 | + * |
|
| 605 | + * @return string |
|
| 606 | + */ |
|
| 607 | + public function renderText() { |
|
| 608 | + if (!$this->footerAdded) { |
|
| 609 | + $this->footerAdded = true; |
|
| 610 | + $this->ensureBodyIsClosed(); |
|
| 611 | + $this->htmlBody .= $this->tail; |
|
| 612 | + } |
|
| 613 | + return $this->plainBody; |
|
| 614 | + } |
|
| 615 | 615 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
| 380 | 380 | if ($plainTitle !== false) { |
| 381 | - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
| 381 | + $this->plainBody .= $plainTitle.PHP_EOL.PHP_EOL; |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | |
| 414 | 414 | $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); |
| 415 | 415 | if ($plainText !== false) { |
| 416 | - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
| 416 | + $this->plainBody .= $plainText.PHP_EOL.PHP_EOL; |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | |
@@ -441,18 +441,18 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | $htmlText = htmlspecialchars($text); |
| 443 | 443 | if ($metaInfo) { |
| 444 | - $htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText; |
|
| 444 | + $htmlText = '<em style="color:#777;">'.htmlspecialchars($metaInfo).'</em><br>'.$htmlText; |
|
| 445 | 445 | } |
| 446 | 446 | if ($icon !== '') { |
| 447 | - $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
| 447 | + $icon = '<img src="'.htmlspecialchars($icon).'" alt="•">'; |
|
| 448 | 448 | } else { |
| 449 | 449 | $icon = '•'; |
| 450 | 450 | } |
| 451 | 451 | $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
| 452 | 452 | if ($plainText !== false) { |
| 453 | - $this->plainBody .= ' * ' . $plainText; |
|
| 453 | + $this->plainBody .= ' * '.$plainText; |
|
| 454 | 454 | if ($plainMetaInfo !== false) { |
| 455 | - $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
| 455 | + $this->plainBody .= ' ('.$plainMetaInfo.')'; |
|
| 456 | 456 | } |
| 457 | 457 | $this->plainBody .= PHP_EOL; |
| 458 | 458 | } |
@@ -510,8 +510,8 @@ discard block |
||
| 510 | 510 | $color = $this->themingDefaults->getColorPrimary(); |
| 511 | 511 | |
| 512 | 512 | $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]); |
| 513 | - $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
| 514 | - $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
| 513 | + $this->plainBody .= $plainTextLeft.': '.$urlLeft.PHP_EOL; |
|
| 514 | + $this->plainBody .= $plainTextRight.': '.$urlRight.PHP_EOL.PHP_EOL; |
|
| 515 | 515 | |
| 516 | 516 | } |
| 517 | 517 | |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]); |
| 542 | 542 | |
| 543 | 543 | if ($plainText !== false) { |
| 544 | - $this->plainBody .= $plainText . ': '; |
|
| 544 | + $this->plainBody .= $plainText.': '; |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $this->plainBody .= $url . PHP_EOL; |
|
| 547 | + $this->plainBody .= $url.PHP_EOL; |
|
| 548 | 548 | |
| 549 | 549 | } |
| 550 | 550 | |
@@ -568,8 +568,8 @@ discard block |
||
| 568 | 568 | * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
| 569 | 569 | */ |
| 570 | 570 | public function addFooter($text = '') { |
| 571 | - if($text === '') { |
|
| 572 | - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 571 | + if ($text === '') { |
|
| 572 | + $text = $this->themingDefaults->getName().' - '.$this->themingDefaults->getSlogan().'<br>'.$this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | if ($this->footerAdded) { |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | $this->htmlBody .= vsprintf($this->footer, [$text]); |
| 583 | 583 | $this->htmlBody .= $this->tail; |
| 584 | - $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
| 584 | + $this->plainBody .= PHP_EOL.'-- '.PHP_EOL; |
|
| 585 | 585 | $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
| 586 | 586 | } |
| 587 | 587 | |