2017-04-06 21:20:47 +03:00
< ? php
2019-12-03 21:57:53 +03:00
2018-03-01 23:15:39 +03:00
declare ( strict_types = 1 );
2019-12-03 21:57:53 +03:00
2017-04-06 21:20:47 +03:00
/**
* @ copyright 2017 , Morris Jobke < hey @ morrisjobke . de >
2017-04-07 15:51:05 +03:00
* @ copyright 2017 , Lukas Reschke < lukas @ statuscode . ch >
2017-04-06 21:20:47 +03:00
*
2017-11-06 17:56:42 +03:00
* @ author Bjoern Schiessle < bjoern @ schiessle . org >
2019-12-03 21:57:53 +03:00
* @ author brad2014 < brad2014 @ users . noreply . github . com >
2020-09-07 15:37:44 +03:00
* @ author Brad Rubenstein < brad @ wbr . tech >
2020-04-29 12:57:22 +03:00
* @ author Christoph Wurst < christoph @ winzerhof - wurst . at >
2020-08-24 15:54:25 +03:00
* @ author Jan - Christoph Borchardt < hey @ jancborchardt . net >
2017-11-06 17:56:42 +03:00
* @ author Joas Schilling < coding @ schilljs . com >
2019-12-03 21:57:53 +03:00
* @ author Julius Härtl < jus @ bitgrid . net >
2020-04-29 12:57:22 +03:00
* @ author Liam JACK < liamjack @ users . noreply . github . com >
2017-04-07 15:51:05 +03:00
* @ author Lukas Reschke < lukas @ statuscode . ch >
2017-11-06 17:56:42 +03:00
* @ author Morris Jobke < hey @ morrisjobke . de >
2019-12-03 21:57:53 +03:00
* @ author Roeland Jago Douma < roeland @ famdouma . nl >
2020-07-08 11:26:34 +03:00
* @ author Simon Spannagel < simonspa @ kth . se >
2020-08-24 15:54:25 +03:00
* @ author Tomasz Paluszkiewicz < tomasz . paluszkiewicz @ gmail . com >
2017-04-06 21:20:47 +03:00
*
* @ license GNU AGPL version 3 or any later version
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation , either version 3 of the
* License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Affero General Public License for more details .
*
* You should have received a copy of the GNU Affero General Public License
2019-12-03 21:57:53 +03:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2017-04-06 21:20:47 +03:00
*
*/
namespace OC\Mail ;
2017-04-07 23:42:43 +03:00
use OCP\Defaults ;
2017-04-07 15:51:05 +03:00
use OCP\IURLGenerator ;
2020-03-31 15:02:39 +03:00
use OCP\L10N\IFactory ;
2017-04-11 17:35:46 +03:00
use OCP\Mail\IEMailTemplate ;
2017-04-06 21:20:47 +03:00
/**
* Class EMailTemplate
*
* addBodyText and addBodyButtonGroup automatically opens the body
2017-04-19 01:09:25 +03:00
* addFooter , renderHtml , renderText automatically closes the body and the HTML if opened
2017-04-06 21:20:47 +03:00
*
* @ package OC\Mail
*/
class EMailTemplate implements IEMailTemplate {
2017-04-07 23:42:43 +03:00
/** @var Defaults */
2017-04-07 15:51:05 +03:00
protected $themingDefaults ;
/** @var IURLGenerator */
protected $urlGenerator ;
2020-03-31 15:02:39 +03:00
/** @var IFactory */
protected $l10nFactory ;
2017-08-24 18:54:22 +03:00
/** @var string */
protected $emailId ;
/** @var array */
protected $data ;
2017-04-06 21:20:47 +03:00
2017-09-15 11:51:55 +03:00
/** @var string */
protected $subject = '' ;
2017-04-06 21:20:47 +03:00
/** @var string */
protected $htmlBody = '' ;
/** @var string */
protected $plainBody = '' ;
/** @var bool indicated if the footer is added */
protected $headerAdded = false ;
/** @var bool indicated if the body is already opened */
protected $bodyOpened = false ;
2017-04-24 14:48:27 +03:00
/** @var bool indicated if there is a list open in the body */
protected $bodyListOpened = false ;
2017-04-06 21:20:47 +03:00
/** @var bool indicated if the footer is added */
protected $footerAdded = false ;
protected $head = <<< EOF
<! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
2020-04-09 11:55:43 +03:00
< html xmlns = " http://www.w3.org/1999/xhtml " lang = " en " xml : lang = " en " style = " -webkit-font-smoothing:antialiased;background:#fff!important " >
2017-04-06 21:20:47 +03:00
< head >
< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " >
< meta name = " viewport " content = " width=device-width " >
< title ></ title >
2020-04-09 11:55:43 +03:00
< style type = " text/css " >@ media only screen { html { min - height : 100 % ; background : #fff}}@media only screen and (max-width:610px){table.body img{width:auto;height:auto}table.body center{min-width:0!important}table.body .container{width:95%!important}table.body .columns{height:auto!important;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:30px!important;padding-right:30px!important}th.small-12{display:inline-block!important;width:100%!important}table.menu{width:100%!important}table.menu td,table.menu th{width:auto!important;display:inline-block!important}table.menu.vertical td,table.menu.vertical th{display:block!important}table.menu[align=center]{width:auto!important}}</style>
2017-04-06 21:20:47 +03:00
</ head >
2020-04-30 12:16:40 +03:00
< body style = " -moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;margin:0;background:#fff!important;box-sizing:border-box;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;min-width:100%;padding:0;text-align:left;width:100%!important " >
2017-04-06 21:20:47 +03:00
< span class = " preheader " style = " color:#F5F5F5;display:none!important;font-size:1px;line-height:1px;max-height:0;max-width:0;mso-hide:all!important;opacity:0;overflow:hidden;visibility:hidden " >
</ span >
2020-04-09 12:32:02 +03:00
< table class = " body " style = " -webkit-font-smoothing:antialiased;margin:0;background:#fff;border-collapse:collapse;border-spacing: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;vertical-align:top;width:100% " >
2017-04-06 21:20:47 +03:00
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td class = " center " align = " center " valign = " top " 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 " >
2017-04-06 21:20:47 +03:00
< center data - parsed = " " style = " min-width:580px;width:100% " >
EOF ;
protected $tail = <<< EOF
</ center >
</ td >
</ tr >
</ table >
<!-- prevent Gmail on iOS font size manipulation -->
< div style = " display:none;white-space:nowrap;font:15px courier;line-height:0 " >& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; </ div >
</ body >
</ html >
2020-04-30 12:16:40 +03:00
2017-04-06 21:20:47 +03:00
EOF ;
protected $header = <<< EOF
2020-04-09 11:55:43 +03:00
< 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%% " >
2017-04-06 21:20:47 +03:00
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2020-04-09 11:55:43 +03:00
< table align = " center " class = " container " style = " Margin:0 auto;background:0 0;border-collapse:collapse;border-spacing:0;margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:150px " >
2017-04-06 21:20:47 +03:00
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2017-04-06 21:20:47 +03:00
< table class = " row collapse " style = " border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-11-14 18:19:44 +03:00
< center data - parsed = " " style = " background-color:%s;min-width:175px;max-height:175px; padding:35px 0px;border-radius:200px " >
< img class = " logo float-center " src = " %s " alt = " %s " align = " center " style = " -ms-interpolation-mode:bicubic;clear:both;display:block;float:none;margin:0 auto;outline:0;text-align:center;text-decoration:none;max-height:105px;max-width:105px;width:auto;height:auto " >
2017-04-06 21:20:47 +03:00
</ center >
</ tr >
</ tbody >
</ table >
</ td >
</ tr >
</ tbody >
</ table >
</ td >
</ tr >
</ table >
< 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%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td height = " 40px " style = " -moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-size:80px;font-weight:400;hyphens:auto;line-height:80px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word " >& #xA0;</td>
2017-04-06 21:20:47 +03:00
</ tr >
</ tbody >
</ table >
EOF ;
protected $heading = <<< EOF
< 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 " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2020-04-09 12:39:25 +03:00
< h1 class = " text-center " style = " Margin:0;Margin-bottom:10px;color:inherit;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:center;word-wrap:normal " >% s </ h1 >
2017-04-06 21:20:47 +03:00
</ td >
</ tr >
</ tbody >
</ table >
< 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%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:39:25 +03:00
< td height = " 36px " style = " -moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-size:40px;font-weight:400;hyphens:auto;line-height:36px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word " >& #xA0;</td>
2017-04-06 21:20:47 +03:00
</ tr >
</ tbody >
</ table >
EOF ;
protected $bodyBegin = <<< EOF
< 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% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2020-04-09 12:39:25 +03:00
< table align = " center " class = " container " style = " Margin:0 auto;background:#fff;border-collapse:collapse;border-spacing:0;margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px " >
2017-04-06 21:20:47 +03:00
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2017-04-06 21:20:47 +03:00
EOF ;
protected $bodyText = <<< EOF
< 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%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< th class = " small-12 large-12 columns first last " style = " Margin:0 auto;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 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px " >
2017-04-06 21:20:47 +03:00
< table style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< th 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 " >
2020-04-09 12:39:25 +03:00
< p 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;text-align:center " >% s </ p >
2017-04-06 21:20:47 +03:00
</ th >
2020-04-09 12:32:02 +03:00
< th class = " expander " 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!important;text-align:left;visibility:hidden;width:0 " ></ th >
2017-04-06 21:20:47 +03:00
</ tr >
</ table >
</ th >
</ tr >
</ tbody >
</ table >
2017-04-24 14:48:27 +03:00
EOF ;
2020-04-10 15:19:56 +03:00
// note: listBegin (like bodyBegin) is not processed through sprintf, so "%" is not escaped as "%%". (bug #12151)
2017-04-24 14:48:27 +03:00
protected $listBegin = <<< EOF
2018-10-31 01:26:16 +03:00
< 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% " >
2017-04-24 14:48:27 +03:00
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< th class = " small-12 large-12 columns first last " style = " Margin:0 auto;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 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px " >
2018-10-31 01:26:16 +03:00
< table style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100% " >
2017-04-24 14:48:27 +03:00
EOF ;
protected $listItem = <<< EOF
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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; " >
< 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 >
2017-04-24 14:48:27 +03:00
</ td >
2020-04-09 12:32:02 +03:00
< 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 " >
< p class = " text-left " style = " Margin:0;Margin-bottom:10px;color:#555;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 >
2017-04-24 14:48:27 +03:00
</ td >
2020-04-09 12:32:02 +03:00
< td class = " expander " 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!important;text-align:left;visibility:hidden;width:0 " ></ td >
2017-04-24 14:48:27 +03:00
</ tr >
EOF ;
protected $listEnd = <<< EOF
</ table >
</ th >
</ tr >
</ tbody >
</ table >
2017-04-06 21:20:47 +03:00
EOF ;
protected $buttonGroup = <<< EOF
< table class = " spacer " style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td height = " 50px " 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:50px;font-weight:400;hyphens:auto;line-height:50px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word " >& #xA0;</td>
2017-04-06 21:20:47 +03:00
</ tr >
</ tbody >
</ table >
< table align = " center " class = " row btn-group " style = " border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< th class = " small-12 large-12 columns first last " style = " Margin:0 auto;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 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px " >
2017-04-06 21:20:47 +03:00
< table style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< th 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 " >
2017-04-06 21:20:47 +03:00
< center data - parsed = " " style = " min-width:490px;width:100%% " >
2020-04-12 14:04:56 +03:00
< table class = " button btn default primary float-center " style = " Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;max-height:60px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto;background:%1 \$ s;background-color:%1 \$ s;color:#fefefe; " >
2017-04-06 21:20:47 +03:00
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2017-04-06 21:20:47 +03:00
< table style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td style = " -moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid %2 \$ s;border-collapse:collapse!important;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 " >
< a href = " %3 \$ s " style = " Margin:0;border:0 solid %4 \$ s;border-radius:2px;color:%5 \$ s;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;outline:1px solid %6 \$ s;text-decoration:none " >% 7 \ $s </ a >
2017-04-06 21:20:47 +03:00
</ td >
</ tr >
</ table >
</ td >
</ tr >
</ table >
< table class = " button btn default secondary float-center " style = " Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;max-height:40px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2017-04-06 21:20:47 +03:00
< table style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td style = " -moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:#777;border:0 solid #777;border-collapse:collapse!important;color:#fefefe;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 " >
< a href = " %8 \$ s " style = " Margin:0;background-color:#fff;border:0 solid #777;border-radius:2px;color:#6C6C6C!important;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;outline:1px solid #CBCBCB;padding:10px 25px 10px 25px;text-align:left;text-decoration:none " >% 9 \ $s </ a >
2017-04-06 21:20:47 +03:00
</ td >
</ tr >
</ table >
</ td >
</ tr >
</ table >
</ center >
</ th >
2020-04-09 12:32:02 +03:00
< th class = " expander " 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!important;text-align:left;visibility:hidden;width:0 " ></ th >
2017-04-06 21:20:47 +03:00
</ tr >
</ table >
</ th >
</ tr >
</ tbody >
</ table >
2017-04-12 00:13:34 +03:00
EOF ;
protected $button = <<< EOF
< table class = " spacer " style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td height = " 50px " 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:50px;font-weight:400;hyphens:auto;line-height:50px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word " >& #xA0;</td>
2017-04-12 00:13:34 +03:00
</ tr >
</ tbody >
</ table >
< table align = " center " class = " row btn-group " style = " border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< th class = " small-12 large-12 columns first last " style = " Margin:0 auto;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 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px " >
2017-04-12 00:13:34 +03:00
< table style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< th 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 " >
2017-04-12 00:13:34 +03:00
< center data - parsed = " " style = " min-width:490px;width:100%% " >
2020-04-12 14:04:56 +03:00
< table class = " button btn default primary float-center " style = " Margin:0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0;max-height:60px;padding:0;text-align:center;vertical-align:top;width:auto;background:%1 \$ s;color:#fefefe;background-color:%1 \$ s; " >
2017-04-12 00:13:34 +03:00
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2017-04-12 00:13:34 +03:00
< table style = " border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-12-02 23:56:55 +03:00
< td style = " -moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid %2 \$ s;border-collapse:collapse!important;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 " >
2020-04-09 12:32:02 +03:00
< a href = " %3 \$ s " style = " Margin:0;border:0 solid %4 \$ s;border-radius:2px;color:%5 \$ s;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;outline:1px solid %5 \$ s;text-decoration:none " >% 7 \ $s </ a >
2017-04-12 00:13:34 +03:00
</ td >
</ tr >
</ table >
</ td >
</ tr >
</ table >
</ center >
</ th >
2020-04-09 12:32:02 +03:00
< th class = " expander " 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!important;text-align:left;visibility:hidden;width:0 " ></ th >
2017-04-12 00:13:34 +03:00
</ tr >
</ table >
</ th >
</ tr >
</ tbody >
</ table >
2017-04-06 21:20:47 +03:00
EOF ;
protected $bodyEnd = <<< EOF
</ td >
</ tr >
</ tbody >
</ table >
</ td >
</ tr >
</ table >
EOF ;
protected $footer = <<< EOF
< 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%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td height = " 60px " 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:60px;font-weight:400;hyphens:auto;line-height:60px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word " >& #xA0;</td>
2017-04-06 21:20:47 +03:00
</ tr >
</ tbody >
</ table >
< table align = " center " class = " wrapper footer 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%% " >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< 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 " >
2017-04-07 15:51:05 +03:00
< center data - parsed = " " style = " min-width:580px;width:100%% " >
2017-04-06 21:20:47 +03:00
< 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%% " >
< tbody >
< tr style = " padding:0;text-align:left;vertical-align:top " >
2020-04-09 12:32:02 +03:00
< td height = " 15px " 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:15px;font-weight:400;hyphens:auto;line-height:15px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word " >& #xA0;</td>
2017-04-06 21:20:47 +03:00
</ tr >
</ tbody >
</ table >
2020-04-09 12:32:02 +03:00
< p class = " text-center float-center " align = " center " style = " Margin:0;Margin-bottom:10px;color:#C8C8C8;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:12px;font-weight:400;line-height:16px;margin:0;margin-bottom:10px;padding:0;text-align:center " >% s </ p >
2017-04-06 21:20:47 +03:00
</ center >
</ td >
</ tr >
</ table >
EOF ;
2017-04-07 23:42:43 +03:00
public function __construct ( Defaults $themingDefaults ,
2017-04-07 15:51:05 +03:00
IURLGenerator $urlGenerator ,
2020-03-31 15:02:39 +03:00
IFactory $l10nFactory ,
2017-09-04 16:07:19 +03:00
$emailId ,
array $data ) {
2017-04-07 15:51:05 +03:00
$this -> themingDefaults = $themingDefaults ;
$this -> urlGenerator = $urlGenerator ;
2020-03-31 15:02:39 +03:00
$this -> l10nFactory = $l10nFactory ;
2017-04-06 21:20:47 +03:00
$this -> htmlBody .= $this -> head ;
2017-08-24 18:54:22 +03:00
$this -> emailId = $emailId ;
$this -> data = $data ;
}
2017-09-15 11:51:55 +03:00
/**
* Sets the subject of the email
*
* @ param string $subject
*/
2018-03-01 23:15:39 +03:00
public function setSubject ( string $subject ) {
2017-09-15 11:51:55 +03:00
$this -> subject = $subject ;
}
2017-04-06 21:20:47 +03:00
/**
* Adds a header to the email
*/
2017-04-07 15:51:05 +03:00
public function addHeader () {
2017-04-06 21:20:47 +03:00
if ( $this -> headerAdded ) {
return ;
}
$this -> headerAdded = true ;
2017-05-08 15:51:55 +03:00
$logoUrl = $this -> urlGenerator -> getAbsoluteURL ( $this -> themingDefaults -> getLogo ( false ));
2017-04-12 12:52:58 +03:00
$this -> htmlBody .= vsprintf ( $this -> header , [ $this -> themingDefaults -> getColorPrimary (), $logoUrl , $this -> themingDefaults -> getName ()]);
2017-04-06 21:20:47 +03:00
}
/**
* Adds a heading to the email
*
* @ param string $title
2017-07-19 16:37:03 +03:00
* @ param string | bool $plainTitle Title that is used in the plain text email
2017-04-12 16:33:14 +03:00
* if empty the $title is used , if false none will be used
2017-04-06 21:20:47 +03:00
*/
2018-03-01 23:15:39 +03:00
public function addHeading ( string $title , $plainTitle = '' ) {
2017-04-06 21:20:47 +03:00
if ( $this -> footerAdded ) {
return ;
}
2017-04-12 01:45:05 +03:00
if ( $plainTitle === '' ) {
$plainTitle = $title ;
}
2017-04-06 21:20:47 +03:00
2017-04-12 00:17:44 +03:00
$this -> htmlBody .= vsprintf ( $this -> heading , [ htmlspecialchars ( $title )]);
2017-04-12 16:33:14 +03:00
if ( $plainTitle !== false ) {
$this -> plainBody .= $plainTitle . PHP_EOL . PHP_EOL ;
}
2017-04-06 21:20:47 +03:00
}
2017-04-24 14:48:27 +03:00
/**
* Open the HTML body when it is not already
*/
protected function ensureBodyIsOpened () {
if ( $this -> bodyOpened ) {
return ;
}
$this -> htmlBody .= $this -> bodyBegin ;
$this -> bodyOpened = true ;
}
2017-04-06 21:20:47 +03:00
/**
* Adds a paragraph to the body of the email
*
2018-01-24 17:17:09 +03:00
* @ param string $text Note : When $plainText falls back to this , HTML is automatically escaped in the HTML email
2017-04-12 12:52:33 +03:00
* @ param string | bool $plainText Text that is used in the plain text email
* if empty the $text is used , if false none will be used
2017-04-06 21:20:47 +03:00
*/
2018-03-01 23:15:39 +03:00
public function addBodyText ( string $text , $plainText = '' ) {
2017-04-06 21:20:47 +03:00
if ( $this -> footerAdded ) {
return ;
}
2017-04-12 01:45:05 +03:00
if ( $plainText === '' ) {
$plainText = $text ;
2018-01-24 17:17:09 +03:00
$text = htmlspecialchars ( $text );
2017-04-12 01:45:05 +03:00
}
2017-04-06 21:20:47 +03:00
2019-02-22 18:19:25 +03:00
$this -> ensureBodyListClosed ();
2019-02-26 02:24:02 +03:00
$this -> ensureBodyIsOpened ();
2017-04-06 21:20:47 +03:00
2018-01-24 17:17:09 +03:00
$this -> htmlBody .= vsprintf ( $this -> bodyText , [ $text ]);
2017-04-12 12:52:33 +03:00
if ( $plainText !== false ) {
$this -> plainBody .= $plainText . PHP_EOL . PHP_EOL ;
}
2017-04-06 21:20:47 +03:00
}
2017-04-24 14:48:27 +03:00
/**
* Adds a list item to the body of the email
*
2018-01-24 17:17:09 +03:00
* @ param string $text Note : When $plainText falls back to this , HTML is automatically escaped in the HTML email
* @ param string $metaInfo Note : When $plainMetaInfo falls back to this , HTML is automatically escaped in the HTML email
2017-04-25 15:31:21 +03:00
* @ param string $icon Absolute path , must be 16 * 16 pixels
2018-03-05 11:06:40 +03:00
* @ param string | bool $plainText Text that is used in the plain text email
2020-09-02 18:16:24 +03:00
* if empty or true the $text is used , if false none will be used
2018-03-05 11:06:40 +03:00
* @ param string | bool $plainMetaInfo Meta info that is used in the plain text email
2020-09-02 18:16:24 +03:00
* if empty or true the $metaInfo is used , if false none will be used
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
* @ param integer plainIndent If > 0 , Indent plainText by this amount .
2017-04-24 14:48:27 +03:00
* @ since 12.0 . 0
*/
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
public function addBodyListItem ( string $text , string $metaInfo = '' , string $icon = '' , $plainText = '' , $plainMetaInfo = '' , $plainIndent = 0 ) {
2017-04-24 14:48:27 +03:00
$this -> ensureBodyListOpened ();
2020-09-02 18:16:24 +03:00
if ( $plainText === '' || $plainText === true ) {
2017-04-24 14:48:27 +03:00
$plainText = $text ;
2018-01-24 17:17:09 +03:00
$text = htmlspecialchars ( $text );
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
$text = str_replace ( " \n " , " <br/> " , $text ); // convert newlines to HTML breaks
2017-04-24 14:48:27 +03:00
}
2020-09-02 18:16:24 +03:00
if ( $plainMetaInfo === '' || $plainMetaInfo === true ) {
2017-04-25 15:31:21 +03:00
$plainMetaInfo = $metaInfo ;
2018-01-24 17:17:09 +03:00
$metaInfo = htmlspecialchars ( $metaInfo );
2017-04-25 15:31:21 +03:00
}
2017-04-24 14:48:27 +03:00
2018-01-24 17:17:09 +03:00
$htmlText = $text ;
2017-04-25 15:31:21 +03:00
if ( $metaInfo ) {
2018-01-24 17:17:09 +03:00
$htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText ;
2017-04-25 15:31:21 +03:00
}
if ( $icon !== '' ) {
$icon = '<img src="' . htmlspecialchars ( $icon ) . '" alt="•">' ;
} else {
$icon = '•' ;
}
$this -> htmlBody .= vsprintf ( $this -> listItem , [ $icon , $htmlText ]);
2017-04-24 14:48:27 +03:00
if ( $plainText !== false ) {
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
if ( $plainIndent === 0 ) {
/*
* If plainIndent is not set by caller , this is the old NC17 layout code .
*/
$this -> plainBody .= ' * ' . $plainText ;
if ( $plainMetaInfo !== false ) {
$this -> plainBody .= ' (' . $plainMetaInfo . ')' ;
}
$this -> plainBody .= PHP_EOL ;
} else {
/*
* Caller can set plainIndent > 0 to format plainText in tabular fashion .
* with plainMetaInfo in column 1 , and plainText in column 2.
* The plainMetaInfo label is right justified in a field of width
* " plainIndent " . Multilines after the first are indented plainIndent + 1
* ( to account for space after label ) . Fixes : #12391
*/
2020-09-02 18:16:24 +03:00
/** @var string $label */
$label = ( $plainMetaInfo !== false ) ? $plainMetaInfo : '' ;
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
$this -> plainBody .= sprintf ( " % ${ plainIndent } s %s \n " ,
2020-09-02 18:16:24 +03:00
$label ,
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
str_replace ( " \n " , " \n " . str_repeat ( ' ' , $plainIndent + 1 ), $plainText ));
2017-04-25 15:31:21 +03:00
}
2017-04-24 14:48:27 +03:00
}
}
protected function ensureBodyListOpened () {
if ( $this -> bodyListOpened ) {
return ;
}
$this -> ensureBodyIsOpened ();
$this -> bodyListOpened = true ;
$this -> htmlBody .= $this -> listBegin ;
}
protected function ensureBodyListClosed () {
if ( ! $this -> bodyListOpened ) {
return ;
}
$this -> bodyListOpened = false ;
$this -> htmlBody .= $this -> listEnd ;
}
2017-04-06 21:20:47 +03:00
/**
* Adds a button group of two buttons to the body of the email
*
2018-01-24 17:17:09 +03:00
* @ param string $textLeft Text of left button ; Note : When $plainTextLeft falls back to this , HTML is automatically escaped in the HTML email
2017-04-06 21:20:47 +03:00
* @ param string $urlLeft URL of left button
2018-01-24 17:17:09 +03:00
* @ param string $textRight Text of right button ; Note : When $plainTextRight falls back to this , HTML is automatically escaped in the HTML email
2017-04-06 21:20:47 +03:00
* @ param string $urlRight URL of right button
2017-04-12 01:45:05 +03:00
* @ param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used
* @ param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used
2017-04-06 21:20:47 +03:00
*/
2018-03-01 23:15:39 +03:00
public function addBodyButtonGroup ( string $textLeft ,
string $urlLeft ,
string $textRight ,
string $urlRight ,
string $plainTextLeft = '' ,
string $plainTextRight = '' ) {
2017-04-06 21:20:47 +03:00
if ( $this -> footerAdded ) {
return ;
}
2017-04-12 01:45:05 +03:00
if ( $plainTextLeft === '' ) {
$plainTextLeft = $textLeft ;
2018-01-24 17:17:09 +03:00
$textLeft = htmlspecialchars ( $textLeft );
2017-04-12 01:45:05 +03:00
}
if ( $plainTextRight === '' ) {
$plainTextRight = $textRight ;
2018-01-24 17:17:09 +03:00
$textRight = htmlspecialchars ( $textRight );
2017-04-12 01:45:05 +03:00
}
2017-04-06 21:20:47 +03:00
2017-04-24 14:48:27 +03:00
$this -> ensureBodyIsOpened ();
$this -> ensureBodyListClosed ();
2017-04-06 21:20:47 +03:00
2017-04-07 15:51:05 +03:00
$color = $this -> themingDefaults -> getColorPrimary ();
2017-12-08 14:16:05 +03:00
$textColor = $this -> themingDefaults -> getTextColorPrimary ();
2017-04-12 00:17:44 +03:00
2018-07-19 12:17:49 +03:00
$this -> htmlBody .= vsprintf ( $this -> buttonGroup , [ $color , $color , $urlLeft , $color , $textColor , $textColor , $textLeft , $urlRight , $textRight ]);
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
$this -> plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL ;
2017-04-12 01:45:05 +03:00
$this -> plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL ;
2017-04-06 21:20:47 +03:00
}
2017-04-12 00:13:34 +03:00
/**
* Adds a button to the body of the email
*
2018-01-24 17:17:09 +03:00
* @ param string $text Text of button ; Note : When $plainText falls back to this , HTML is automatically escaped in the HTML email
2017-04-12 00:13:34 +03:00
* @ param string $url URL of button
2017-04-12 01:24:58 +03:00
* @ param string $plainText Text of button in plain text version
* if empty the $text is used , if false none will be used
2017-04-12 00:13:34 +03:00
*
* @ since 12.0 . 0
*/
2018-03-02 09:50:35 +03:00
public function addBodyButton ( string $text , string $url , $plainText = '' ) {
2017-04-12 00:13:34 +03:00
if ( $this -> footerAdded ) {
return ;
}
2017-04-24 14:48:27 +03:00
$this -> ensureBodyIsOpened ();
$this -> ensureBodyListClosed ();
2017-04-12 00:13:34 +03:00
2017-04-12 01:24:58 +03:00
if ( $plainText === '' ) {
$plainText = $text ;
2018-01-24 17:17:09 +03:00
$text = htmlspecialchars ( $text );
2017-04-12 01:24:58 +03:00
}
2017-04-12 00:13:34 +03:00
$color = $this -> themingDefaults -> getColorPrimary ();
2017-12-08 14:16:05 +03:00
$textColor = $this -> themingDefaults -> getTextColorPrimary ();
2018-07-19 12:17:49 +03:00
$this -> htmlBody .= vsprintf ( $this -> button , [ $color , $color , $url , $color , $textColor , $textColor , $text ]);
2017-04-12 01:24:58 +03:00
if ( $plainText !== false ) {
$this -> plainBody .= $plainText . ': ' ;
}
$this -> plainBody .= $url . PHP_EOL ;
2017-04-12 00:13:34 +03:00
}
2017-04-24 14:48:27 +03:00
/**
* Close the HTML body when it is open
*/
protected function ensureBodyIsClosed () {
if ( ! $this -> bodyOpened ) {
return ;
}
$this -> ensureBodyListClosed ();
$this -> htmlBody .= $this -> bodyEnd ;
$this -> bodyOpened = false ;
}
2017-04-06 21:20:47 +03:00
/**
* Adds a logo and a text to the footer . < br > in the text will be replaced by new lines in the plain text email
*
2017-04-18 10:53:02 +03:00
* @ param string $text If the text is empty the default " Name - Slogan<br>This is an automatically sent email " will be used
2017-04-06 21:20:47 +03:00
*/
2020-03-31 15:02:39 +03:00
public function addFooter ( string $text = '' , ? string $lang = null ) {
2020-04-10 15:19:56 +03:00
if ( $text === '' ) {
2020-03-31 15:02:39 +03:00
$l10n = $this -> l10nFactory -> get ( 'lib' , $lang );
$text = $this -> themingDefaults -> getName () . ' - ' . $this -> themingDefaults -> getSlogan ( $lang ) . '<br>' . $l10n -> t ( 'This is an automatically sent email, please do not reply.' );
2017-04-07 15:51:05 +03:00
}
2017-04-06 21:20:47 +03:00
if ( $this -> footerAdded ) {
return ;
}
$this -> footerAdded = true ;
2017-04-24 14:48:27 +03:00
$this -> ensureBodyIsClosed ();
2017-04-07 15:51:05 +03:00
$this -> htmlBody .= vsprintf ( $this -> footer , [ $text ]);
2017-04-06 21:20:47 +03:00
$this -> htmlBody .= $this -> tail ;
2017-04-12 13:43:55 +03:00
$this -> plainBody .= PHP_EOL . '-- ' . PHP_EOL ;
2017-04-06 21:20:47 +03:00
$this -> plainBody .= str_replace ( '<br>' , PHP_EOL , $text );
}
2017-09-15 11:51:55 +03:00
/**
* Returns the rendered email subject as string
*
* @ return string
*/
2018-03-01 23:15:39 +03:00
public function renderSubject () : string {
2017-09-15 11:51:55 +03:00
return $this -> subject ;
}
2017-04-06 21:20:47 +03:00
/**
* Returns the rendered HTML email as string
*
* @ return string
*/
2018-03-01 23:15:39 +03:00
public function renderHtml () : string {
2017-04-06 21:20:47 +03:00
if ( ! $this -> footerAdded ) {
$this -> footerAdded = true ;
2017-04-24 14:48:27 +03:00
$this -> ensureBodyIsClosed ();
2017-04-06 21:20:47 +03:00
$this -> htmlBody .= $this -> tail ;
}
return $this -> htmlBody ;
}
/**
* Returns the rendered plain text email as string
*
* @ return string
*/
2018-03-01 23:15:39 +03:00
public function renderText () : string {
2017-04-06 21:20:47 +03:00
if ( ! $this -> footerAdded ) {
$this -> footerAdded = true ;
2017-04-24 14:48:27 +03:00
$this -> ensureBodyIsClosed ();
2017-04-06 21:20:47 +03:00
$this -> htmlBody .= $this -> tail ;
}
return $this -> plainBody ;
}
}