@@ -40,186 +40,186 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | class Defaults { |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * \OC_Defaults instance to retrieve the defaults |
|
| 45 | - * @since 6.0.0 |
|
| 46 | - */ |
|
| 47 | - private $defaults; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * creates a \OC_Defaults instance which is used in all methods to retrieve the |
|
| 51 | - * actual defaults |
|
| 52 | - * @since 6.0.0 |
|
| 53 | - */ |
|
| 54 | - public function __construct(\OC_Defaults $defaults = null) { |
|
| 55 | - if ($defaults === null) { |
|
| 56 | - $defaults = \OC::$server->getThemingDefaults(); |
|
| 57 | - } |
|
| 58 | - $this->defaults = $defaults; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * get base URL for the organisation behind your ownCloud instance |
|
| 63 | - * @return string |
|
| 64 | - * @since 6.0.0 |
|
| 65 | - */ |
|
| 66 | - public function getBaseUrl() { |
|
| 67 | - return $this->defaults->getBaseUrl(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * link to the desktop sync client |
|
| 72 | - * @return string |
|
| 73 | - * @since 6.0.0 |
|
| 74 | - */ |
|
| 75 | - public function getSyncClientUrl() { |
|
| 76 | - return $this->defaults->getSyncClientUrl(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * link to the iOS client |
|
| 81 | - * @return string |
|
| 82 | - * @since 8.0.0 |
|
| 83 | - */ |
|
| 84 | - public function getiOSClientUrl() { |
|
| 85 | - return $this->defaults->getiOSClientUrl(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * link to the Android client |
|
| 90 | - * @return string |
|
| 91 | - * @since 8.0.0 |
|
| 92 | - */ |
|
| 93 | - public function getAndroidClientUrl() { |
|
| 94 | - return $this->defaults->getAndroidClientUrl(); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * base URL to the documentation of your ownCloud instance |
|
| 99 | - * @return string |
|
| 100 | - * @since 6.0.0 |
|
| 101 | - */ |
|
| 102 | - public function getDocBaseUrl() { |
|
| 103 | - return $this->defaults->getDocBaseUrl(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * name of your ownCloud instance |
|
| 108 | - * @return string |
|
| 109 | - * @since 6.0.0 |
|
| 110 | - */ |
|
| 111 | - public function getName() { |
|
| 112 | - return $this->defaults->getName(); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * name of your ownCloud instance containing HTML styles |
|
| 117 | - * @return string |
|
| 118 | - * @since 8.0.0 |
|
| 119 | - */ |
|
| 120 | - public function getHTMLName() { |
|
| 121 | - return $this->defaults->getHTMLName(); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Entity behind your onwCloud instance |
|
| 126 | - * @return string |
|
| 127 | - * @since 6.0.0 |
|
| 128 | - */ |
|
| 129 | - public function getEntity() { |
|
| 130 | - return $this->defaults->getEntity(); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * ownCloud slogan |
|
| 135 | - * @return string |
|
| 136 | - * @since 6.0.0 |
|
| 137 | - */ |
|
| 138 | - public function getSlogan() { |
|
| 139 | - return $this->defaults->getSlogan(); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * logo claim |
|
| 144 | - * @return string |
|
| 145 | - * @since 6.0.0 |
|
| 146 | - * @deprecated 13.0.0 |
|
| 147 | - */ |
|
| 148 | - public function getLogoClaim() { |
|
| 149 | - return ''; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * footer, short version |
|
| 154 | - * @return string |
|
| 155 | - * @since 6.0.0 |
|
| 156 | - */ |
|
| 157 | - public function getShortFooter() { |
|
| 158 | - return $this->defaults->getShortFooter(); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * footer, long version |
|
| 163 | - * @return string |
|
| 164 | - * @since 6.0.0 |
|
| 165 | - */ |
|
| 166 | - public function getLongFooter() { |
|
| 167 | - return $this->defaults->getLongFooter(); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Returns the AppId for the App Store for the iOS Client |
|
| 172 | - * @return string AppId |
|
| 173 | - * @since 8.0.0 |
|
| 174 | - */ |
|
| 175 | - public function getiTunesAppId() { |
|
| 176 | - return $this->defaults->getiTunesAppId(); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Themed logo url |
|
| 181 | - * |
|
| 182 | - * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
| 183 | - * @return string |
|
| 184 | - * @since 12.0.0 |
|
| 185 | - */ |
|
| 186 | - public function getLogo($useSvg = true) { |
|
| 187 | - return $this->defaults->getLogo($useSvg); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Returns primary color |
|
| 192 | - * @return string |
|
| 193 | - * @since 12.0.0 |
|
| 194 | - */ |
|
| 195 | - public function getColorPrimary() { |
|
| 196 | - return $this->defaults->getColorPrimary(); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * @param string $key |
|
| 201 | - * @return string URL to doc with key |
|
| 202 | - * @since 12.0.0 |
|
| 203 | - */ |
|
| 204 | - public function buildDocLinkToKey($key) { |
|
| 205 | - return $this->defaults->buildDocLinkToKey($key); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Returns the title |
|
| 210 | - * @return string title |
|
| 211 | - * @since 12.0.0 |
|
| 212 | - */ |
|
| 213 | - public function getTitle() { |
|
| 214 | - return $this->defaults->getTitle(); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * Returns primary color |
|
| 219 | - * @return string |
|
| 220 | - * @since 13.0.0 |
|
| 221 | - */ |
|
| 222 | - public function getTextColorPrimary() { |
|
| 223 | - return $this->defaults->getTextColorPrimary(); |
|
| 224 | - } |
|
| 43 | + /** |
|
| 44 | + * \OC_Defaults instance to retrieve the defaults |
|
| 45 | + * @since 6.0.0 |
|
| 46 | + */ |
|
| 47 | + private $defaults; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * creates a \OC_Defaults instance which is used in all methods to retrieve the |
|
| 51 | + * actual defaults |
|
| 52 | + * @since 6.0.0 |
|
| 53 | + */ |
|
| 54 | + public function __construct(\OC_Defaults $defaults = null) { |
|
| 55 | + if ($defaults === null) { |
|
| 56 | + $defaults = \OC::$server->getThemingDefaults(); |
|
| 57 | + } |
|
| 58 | + $this->defaults = $defaults; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * get base URL for the organisation behind your ownCloud instance |
|
| 63 | + * @return string |
|
| 64 | + * @since 6.0.0 |
|
| 65 | + */ |
|
| 66 | + public function getBaseUrl() { |
|
| 67 | + return $this->defaults->getBaseUrl(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * link to the desktop sync client |
|
| 72 | + * @return string |
|
| 73 | + * @since 6.0.0 |
|
| 74 | + */ |
|
| 75 | + public function getSyncClientUrl() { |
|
| 76 | + return $this->defaults->getSyncClientUrl(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * link to the iOS client |
|
| 81 | + * @return string |
|
| 82 | + * @since 8.0.0 |
|
| 83 | + */ |
|
| 84 | + public function getiOSClientUrl() { |
|
| 85 | + return $this->defaults->getiOSClientUrl(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * link to the Android client |
|
| 90 | + * @return string |
|
| 91 | + * @since 8.0.0 |
|
| 92 | + */ |
|
| 93 | + public function getAndroidClientUrl() { |
|
| 94 | + return $this->defaults->getAndroidClientUrl(); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * base URL to the documentation of your ownCloud instance |
|
| 99 | + * @return string |
|
| 100 | + * @since 6.0.0 |
|
| 101 | + */ |
|
| 102 | + public function getDocBaseUrl() { |
|
| 103 | + return $this->defaults->getDocBaseUrl(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * name of your ownCloud instance |
|
| 108 | + * @return string |
|
| 109 | + * @since 6.0.0 |
|
| 110 | + */ |
|
| 111 | + public function getName() { |
|
| 112 | + return $this->defaults->getName(); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * name of your ownCloud instance containing HTML styles |
|
| 117 | + * @return string |
|
| 118 | + * @since 8.0.0 |
|
| 119 | + */ |
|
| 120 | + public function getHTMLName() { |
|
| 121 | + return $this->defaults->getHTMLName(); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Entity behind your onwCloud instance |
|
| 126 | + * @return string |
|
| 127 | + * @since 6.0.0 |
|
| 128 | + */ |
|
| 129 | + public function getEntity() { |
|
| 130 | + return $this->defaults->getEntity(); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * ownCloud slogan |
|
| 135 | + * @return string |
|
| 136 | + * @since 6.0.0 |
|
| 137 | + */ |
|
| 138 | + public function getSlogan() { |
|
| 139 | + return $this->defaults->getSlogan(); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * logo claim |
|
| 144 | + * @return string |
|
| 145 | + * @since 6.0.0 |
|
| 146 | + * @deprecated 13.0.0 |
|
| 147 | + */ |
|
| 148 | + public function getLogoClaim() { |
|
| 149 | + return ''; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * footer, short version |
|
| 154 | + * @return string |
|
| 155 | + * @since 6.0.0 |
|
| 156 | + */ |
|
| 157 | + public function getShortFooter() { |
|
| 158 | + return $this->defaults->getShortFooter(); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * footer, long version |
|
| 163 | + * @return string |
|
| 164 | + * @since 6.0.0 |
|
| 165 | + */ |
|
| 166 | + public function getLongFooter() { |
|
| 167 | + return $this->defaults->getLongFooter(); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Returns the AppId for the App Store for the iOS Client |
|
| 172 | + * @return string AppId |
|
| 173 | + * @since 8.0.0 |
|
| 174 | + */ |
|
| 175 | + public function getiTunesAppId() { |
|
| 176 | + return $this->defaults->getiTunesAppId(); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Themed logo url |
|
| 181 | + * |
|
| 182 | + * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
| 183 | + * @return string |
|
| 184 | + * @since 12.0.0 |
|
| 185 | + */ |
|
| 186 | + public function getLogo($useSvg = true) { |
|
| 187 | + return $this->defaults->getLogo($useSvg); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Returns primary color |
|
| 192 | + * @return string |
|
| 193 | + * @since 12.0.0 |
|
| 194 | + */ |
|
| 195 | + public function getColorPrimary() { |
|
| 196 | + return $this->defaults->getColorPrimary(); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * @param string $key |
|
| 201 | + * @return string URL to doc with key |
|
| 202 | + * @since 12.0.0 |
|
| 203 | + */ |
|
| 204 | + public function buildDocLinkToKey($key) { |
|
| 205 | + return $this->defaults->buildDocLinkToKey($key); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Returns the title |
|
| 210 | + * @return string title |
|
| 211 | + * @since 12.0.0 |
|
| 212 | + */ |
|
| 213 | + public function getTitle() { |
|
| 214 | + return $this->defaults->getTitle(); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * Returns primary color |
|
| 219 | + * @return string |
|
| 220 | + * @since 13.0.0 |
|
| 221 | + */ |
|
| 222 | + public function getTextColorPrimary() { |
|
| 223 | + return $this->defaults->getTextColorPrimary(); |
|
| 224 | + } |
|
| 225 | 225 | } |
@@ -41,33 +41,33 @@ discard block |
||
| 41 | 41 | * @package OC\Mail |
| 42 | 42 | */ |
| 43 | 43 | class EMailTemplate implements IEMailTemplate { |
| 44 | - /** @var Defaults */ |
|
| 45 | - protected $themingDefaults; |
|
| 46 | - /** @var IURLGenerator */ |
|
| 47 | - protected $urlGenerator; |
|
| 48 | - /** @var IL10N */ |
|
| 49 | - protected $l10n; |
|
| 50 | - /** @var string */ |
|
| 51 | - protected $emailId; |
|
| 52 | - /** @var array */ |
|
| 53 | - protected $data; |
|
| 54 | - |
|
| 55 | - /** @var string */ |
|
| 56 | - protected $subject = ''; |
|
| 57 | - /** @var string */ |
|
| 58 | - protected $htmlBody = ''; |
|
| 59 | - /** @var string */ |
|
| 60 | - protected $plainBody = ''; |
|
| 61 | - /** @var bool indicated if the footer is added */ |
|
| 62 | - protected $headerAdded = false; |
|
| 63 | - /** @var bool indicated if the body is already opened */ |
|
| 64 | - protected $bodyOpened = false; |
|
| 65 | - /** @var bool indicated if there is a list open in the body */ |
|
| 66 | - protected $bodyListOpened = false; |
|
| 67 | - /** @var bool indicated if the footer is added */ |
|
| 68 | - protected $footerAdded = false; |
|
| 69 | - |
|
| 70 | - protected $head = <<<EOF |
|
| 44 | + /** @var Defaults */ |
|
| 45 | + protected $themingDefaults; |
|
| 46 | + /** @var IURLGenerator */ |
|
| 47 | + protected $urlGenerator; |
|
| 48 | + /** @var IL10N */ |
|
| 49 | + protected $l10n; |
|
| 50 | + /** @var string */ |
|
| 51 | + protected $emailId; |
|
| 52 | + /** @var array */ |
|
| 53 | + protected $data; |
|
| 54 | + |
|
| 55 | + /** @var string */ |
|
| 56 | + protected $subject = ''; |
|
| 57 | + /** @var string */ |
|
| 58 | + protected $htmlBody = ''; |
|
| 59 | + /** @var string */ |
|
| 60 | + protected $plainBody = ''; |
|
| 61 | + /** @var bool indicated if the footer is added */ |
|
| 62 | + protected $headerAdded = false; |
|
| 63 | + /** @var bool indicated if the body is already opened */ |
|
| 64 | + protected $bodyOpened = false; |
|
| 65 | + /** @var bool indicated if there is a list open in the body */ |
|
| 66 | + protected $bodyListOpened = false; |
|
| 67 | + /** @var bool indicated if the footer is added */ |
|
| 68 | + protected $footerAdded = false; |
|
| 69 | + |
|
| 70 | + protected $head = <<<EOF |
|
| 71 | 71 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 72 | 72 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#f3f3f3!important"> |
| 73 | 73 | <head> |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | <center data-parsed="" style="min-width:580px;width:100%"> |
| 86 | 86 | EOF; |
| 87 | 87 | |
| 88 | - protected $tail = <<<EOF |
|
| 88 | + protected $tail = <<<EOF |
|
| 89 | 89 | </center> |
| 90 | 90 | </td> |
| 91 | 91 | </tr> |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | </html> |
| 97 | 97 | EOF; |
| 98 | 98 | |
| 99 | - protected $header = <<<EOF |
|
| 99 | + protected $header = <<<EOF |
|
| 100 | 100 | <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%%"> |
| 101 | 101 | <tr style="padding:0;text-align:left;vertical-align:top"> |
| 102 | 102 | <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"> |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | </table> |
| 130 | 130 | EOF; |
| 131 | 131 | |
| 132 | - protected $heading = <<<EOF |
|
| 132 | + protected $heading = <<<EOF |
|
| 133 | 133 | <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"> |
| 134 | 134 | <tbody> |
| 135 | 135 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | </table> |
| 149 | 149 | EOF; |
| 150 | 150 | |
| 151 | - protected $bodyBegin = <<<EOF |
|
| 151 | + protected $bodyBegin = <<<EOF |
|
| 152 | 152 | <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%"> |
| 153 | 153 | <tr style="padding:0;text-align:left;vertical-align:top"> |
| 154 | 154 | <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"> |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | </table> |
| 166 | 166 | EOF; |
| 167 | 167 | |
| 168 | - protected $bodyText = <<<EOF |
|
| 168 | + protected $bodyText = <<<EOF |
|
| 169 | 169 | <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%%"> |
| 170 | 170 | <tbody> |
| 171 | 171 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | </table> |
| 185 | 185 | EOF; |
| 186 | 186 | |
| 187 | - protected $listBegin = <<<EOF |
|
| 187 | + protected $listBegin = <<<EOF |
|
| 188 | 188 | <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%%"> |
| 189 | 189 | <tbody> |
| 190 | 190 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%"> |
| 193 | 193 | EOF; |
| 194 | 194 | |
| 195 | - protected $listItem = <<<EOF |
|
| 195 | + protected $listItem = <<<EOF |
|
| 196 | 196 | <tr style="padding:0;text-align:left;vertical-align:top"> |
| 197 | 197 | <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;"> |
| 198 | 198 | <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> |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | </tr> |
| 205 | 205 | EOF; |
| 206 | 206 | |
| 207 | - protected $listEnd = <<<EOF |
|
| 207 | + protected $listEnd = <<<EOF |
|
| 208 | 208 | </table> |
| 209 | 209 | </th> |
| 210 | 210 | </tr> |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | </table> |
| 213 | 213 | EOF; |
| 214 | 214 | |
| 215 | - protected $buttonGroup = <<<EOF |
|
| 215 | + protected $buttonGroup = <<<EOF |
|
| 216 | 216 | <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%"> |
| 217 | 217 | <tbody> |
| 218 | 218 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | </table> |
| 266 | 266 | EOF; |
| 267 | 267 | |
| 268 | - protected $button = <<<EOF |
|
| 268 | + protected $button = <<<EOF |
|
| 269 | 269 | <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%"> |
| 270 | 270 | <tbody> |
| 271 | 271 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | </table> |
| 306 | 306 | EOF; |
| 307 | 307 | |
| 308 | - protected $bodyEnd = <<<EOF |
|
| 308 | + protected $bodyEnd = <<<EOF |
|
| 309 | 309 | |
| 310 | 310 | </td> |
| 311 | 311 | </tr> |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | </table> |
| 317 | 317 | EOF; |
| 318 | 318 | |
| 319 | - protected $footer = <<<EOF |
|
| 319 | + protected $footer = <<<EOF |
|
| 320 | 320 | <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%%"> |
| 321 | 321 | <tbody> |
| 322 | 322 | <tr style="padding:0;text-align:left;vertical-align:top"> |
@@ -342,308 +342,308 @@ discard block |
||
| 342 | 342 | </table> |
| 343 | 343 | EOF; |
| 344 | 344 | |
| 345 | - /** |
|
| 346 | - * @param Defaults $themingDefaults |
|
| 347 | - * @param IURLGenerator $urlGenerator |
|
| 348 | - * @param IL10N $l10n |
|
| 349 | - * @param string $emailId |
|
| 350 | - * @param array $data |
|
| 351 | - */ |
|
| 352 | - public function __construct(Defaults $themingDefaults, |
|
| 353 | - IURLGenerator $urlGenerator, |
|
| 354 | - IL10N $l10n, |
|
| 355 | - $emailId, |
|
| 356 | - array $data) { |
|
| 357 | - $this->themingDefaults = $themingDefaults; |
|
| 358 | - $this->urlGenerator = $urlGenerator; |
|
| 359 | - $this->l10n = $l10n; |
|
| 360 | - $this->htmlBody .= $this->head; |
|
| 361 | - $this->emailId = $emailId; |
|
| 362 | - $this->data = $data; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Sets the subject of the email |
|
| 367 | - * |
|
| 368 | - * @param string $subject |
|
| 369 | - */ |
|
| 370 | - public function setSubject($subject) { |
|
| 371 | - $this->subject = $subject; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * Adds a header to the email |
|
| 376 | - */ |
|
| 377 | - public function addHeader() { |
|
| 378 | - if ($this->headerAdded) { |
|
| 379 | - return; |
|
| 380 | - } |
|
| 381 | - $this->headerAdded = true; |
|
| 382 | - |
|
| 383 | - $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false)); |
|
| 384 | - $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * Adds a heading to the email |
|
| 389 | - * |
|
| 390 | - * @param string $title |
|
| 391 | - * @param string|bool $plainTitle Title that is used in the plain text email |
|
| 392 | - * if empty the $title is used, if false none will be used |
|
| 393 | - */ |
|
| 394 | - public function addHeading($title, $plainTitle = '') { |
|
| 395 | - if ($this->footerAdded) { |
|
| 396 | - return; |
|
| 397 | - } |
|
| 398 | - if ($plainTitle === '') { |
|
| 399 | - $plainTitle = $title; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
|
| 403 | - if ($plainTitle !== false) { |
|
| 404 | - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * Open the HTML body when it is not already |
|
| 410 | - */ |
|
| 411 | - protected function ensureBodyIsOpened() { |
|
| 412 | - if ($this->bodyOpened) { |
|
| 413 | - return; |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - $this->htmlBody .= $this->bodyBegin; |
|
| 417 | - $this->bodyOpened = true; |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * Adds a paragraph to the body of the email |
|
| 422 | - * |
|
| 423 | - * @param string $text |
|
| 424 | - * @param string|bool $plainText Text that is used in the plain text email |
|
| 425 | - * if empty the $text is used, if false none will be used |
|
| 426 | - */ |
|
| 427 | - public function addBodyText($text, $plainText = '') { |
|
| 428 | - if ($this->footerAdded) { |
|
| 429 | - return; |
|
| 430 | - } |
|
| 431 | - if ($plainText === '') { |
|
| 432 | - $plainText = $text; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - $this->ensureBodyIsOpened(); |
|
| 436 | - |
|
| 437 | - $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); |
|
| 438 | - if ($plainText !== false) { |
|
| 439 | - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
| 440 | - } |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * Adds a list item to the body of the email |
|
| 445 | - * |
|
| 446 | - * @param string $text |
|
| 447 | - * @param string $metaInfo |
|
| 448 | - * @param string $icon Absolute path, must be 16*16 pixels |
|
| 449 | - * @param string $plainText Text that is used in the plain text email |
|
| 450 | - * if empty the $text is used, if false none will be used |
|
| 451 | - * @param string $plainMetaInfo Meta info that is used in the plain text email |
|
| 452 | - * if empty the $metaInfo is used, if false none will be used |
|
| 453 | - * @since 12.0.0 |
|
| 454 | - */ |
|
| 455 | - public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') { |
|
| 456 | - $this->ensureBodyListOpened(); |
|
| 457 | - |
|
| 458 | - if ($plainText === '') { |
|
| 459 | - $plainText = $text; |
|
| 460 | - } |
|
| 461 | - if ($plainMetaInfo === '') { |
|
| 462 | - $plainMetaInfo = $metaInfo; |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - $htmlText = htmlspecialchars($text); |
|
| 466 | - if ($metaInfo) { |
|
| 467 | - $htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText; |
|
| 468 | - } |
|
| 469 | - if ($icon !== '') { |
|
| 470 | - $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
| 471 | - } else { |
|
| 472 | - $icon = '•'; |
|
| 473 | - } |
|
| 474 | - $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
|
| 475 | - if ($plainText !== false) { |
|
| 476 | - $this->plainBody .= ' * ' . $plainText; |
|
| 477 | - if ($plainMetaInfo !== false) { |
|
| 478 | - $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
| 479 | - } |
|
| 480 | - $this->plainBody .= PHP_EOL; |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - protected function ensureBodyListOpened() { |
|
| 485 | - if ($this->bodyListOpened) { |
|
| 486 | - return; |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - $this->ensureBodyIsOpened(); |
|
| 490 | - $this->bodyListOpened = true; |
|
| 491 | - $this->htmlBody .= $this->listBegin; |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - protected function ensureBodyListClosed() { |
|
| 495 | - if (!$this->bodyListOpened) { |
|
| 496 | - return; |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - $this->bodyListOpened = false; |
|
| 500 | - $this->htmlBody .= $this->listEnd; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * Adds a button group of two buttons to the body of the email |
|
| 505 | - * |
|
| 506 | - * @param string $textLeft Text of left button |
|
| 507 | - * @param string $urlLeft URL of left button |
|
| 508 | - * @param string $textRight Text of right button |
|
| 509 | - * @param string $urlRight URL of right button |
|
| 510 | - * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used |
|
| 511 | - * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used |
|
| 512 | - */ |
|
| 513 | - public function addBodyButtonGroup($textLeft, |
|
| 514 | - $urlLeft, |
|
| 515 | - $textRight, |
|
| 516 | - $urlRight, |
|
| 517 | - $plainTextLeft = '', |
|
| 518 | - $plainTextRight = '') { |
|
| 519 | - if ($this->footerAdded) { |
|
| 520 | - return; |
|
| 521 | - } |
|
| 522 | - if ($plainTextLeft === '') { |
|
| 523 | - $plainTextLeft = $textLeft; |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - if ($plainTextRight === '') { |
|
| 527 | - $plainTextRight = $textRight; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - $this->ensureBodyIsOpened(); |
|
| 531 | - $this->ensureBodyListClosed(); |
|
| 532 | - |
|
| 533 | - $color = $this->themingDefaults->getColorPrimary(); |
|
| 534 | - $textColor = $this->themingDefaults->getTextColorPrimary(); |
|
| 535 | - |
|
| 536 | - $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]); |
|
| 537 | - $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
| 538 | - $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
| 539 | - |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * Adds a button to the body of the email |
|
| 544 | - * |
|
| 545 | - * @param string $text Text of button |
|
| 546 | - * @param string $url URL of button |
|
| 547 | - * @param string $plainText Text of button in plain text version |
|
| 548 | - * if empty the $text is used, if false none will be used |
|
| 549 | - * |
|
| 550 | - * @since 12.0.0 |
|
| 551 | - */ |
|
| 552 | - public function addBodyButton($text, $url, $plainText = '') { |
|
| 553 | - if ($this->footerAdded) { |
|
| 554 | - return; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - $this->ensureBodyIsOpened(); |
|
| 558 | - $this->ensureBodyListClosed(); |
|
| 559 | - |
|
| 560 | - if ($plainText === '') { |
|
| 561 | - $plainText = $text; |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - $color = $this->themingDefaults->getColorPrimary(); |
|
| 565 | - $textColor = $this->themingDefaults->getTextColorPrimary(); |
|
| 566 | - $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, htmlspecialchars($text)]); |
|
| 567 | - |
|
| 568 | - if ($plainText !== false) { |
|
| 569 | - $this->plainBody .= $plainText . ': '; |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - $this->plainBody .= $url . PHP_EOL; |
|
| 573 | - |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * Close the HTML body when it is open |
|
| 578 | - */ |
|
| 579 | - protected function ensureBodyIsClosed() { |
|
| 580 | - if (!$this->bodyOpened) { |
|
| 581 | - return; |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - $this->ensureBodyListClosed(); |
|
| 585 | - |
|
| 586 | - $this->htmlBody .= $this->bodyEnd; |
|
| 587 | - $this->bodyOpened = false; |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
| 592 | - * |
|
| 593 | - * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
|
| 594 | - */ |
|
| 595 | - public function addFooter($text = '') { |
|
| 596 | - if($text === '') { |
|
| 597 | - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - if ($this->footerAdded) { |
|
| 601 | - return; |
|
| 602 | - } |
|
| 603 | - $this->footerAdded = true; |
|
| 604 | - |
|
| 605 | - $this->ensureBodyIsClosed(); |
|
| 606 | - |
|
| 607 | - $this->htmlBody .= vsprintf($this->footer, [$text]); |
|
| 608 | - $this->htmlBody .= $this->tail; |
|
| 609 | - $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
| 610 | - $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - /** |
|
| 614 | - * Returns the rendered email subject as string |
|
| 615 | - * |
|
| 616 | - * @return string |
|
| 617 | - */ |
|
| 618 | - public function renderSubject() { |
|
| 619 | - return $this->subject; |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * Returns the rendered HTML email as string |
|
| 624 | - * |
|
| 625 | - * @return string |
|
| 626 | - */ |
|
| 627 | - public function renderHtml() { |
|
| 628 | - if (!$this->footerAdded) { |
|
| 629 | - $this->footerAdded = true; |
|
| 630 | - $this->ensureBodyIsClosed(); |
|
| 631 | - $this->htmlBody .= $this->tail; |
|
| 632 | - } |
|
| 633 | - return $this->htmlBody; |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - /** |
|
| 637 | - * Returns the rendered plain text email as string |
|
| 638 | - * |
|
| 639 | - * @return string |
|
| 640 | - */ |
|
| 641 | - public function renderText() { |
|
| 642 | - if (!$this->footerAdded) { |
|
| 643 | - $this->footerAdded = true; |
|
| 644 | - $this->ensureBodyIsClosed(); |
|
| 645 | - $this->htmlBody .= $this->tail; |
|
| 646 | - } |
|
| 647 | - return $this->plainBody; |
|
| 648 | - } |
|
| 345 | + /** |
|
| 346 | + * @param Defaults $themingDefaults |
|
| 347 | + * @param IURLGenerator $urlGenerator |
|
| 348 | + * @param IL10N $l10n |
|
| 349 | + * @param string $emailId |
|
| 350 | + * @param array $data |
|
| 351 | + */ |
|
| 352 | + public function __construct(Defaults $themingDefaults, |
|
| 353 | + IURLGenerator $urlGenerator, |
|
| 354 | + IL10N $l10n, |
|
| 355 | + $emailId, |
|
| 356 | + array $data) { |
|
| 357 | + $this->themingDefaults = $themingDefaults; |
|
| 358 | + $this->urlGenerator = $urlGenerator; |
|
| 359 | + $this->l10n = $l10n; |
|
| 360 | + $this->htmlBody .= $this->head; |
|
| 361 | + $this->emailId = $emailId; |
|
| 362 | + $this->data = $data; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * Sets the subject of the email |
|
| 367 | + * |
|
| 368 | + * @param string $subject |
|
| 369 | + */ |
|
| 370 | + public function setSubject($subject) { |
|
| 371 | + $this->subject = $subject; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * Adds a header to the email |
|
| 376 | + */ |
|
| 377 | + public function addHeader() { |
|
| 378 | + if ($this->headerAdded) { |
|
| 379 | + return; |
|
| 380 | + } |
|
| 381 | + $this->headerAdded = true; |
|
| 382 | + |
|
| 383 | + $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false)); |
|
| 384 | + $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * Adds a heading to the email |
|
| 389 | + * |
|
| 390 | + * @param string $title |
|
| 391 | + * @param string|bool $plainTitle Title that is used in the plain text email |
|
| 392 | + * if empty the $title is used, if false none will be used |
|
| 393 | + */ |
|
| 394 | + public function addHeading($title, $plainTitle = '') { |
|
| 395 | + if ($this->footerAdded) { |
|
| 396 | + return; |
|
| 397 | + } |
|
| 398 | + if ($plainTitle === '') { |
|
| 399 | + $plainTitle = $title; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
|
| 403 | + if ($plainTitle !== false) { |
|
| 404 | + $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * Open the HTML body when it is not already |
|
| 410 | + */ |
|
| 411 | + protected function ensureBodyIsOpened() { |
|
| 412 | + if ($this->bodyOpened) { |
|
| 413 | + return; |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + $this->htmlBody .= $this->bodyBegin; |
|
| 417 | + $this->bodyOpened = true; |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * Adds a paragraph to the body of the email |
|
| 422 | + * |
|
| 423 | + * @param string $text |
|
| 424 | + * @param string|bool $plainText Text that is used in the plain text email |
|
| 425 | + * if empty the $text is used, if false none will be used |
|
| 426 | + */ |
|
| 427 | + public function addBodyText($text, $plainText = '') { |
|
| 428 | + if ($this->footerAdded) { |
|
| 429 | + return; |
|
| 430 | + } |
|
| 431 | + if ($plainText === '') { |
|
| 432 | + $plainText = $text; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + $this->ensureBodyIsOpened(); |
|
| 436 | + |
|
| 437 | + $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); |
|
| 438 | + if ($plainText !== false) { |
|
| 439 | + $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
| 440 | + } |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * Adds a list item to the body of the email |
|
| 445 | + * |
|
| 446 | + * @param string $text |
|
| 447 | + * @param string $metaInfo |
|
| 448 | + * @param string $icon Absolute path, must be 16*16 pixels |
|
| 449 | + * @param string $plainText Text that is used in the plain text email |
|
| 450 | + * if empty the $text is used, if false none will be used |
|
| 451 | + * @param string $plainMetaInfo Meta info that is used in the plain text email |
|
| 452 | + * if empty the $metaInfo is used, if false none will be used |
|
| 453 | + * @since 12.0.0 |
|
| 454 | + */ |
|
| 455 | + public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') { |
|
| 456 | + $this->ensureBodyListOpened(); |
|
| 457 | + |
|
| 458 | + if ($plainText === '') { |
|
| 459 | + $plainText = $text; |
|
| 460 | + } |
|
| 461 | + if ($plainMetaInfo === '') { |
|
| 462 | + $plainMetaInfo = $metaInfo; |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + $htmlText = htmlspecialchars($text); |
|
| 466 | + if ($metaInfo) { |
|
| 467 | + $htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText; |
|
| 468 | + } |
|
| 469 | + if ($icon !== '') { |
|
| 470 | + $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
| 471 | + } else { |
|
| 472 | + $icon = '•'; |
|
| 473 | + } |
|
| 474 | + $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
|
| 475 | + if ($plainText !== false) { |
|
| 476 | + $this->plainBody .= ' * ' . $plainText; |
|
| 477 | + if ($plainMetaInfo !== false) { |
|
| 478 | + $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
| 479 | + } |
|
| 480 | + $this->plainBody .= PHP_EOL; |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + protected function ensureBodyListOpened() { |
|
| 485 | + if ($this->bodyListOpened) { |
|
| 486 | + return; |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + $this->ensureBodyIsOpened(); |
|
| 490 | + $this->bodyListOpened = true; |
|
| 491 | + $this->htmlBody .= $this->listBegin; |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + protected function ensureBodyListClosed() { |
|
| 495 | + if (!$this->bodyListOpened) { |
|
| 496 | + return; |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + $this->bodyListOpened = false; |
|
| 500 | + $this->htmlBody .= $this->listEnd; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * Adds a button group of two buttons to the body of the email |
|
| 505 | + * |
|
| 506 | + * @param string $textLeft Text of left button |
|
| 507 | + * @param string $urlLeft URL of left button |
|
| 508 | + * @param string $textRight Text of right button |
|
| 509 | + * @param string $urlRight URL of right button |
|
| 510 | + * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used |
|
| 511 | + * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used |
|
| 512 | + */ |
|
| 513 | + public function addBodyButtonGroup($textLeft, |
|
| 514 | + $urlLeft, |
|
| 515 | + $textRight, |
|
| 516 | + $urlRight, |
|
| 517 | + $plainTextLeft = '', |
|
| 518 | + $plainTextRight = '') { |
|
| 519 | + if ($this->footerAdded) { |
|
| 520 | + return; |
|
| 521 | + } |
|
| 522 | + if ($plainTextLeft === '') { |
|
| 523 | + $plainTextLeft = $textLeft; |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + if ($plainTextRight === '') { |
|
| 527 | + $plainTextRight = $textRight; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + $this->ensureBodyIsOpened(); |
|
| 531 | + $this->ensureBodyListClosed(); |
|
| 532 | + |
|
| 533 | + $color = $this->themingDefaults->getColorPrimary(); |
|
| 534 | + $textColor = $this->themingDefaults->getTextColorPrimary(); |
|
| 535 | + |
|
| 536 | + $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]); |
|
| 537 | + $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
| 538 | + $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
| 539 | + |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + /** |
|
| 543 | + * Adds a button to the body of the email |
|
| 544 | + * |
|
| 545 | + * @param string $text Text of button |
|
| 546 | + * @param string $url URL of button |
|
| 547 | + * @param string $plainText Text of button in plain text version |
|
| 548 | + * if empty the $text is used, if false none will be used |
|
| 549 | + * |
|
| 550 | + * @since 12.0.0 |
|
| 551 | + */ |
|
| 552 | + public function addBodyButton($text, $url, $plainText = '') { |
|
| 553 | + if ($this->footerAdded) { |
|
| 554 | + return; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + $this->ensureBodyIsOpened(); |
|
| 558 | + $this->ensureBodyListClosed(); |
|
| 559 | + |
|
| 560 | + if ($plainText === '') { |
|
| 561 | + $plainText = $text; |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + $color = $this->themingDefaults->getColorPrimary(); |
|
| 565 | + $textColor = $this->themingDefaults->getTextColorPrimary(); |
|
| 566 | + $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, htmlspecialchars($text)]); |
|
| 567 | + |
|
| 568 | + if ($plainText !== false) { |
|
| 569 | + $this->plainBody .= $plainText . ': '; |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + $this->plainBody .= $url . PHP_EOL; |
|
| 573 | + |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * Close the HTML body when it is open |
|
| 578 | + */ |
|
| 579 | + protected function ensureBodyIsClosed() { |
|
| 580 | + if (!$this->bodyOpened) { |
|
| 581 | + return; |
|
| 582 | + } |
|
| 583 | + |
|
| 584 | + $this->ensureBodyListClosed(); |
|
| 585 | + |
|
| 586 | + $this->htmlBody .= $this->bodyEnd; |
|
| 587 | + $this->bodyOpened = false; |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
| 592 | + * |
|
| 593 | + * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
|
| 594 | + */ |
|
| 595 | + public function addFooter($text = '') { |
|
| 596 | + if($text === '') { |
|
| 597 | + $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + if ($this->footerAdded) { |
|
| 601 | + return; |
|
| 602 | + } |
|
| 603 | + $this->footerAdded = true; |
|
| 604 | + |
|
| 605 | + $this->ensureBodyIsClosed(); |
|
| 606 | + |
|
| 607 | + $this->htmlBody .= vsprintf($this->footer, [$text]); |
|
| 608 | + $this->htmlBody .= $this->tail; |
|
| 609 | + $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
| 610 | + $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + /** |
|
| 614 | + * Returns the rendered email subject as string |
|
| 615 | + * |
|
| 616 | + * @return string |
|
| 617 | + */ |
|
| 618 | + public function renderSubject() { |
|
| 619 | + return $this->subject; |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * Returns the rendered HTML email as string |
|
| 624 | + * |
|
| 625 | + * @return string |
|
| 626 | + */ |
|
| 627 | + public function renderHtml() { |
|
| 628 | + if (!$this->footerAdded) { |
|
| 629 | + $this->footerAdded = true; |
|
| 630 | + $this->ensureBodyIsClosed(); |
|
| 631 | + $this->htmlBody .= $this->tail; |
|
| 632 | + } |
|
| 633 | + return $this->htmlBody; |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + /** |
|
| 637 | + * Returns the rendered plain text email as string |
|
| 638 | + * |
|
| 639 | + * @return string |
|
| 640 | + */ |
|
| 641 | + public function renderText() { |
|
| 642 | + if (!$this->footerAdded) { |
|
| 643 | + $this->footerAdded = true; |
|
| 644 | + $this->ensureBodyIsClosed(); |
|
| 645 | + $this->htmlBody .= $this->tail; |
|
| 646 | + } |
|
| 647 | + return $this->plainBody; |
|
| 648 | + } |
|
| 649 | 649 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | |
| 402 | 402 | $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
| 403 | 403 | if ($plainTitle !== false) { |
| 404 | - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
| 404 | + $this->plainBody .= $plainTitle.PHP_EOL.PHP_EOL; |
|
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | |
| 437 | 437 | $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); |
| 438 | 438 | if ($plainText !== false) { |
| 439 | - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
| 439 | + $this->plainBody .= $plainText.PHP_EOL.PHP_EOL; |
|
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
@@ -464,18 +464,18 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | $htmlText = htmlspecialchars($text); |
| 466 | 466 | if ($metaInfo) { |
| 467 | - $htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText; |
|
| 467 | + $htmlText = '<em style="color:#777;">'.htmlspecialchars($metaInfo).'</em><br>'.$htmlText; |
|
| 468 | 468 | } |
| 469 | 469 | if ($icon !== '') { |
| 470 | - $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
| 470 | + $icon = '<img src="'.htmlspecialchars($icon).'" alt="•">'; |
|
| 471 | 471 | } else { |
| 472 | 472 | $icon = '•'; |
| 473 | 473 | } |
| 474 | 474 | $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
| 475 | 475 | if ($plainText !== false) { |
| 476 | - $this->plainBody .= ' * ' . $plainText; |
|
| 476 | + $this->plainBody .= ' * '.$plainText; |
|
| 477 | 477 | if ($plainMetaInfo !== false) { |
| 478 | - $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
| 478 | + $this->plainBody .= ' ('.$plainMetaInfo.')'; |
|
| 479 | 479 | } |
| 480 | 480 | $this->plainBody .= PHP_EOL; |
| 481 | 481 | } |
@@ -534,8 +534,8 @@ discard block |
||
| 534 | 534 | $textColor = $this->themingDefaults->getTextColorPrimary(); |
| 535 | 535 | |
| 536 | 536 | $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]); |
| 537 | - $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
| 538 | - $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
| 537 | + $this->plainBody .= $plainTextLeft.': '.$urlLeft.PHP_EOL; |
|
| 538 | + $this->plainBody .= $plainTextRight.': '.$urlRight.PHP_EOL.PHP_EOL; |
|
| 539 | 539 | |
| 540 | 540 | } |
| 541 | 541 | |
@@ -566,10 +566,10 @@ discard block |
||
| 566 | 566 | $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, htmlspecialchars($text)]); |
| 567 | 567 | |
| 568 | 568 | if ($plainText !== false) { |
| 569 | - $this->plainBody .= $plainText . ': '; |
|
| 569 | + $this->plainBody .= $plainText.': '; |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - $this->plainBody .= $url . PHP_EOL; |
|
| 572 | + $this->plainBody .= $url.PHP_EOL; |
|
| 573 | 573 | |
| 574 | 574 | } |
| 575 | 575 | |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
| 594 | 594 | */ |
| 595 | 595 | public function addFooter($text = '') { |
| 596 | - if($text === '') { |
|
| 597 | - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 596 | + if ($text === '') { |
|
| 597 | + $text = $this->themingDefaults->getName().' - '.$this->themingDefaults->getSlogan().'<br>'.$this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | if ($this->footerAdded) { |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | $this->htmlBody .= vsprintf($this->footer, [$text]); |
| 608 | 608 | $this->htmlBody .= $this->tail; |
| 609 | - $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
| 609 | + $this->plainBody .= PHP_EOL.'-- '.PHP_EOL; |
|
| 610 | 610 | $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
| 611 | 611 | } |
| 612 | 612 | |
@@ -35,296 +35,296 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | class OC_Defaults { |
| 37 | 37 | |
| 38 | - private $theme; |
|
| 39 | - private $l; |
|
| 38 | + private $theme; |
|
| 39 | + private $l; |
|
| 40 | 40 | |
| 41 | - private $defaultEntity; |
|
| 42 | - private $defaultName; |
|
| 43 | - private $defaultTitle; |
|
| 44 | - private $defaultBaseUrl; |
|
| 45 | - private $defaultSyncClientUrl; |
|
| 46 | - private $defaultiOSClientUrl; |
|
| 47 | - private $defaultiTunesAppId; |
|
| 48 | - private $defaultAndroidClientUrl; |
|
| 49 | - private $defaultDocBaseUrl; |
|
| 50 | - private $defaultDocVersion; |
|
| 51 | - private $defaultSlogan; |
|
| 52 | - private $defaultColorPrimary; |
|
| 53 | - private $defaultTextColorPrimary; |
|
| 41 | + private $defaultEntity; |
|
| 42 | + private $defaultName; |
|
| 43 | + private $defaultTitle; |
|
| 44 | + private $defaultBaseUrl; |
|
| 45 | + private $defaultSyncClientUrl; |
|
| 46 | + private $defaultiOSClientUrl; |
|
| 47 | + private $defaultiTunesAppId; |
|
| 48 | + private $defaultAndroidClientUrl; |
|
| 49 | + private $defaultDocBaseUrl; |
|
| 50 | + private $defaultDocVersion; |
|
| 51 | + private $defaultSlogan; |
|
| 52 | + private $defaultColorPrimary; |
|
| 53 | + private $defaultTextColorPrimary; |
|
| 54 | 54 | |
| 55 | - public function __construct() { |
|
| 56 | - $this->l = \OC::$server->getL10N('lib'); |
|
| 55 | + public function __construct() { |
|
| 56 | + $this->l = \OC::$server->getL10N('lib'); |
|
| 57 | 57 | |
| 58 | - $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ |
|
| 59 | - $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */ |
|
| 60 | - $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */ |
|
| 61 | - $this->defaultBaseUrl = 'https://nextcloud.com'; |
|
| 62 | - $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients'; |
|
| 63 | - $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
| 64 | - $this->defaultiTunesAppId = '1125420102'; |
|
| 65 | - $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
| 66 | - $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; |
|
| 67 | - $this->defaultDocVersion = '12'; // used to generate doc links |
|
| 68 | - $this->defaultSlogan = $this->l->t('a safe home for all your data'); |
|
| 69 | - $this->defaultColorPrimary = '#0082c9'; |
|
| 70 | - $this->defaultTextColorPrimary = '#ffffff'; |
|
| 58 | + $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ |
|
| 59 | + $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */ |
|
| 60 | + $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */ |
|
| 61 | + $this->defaultBaseUrl = 'https://nextcloud.com'; |
|
| 62 | + $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients'; |
|
| 63 | + $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
| 64 | + $this->defaultiTunesAppId = '1125420102'; |
|
| 65 | + $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
| 66 | + $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; |
|
| 67 | + $this->defaultDocVersion = '12'; // used to generate doc links |
|
| 68 | + $this->defaultSlogan = $this->l->t('a safe home for all your data'); |
|
| 69 | + $this->defaultColorPrimary = '#0082c9'; |
|
| 70 | + $this->defaultTextColorPrimary = '#ffffff'; |
|
| 71 | 71 | |
| 72 | - $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
| 73 | - if (file_exists($themePath)) { |
|
| 74 | - // prevent defaults.php from printing output |
|
| 75 | - ob_start(); |
|
| 76 | - require_once $themePath; |
|
| 77 | - ob_end_clean(); |
|
| 78 | - if (class_exists('OC_Theme')) { |
|
| 79 | - $this->theme = new OC_Theme(); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - } |
|
| 72 | + $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
| 73 | + if (file_exists($themePath)) { |
|
| 74 | + // prevent defaults.php from printing output |
|
| 75 | + ob_start(); |
|
| 76 | + require_once $themePath; |
|
| 77 | + ob_end_clean(); |
|
| 78 | + if (class_exists('OC_Theme')) { |
|
| 79 | + $this->theme = new OC_Theme(); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param string $method |
|
| 86 | - */ |
|
| 87 | - private function themeExist($method) { |
|
| 88 | - if (isset($this->theme) && method_exists($this->theme, $method)) { |
|
| 89 | - return true; |
|
| 90 | - } |
|
| 91 | - return false; |
|
| 92 | - } |
|
| 84 | + /** |
|
| 85 | + * @param string $method |
|
| 86 | + */ |
|
| 87 | + private function themeExist($method) { |
|
| 88 | + if (isset($this->theme) && method_exists($this->theme, $method)) { |
|
| 89 | + return true; |
|
| 90 | + } |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Returns the base URL |
|
| 96 | - * @return string URL |
|
| 97 | - */ |
|
| 98 | - public function getBaseUrl() { |
|
| 99 | - if ($this->themeExist('getBaseUrl')) { |
|
| 100 | - return $this->theme->getBaseUrl(); |
|
| 101 | - } else { |
|
| 102 | - return $this->defaultBaseUrl; |
|
| 103 | - } |
|
| 104 | - } |
|
| 94 | + /** |
|
| 95 | + * Returns the base URL |
|
| 96 | + * @return string URL |
|
| 97 | + */ |
|
| 98 | + public function getBaseUrl() { |
|
| 99 | + if ($this->themeExist('getBaseUrl')) { |
|
| 100 | + return $this->theme->getBaseUrl(); |
|
| 101 | + } else { |
|
| 102 | + return $this->defaultBaseUrl; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Returns the URL where the sync clients are listed |
|
| 108 | - * @return string URL |
|
| 109 | - */ |
|
| 110 | - public function getSyncClientUrl() { |
|
| 111 | - if ($this->themeExist('getSyncClientUrl')) { |
|
| 112 | - return $this->theme->getSyncClientUrl(); |
|
| 113 | - } else { |
|
| 114 | - return $this->defaultSyncClientUrl; |
|
| 115 | - } |
|
| 116 | - } |
|
| 106 | + /** |
|
| 107 | + * Returns the URL where the sync clients are listed |
|
| 108 | + * @return string URL |
|
| 109 | + */ |
|
| 110 | + public function getSyncClientUrl() { |
|
| 111 | + if ($this->themeExist('getSyncClientUrl')) { |
|
| 112 | + return $this->theme->getSyncClientUrl(); |
|
| 113 | + } else { |
|
| 114 | + return $this->defaultSyncClientUrl; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Returns the URL to the App Store for the iOS Client |
|
| 120 | - * @return string URL |
|
| 121 | - */ |
|
| 122 | - public function getiOSClientUrl() { |
|
| 123 | - if ($this->themeExist('getiOSClientUrl')) { |
|
| 124 | - return $this->theme->getiOSClientUrl(); |
|
| 125 | - } else { |
|
| 126 | - return $this->defaultiOSClientUrl; |
|
| 127 | - } |
|
| 128 | - } |
|
| 118 | + /** |
|
| 119 | + * Returns the URL to the App Store for the iOS Client |
|
| 120 | + * @return string URL |
|
| 121 | + */ |
|
| 122 | + public function getiOSClientUrl() { |
|
| 123 | + if ($this->themeExist('getiOSClientUrl')) { |
|
| 124 | + return $this->theme->getiOSClientUrl(); |
|
| 125 | + } else { |
|
| 126 | + return $this->defaultiOSClientUrl; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Returns the AppId for the App Store for the iOS Client |
|
| 132 | - * @return string AppId |
|
| 133 | - */ |
|
| 134 | - public function getiTunesAppId() { |
|
| 135 | - if ($this->themeExist('getiTunesAppId')) { |
|
| 136 | - return $this->theme->getiTunesAppId(); |
|
| 137 | - } else { |
|
| 138 | - return $this->defaultiTunesAppId; |
|
| 139 | - } |
|
| 140 | - } |
|
| 130 | + /** |
|
| 131 | + * Returns the AppId for the App Store for the iOS Client |
|
| 132 | + * @return string AppId |
|
| 133 | + */ |
|
| 134 | + public function getiTunesAppId() { |
|
| 135 | + if ($this->themeExist('getiTunesAppId')) { |
|
| 136 | + return $this->theme->getiTunesAppId(); |
|
| 137 | + } else { |
|
| 138 | + return $this->defaultiTunesAppId; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Returns the URL to Google Play for the Android Client |
|
| 144 | - * @return string URL |
|
| 145 | - */ |
|
| 146 | - public function getAndroidClientUrl() { |
|
| 147 | - if ($this->themeExist('getAndroidClientUrl')) { |
|
| 148 | - return $this->theme->getAndroidClientUrl(); |
|
| 149 | - } else { |
|
| 150 | - return $this->defaultAndroidClientUrl; |
|
| 151 | - } |
|
| 152 | - } |
|
| 142 | + /** |
|
| 143 | + * Returns the URL to Google Play for the Android Client |
|
| 144 | + * @return string URL |
|
| 145 | + */ |
|
| 146 | + public function getAndroidClientUrl() { |
|
| 147 | + if ($this->themeExist('getAndroidClientUrl')) { |
|
| 148 | + return $this->theme->getAndroidClientUrl(); |
|
| 149 | + } else { |
|
| 150 | + return $this->defaultAndroidClientUrl; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Returns the documentation URL |
|
| 156 | - * @return string URL |
|
| 157 | - */ |
|
| 158 | - public function getDocBaseUrl() { |
|
| 159 | - if ($this->themeExist('getDocBaseUrl')) { |
|
| 160 | - return $this->theme->getDocBaseUrl(); |
|
| 161 | - } else { |
|
| 162 | - return $this->defaultDocBaseUrl; |
|
| 163 | - } |
|
| 164 | - } |
|
| 154 | + /** |
|
| 155 | + * Returns the documentation URL |
|
| 156 | + * @return string URL |
|
| 157 | + */ |
|
| 158 | + public function getDocBaseUrl() { |
|
| 159 | + if ($this->themeExist('getDocBaseUrl')) { |
|
| 160 | + return $this->theme->getDocBaseUrl(); |
|
| 161 | + } else { |
|
| 162 | + return $this->defaultDocBaseUrl; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * Returns the title |
|
| 168 | - * @return string title |
|
| 169 | - */ |
|
| 170 | - public function getTitle() { |
|
| 171 | - if ($this->themeExist('getTitle')) { |
|
| 172 | - return $this->theme->getTitle(); |
|
| 173 | - } else { |
|
| 174 | - return $this->defaultTitle; |
|
| 175 | - } |
|
| 176 | - } |
|
| 166 | + /** |
|
| 167 | + * Returns the title |
|
| 168 | + * @return string title |
|
| 169 | + */ |
|
| 170 | + public function getTitle() { |
|
| 171 | + if ($this->themeExist('getTitle')) { |
|
| 172 | + return $this->theme->getTitle(); |
|
| 173 | + } else { |
|
| 174 | + return $this->defaultTitle; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Returns the short name of the software |
|
| 180 | - * @return string title |
|
| 181 | - */ |
|
| 182 | - public function getName() { |
|
| 183 | - if ($this->themeExist('getName')) { |
|
| 184 | - return $this->theme->getName(); |
|
| 185 | - } else { |
|
| 186 | - return $this->defaultName; |
|
| 187 | - } |
|
| 188 | - } |
|
| 178 | + /** |
|
| 179 | + * Returns the short name of the software |
|
| 180 | + * @return string title |
|
| 181 | + */ |
|
| 182 | + public function getName() { |
|
| 183 | + if ($this->themeExist('getName')) { |
|
| 184 | + return $this->theme->getName(); |
|
| 185 | + } else { |
|
| 186 | + return $this->defaultName; |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Returns the short name of the software containing HTML strings |
|
| 192 | - * @return string title |
|
| 193 | - */ |
|
| 194 | - public function getHTMLName() { |
|
| 195 | - if ($this->themeExist('getHTMLName')) { |
|
| 196 | - return $this->theme->getHTMLName(); |
|
| 197 | - } else { |
|
| 198 | - return $this->defaultName; |
|
| 199 | - } |
|
| 200 | - } |
|
| 190 | + /** |
|
| 191 | + * Returns the short name of the software containing HTML strings |
|
| 192 | + * @return string title |
|
| 193 | + */ |
|
| 194 | + public function getHTMLName() { |
|
| 195 | + if ($this->themeExist('getHTMLName')) { |
|
| 196 | + return $this->theme->getHTMLName(); |
|
| 197 | + } else { |
|
| 198 | + return $this->defaultName; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - /** |
|
| 203 | - * Returns entity (e.g. company name) - used for footer, copyright |
|
| 204 | - * @return string entity name |
|
| 205 | - */ |
|
| 206 | - public function getEntity() { |
|
| 207 | - if ($this->themeExist('getEntity')) { |
|
| 208 | - return $this->theme->getEntity(); |
|
| 209 | - } else { |
|
| 210 | - return $this->defaultEntity; |
|
| 211 | - } |
|
| 212 | - } |
|
| 202 | + /** |
|
| 203 | + * Returns entity (e.g. company name) - used for footer, copyright |
|
| 204 | + * @return string entity name |
|
| 205 | + */ |
|
| 206 | + public function getEntity() { |
|
| 207 | + if ($this->themeExist('getEntity')) { |
|
| 208 | + return $this->theme->getEntity(); |
|
| 209 | + } else { |
|
| 210 | + return $this->defaultEntity; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Returns slogan |
|
| 216 | - * @return string slogan |
|
| 217 | - */ |
|
| 218 | - public function getSlogan() { |
|
| 219 | - if ($this->themeExist('getSlogan')) { |
|
| 220 | - return $this->theme->getSlogan(); |
|
| 221 | - } else { |
|
| 222 | - return $this->defaultSlogan; |
|
| 223 | - } |
|
| 224 | - } |
|
| 214 | + /** |
|
| 215 | + * Returns slogan |
|
| 216 | + * @return string slogan |
|
| 217 | + */ |
|
| 218 | + public function getSlogan() { |
|
| 219 | + if ($this->themeExist('getSlogan')) { |
|
| 220 | + return $this->theme->getSlogan(); |
|
| 221 | + } else { |
|
| 222 | + return $this->defaultSlogan; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Returns logo claim |
|
| 228 | - * @return string logo claim |
|
| 229 | - * @deprecated 13.0.0 |
|
| 230 | - */ |
|
| 231 | - public function getLogoClaim() { |
|
| 232 | - return ''; |
|
| 233 | - } |
|
| 226 | + /** |
|
| 227 | + * Returns logo claim |
|
| 228 | + * @return string logo claim |
|
| 229 | + * @deprecated 13.0.0 |
|
| 230 | + */ |
|
| 231 | + public function getLogoClaim() { |
|
| 232 | + return ''; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * Returns short version of the footer |
|
| 237 | - * @return string short footer |
|
| 238 | - */ |
|
| 239 | - public function getShortFooter() { |
|
| 240 | - if ($this->themeExist('getShortFooter')) { |
|
| 241 | - $footer = $this->theme->getShortFooter(); |
|
| 242 | - } else { |
|
| 243 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 244 | - ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'. |
|
| 245 | - ' – ' . $this->getSlogan(); |
|
| 246 | - } |
|
| 235 | + /** |
|
| 236 | + * Returns short version of the footer |
|
| 237 | + * @return string short footer |
|
| 238 | + */ |
|
| 239 | + public function getShortFooter() { |
|
| 240 | + if ($this->themeExist('getShortFooter')) { |
|
| 241 | + $footer = $this->theme->getShortFooter(); |
|
| 242 | + } else { |
|
| 243 | + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 244 | + ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'. |
|
| 245 | + ' – ' . $this->getSlogan(); |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - return $footer; |
|
| 249 | - } |
|
| 248 | + return $footer; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Returns long version of the footer |
|
| 253 | - * @return string long footer |
|
| 254 | - */ |
|
| 255 | - public function getLongFooter() { |
|
| 256 | - if ($this->themeExist('getLongFooter')) { |
|
| 257 | - $footer = $this->theme->getLongFooter(); |
|
| 258 | - } else { |
|
| 259 | - $footer = $this->getShortFooter(); |
|
| 260 | - } |
|
| 251 | + /** |
|
| 252 | + * Returns long version of the footer |
|
| 253 | + * @return string long footer |
|
| 254 | + */ |
|
| 255 | + public function getLongFooter() { |
|
| 256 | + if ($this->themeExist('getLongFooter')) { |
|
| 257 | + $footer = $this->theme->getLongFooter(); |
|
| 258 | + } else { |
|
| 259 | + $footer = $this->getShortFooter(); |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - return $footer; |
|
| 263 | - } |
|
| 262 | + return $footer; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - /** |
|
| 266 | - * @param string $key |
|
| 267 | - * @return string URL to doc with key |
|
| 268 | - */ |
|
| 269 | - public function buildDocLinkToKey($key) { |
|
| 270 | - if ($this->themeExist('buildDocLinkToKey')) { |
|
| 271 | - return $this->theme->buildDocLinkToKey($key); |
|
| 272 | - } |
|
| 273 | - return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
| 274 | - } |
|
| 265 | + /** |
|
| 266 | + * @param string $key |
|
| 267 | + * @return string URL to doc with key |
|
| 268 | + */ |
|
| 269 | + public function buildDocLinkToKey($key) { |
|
| 270 | + if ($this->themeExist('buildDocLinkToKey')) { |
|
| 271 | + return $this->theme->buildDocLinkToKey($key); |
|
| 272 | + } |
|
| 273 | + return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * Returns primary color |
|
| 278 | - * @return string |
|
| 279 | - */ |
|
| 280 | - public function getColorPrimary() { |
|
| 276 | + /** |
|
| 277 | + * Returns primary color |
|
| 278 | + * @return string |
|
| 279 | + */ |
|
| 280 | + public function getColorPrimary() { |
|
| 281 | 281 | |
| 282 | - if ($this->themeExist('getColorPrimary')) { |
|
| 283 | - return $this->theme->getColorPrimary(); |
|
| 284 | - } |
|
| 285 | - if ($this->themeExist('getMailHeaderColor')) { |
|
| 286 | - return $this->theme->getMailHeaderColor(); |
|
| 287 | - } |
|
| 288 | - return $this->defaultColorPrimary; |
|
| 289 | - } |
|
| 282 | + if ($this->themeExist('getColorPrimary')) { |
|
| 283 | + return $this->theme->getColorPrimary(); |
|
| 284 | + } |
|
| 285 | + if ($this->themeExist('getMailHeaderColor')) { |
|
| 286 | + return $this->theme->getMailHeaderColor(); |
|
| 287 | + } |
|
| 288 | + return $this->defaultColorPrimary; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * @return array scss variables to overwrite |
|
| 293 | - */ |
|
| 294 | - public function getScssVariables() { |
|
| 295 | - if($this->themeExist('getScssVariables')) { |
|
| 296 | - return $this->theme->getScssVariables(); |
|
| 297 | - } |
|
| 298 | - return []; |
|
| 299 | - } |
|
| 291 | + /** |
|
| 292 | + * @return array scss variables to overwrite |
|
| 293 | + */ |
|
| 294 | + public function getScssVariables() { |
|
| 295 | + if($this->themeExist('getScssVariables')) { |
|
| 296 | + return $this->theme->getScssVariables(); |
|
| 297 | + } |
|
| 298 | + return []; |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - public function shouldReplaceIcons() { |
|
| 302 | - return false; |
|
| 303 | - } |
|
| 301 | + public function shouldReplaceIcons() { |
|
| 302 | + return false; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - /** |
|
| 306 | - * Themed logo url |
|
| 307 | - * |
|
| 308 | - * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
| 309 | - * @return string |
|
| 310 | - */ |
|
| 311 | - public function getLogo($useSvg = true) { |
|
| 312 | - if ($this->themeExist('getLogo')) { |
|
| 313 | - return $this->theme->getLogo($useSvg); |
|
| 314 | - } |
|
| 305 | + /** |
|
| 306 | + * Themed logo url |
|
| 307 | + * |
|
| 308 | + * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
| 309 | + * @return string |
|
| 310 | + */ |
|
| 311 | + public function getLogo($useSvg = true) { |
|
| 312 | + if ($this->themeExist('getLogo')) { |
|
| 313 | + return $this->theme->getLogo($useSvg); |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - if($useSvg) { |
|
| 317 | - $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg'); |
|
| 318 | - } else { |
|
| 319 | - $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png'); |
|
| 320 | - } |
|
| 321 | - return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion())); |
|
| 322 | - } |
|
| 316 | + if($useSvg) { |
|
| 317 | + $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg'); |
|
| 318 | + } else { |
|
| 319 | + $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png'); |
|
| 320 | + } |
|
| 321 | + return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion())); |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - public function getTextColorPrimary() { |
|
| 325 | - if ($this->themeExist('getTextColorPrimary')) { |
|
| 326 | - return $this->theme->getTextColorPrimary(); |
|
| 327 | - } |
|
| 328 | - return $this->defaultTextColorPrimary; |
|
| 329 | - } |
|
| 324 | + public function getTextColorPrimary() { |
|
| 325 | + if ($this->themeExist('getTextColorPrimary')) { |
|
| 326 | + return $this->theme->getTextColorPrimary(); |
|
| 327 | + } |
|
| 328 | + return $this->defaultTextColorPrimary; |
|
| 329 | + } |
|
| 330 | 330 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $this->defaultColorPrimary = '#0082c9'; |
| 70 | 70 | $this->defaultTextColorPrimary = '#ffffff'; |
| 71 | 71 | |
| 72 | - $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
| 72 | + $themePath = OC::$SERVERROOT.'/themes/'.OC_Util::getTheme().'/defaults.php'; |
|
| 73 | 73 | if (file_exists($themePath)) { |
| 74 | 74 | // prevent defaults.php from printing output |
| 75 | 75 | ob_start(); |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | if ($this->themeExist('getShortFooter')) { |
| 241 | 241 | $footer = $this->theme->getShortFooter(); |
| 242 | 242 | } else { |
| 243 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 244 | - ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'. |
|
| 245 | - ' – ' . $this->getSlogan(); |
|
| 243 | + $footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'. |
|
| 244 | + ' rel="noreferrer noopener">'.$this->getEntity().'</a>'. |
|
| 245 | + ' – '.$this->getSlogan(); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | return $footer; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | if ($this->themeExist('buildDocLinkToKey')) { |
| 271 | 271 | return $this->theme->buildDocLinkToKey($key); |
| 272 | 272 | } |
| 273 | - return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
| 273 | + return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | * @return array scss variables to overwrite |
| 293 | 293 | */ |
| 294 | 294 | public function getScssVariables() { |
| 295 | - if($this->themeExist('getScssVariables')) { |
|
| 295 | + if ($this->themeExist('getScssVariables')) { |
|
| 296 | 296 | return $this->theme->getScssVariables(); |
| 297 | 297 | } |
| 298 | 298 | return []; |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | return $this->theme->getLogo($useSvg); |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if($useSvg) { |
|
| 316 | + if ($useSvg) { |
|
| 317 | 317 | $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg'); |
| 318 | 318 | } else { |
| 319 | 319 | $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png'); |
| 320 | 320 | } |
| 321 | - return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion())); |
|
| 321 | + return $logo.'?v='.hash('sha1', implode('.', \OCP\Util::getVersion())); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | public function getTextColorPrimary() { |
@@ -36,52 +36,52 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class Capabilities implements IPublicCapability { |
| 38 | 38 | |
| 39 | - /** @var ThemingDefaults */ |
|
| 40 | - protected $theming; |
|
| 39 | + /** @var ThemingDefaults */ |
|
| 40 | + protected $theming; |
|
| 41 | 41 | |
| 42 | - /** @var Util */ |
|
| 43 | - protected $util; |
|
| 42 | + /** @var Util */ |
|
| 43 | + protected $util; |
|
| 44 | 44 | |
| 45 | - /** @var IURLGenerator */ |
|
| 46 | - protected $url; |
|
| 45 | + /** @var IURLGenerator */ |
|
| 46 | + protected $url; |
|
| 47 | 47 | |
| 48 | - /** @var IConfig */ |
|
| 49 | - protected $config; |
|
| 48 | + /** @var IConfig */ |
|
| 49 | + protected $config; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param ThemingDefaults $theming |
|
| 53 | - * @param Util $util |
|
| 54 | - * @param IURLGenerator $url |
|
| 55 | - * @param IConfig $config |
|
| 56 | - */ |
|
| 57 | - public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) { |
|
| 58 | - $this->theming = $theming; |
|
| 59 | - $this->util = $util; |
|
| 60 | - $this->url = $url; |
|
| 61 | - $this->config = $config; |
|
| 62 | - } |
|
| 51 | + /** |
|
| 52 | + * @param ThemingDefaults $theming |
|
| 53 | + * @param Util $util |
|
| 54 | + * @param IURLGenerator $url |
|
| 55 | + * @param IConfig $config |
|
| 56 | + */ |
|
| 57 | + public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) { |
|
| 58 | + $this->theming = $theming; |
|
| 59 | + $this->util = $util; |
|
| 60 | + $this->url = $url; |
|
| 61 | + $this->config = $config; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Return this classes capabilities |
|
| 66 | - * |
|
| 67 | - * @return array |
|
| 68 | - */ |
|
| 69 | - public function getCapabilities() { |
|
| 70 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
| 71 | - $color = $this->theming->getColorPrimary(); |
|
| 72 | - return [ |
|
| 73 | - 'theming' => [ |
|
| 74 | - 'name' => $this->theming->getName(), |
|
| 75 | - 'url' => $this->theming->getBaseUrl(), |
|
| 76 | - 'slogan' => $this->theming->getSlogan(), |
|
| 77 | - 'color' => $color, |
|
| 78 | - 'color-text' => $this->theming->getTextColorPrimary(), |
|
| 79 | - 'color-element' => $this->util->elementColor($color), |
|
| 80 | - 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 81 | - 'background' => $backgroundLogo === 'backgroundColor' ? |
|
| 82 | - $this->theming->getColorPrimary() : |
|
| 83 | - $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 84 | - ], |
|
| 85 | - ]; |
|
| 86 | - } |
|
| 64 | + /** |
|
| 65 | + * Return this classes capabilities |
|
| 66 | + * |
|
| 67 | + * @return array |
|
| 68 | + */ |
|
| 69 | + public function getCapabilities() { |
|
| 70 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
| 71 | + $color = $this->theming->getColorPrimary(); |
|
| 72 | + return [ |
|
| 73 | + 'theming' => [ |
|
| 74 | + 'name' => $this->theming->getName(), |
|
| 75 | + 'url' => $this->theming->getBaseUrl(), |
|
| 76 | + 'slogan' => $this->theming->getSlogan(), |
|
| 77 | + 'color' => $color, |
|
| 78 | + 'color-text' => $this->theming->getTextColorPrimary(), |
|
| 79 | + 'color-element' => $this->util->elementColor($color), |
|
| 80 | + 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 81 | + 'background' => $backgroundLogo === 'backgroundColor' ? |
|
| 82 | + $this->theming->getColorPrimary() : |
|
| 83 | + $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 84 | + ], |
|
| 85 | + ]; |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -44,342 +44,342 @@ |
||
| 44 | 44 | |
| 45 | 45 | class ThemingDefaults extends \OC_Defaults { |
| 46 | 46 | |
| 47 | - /** @var IConfig */ |
|
| 48 | - private $config; |
|
| 49 | - /** @var IL10N */ |
|
| 50 | - private $l; |
|
| 51 | - /** @var IURLGenerator */ |
|
| 52 | - private $urlGenerator; |
|
| 53 | - /** @var IAppData */ |
|
| 54 | - private $appData; |
|
| 55 | - /** @var ICacheFactory */ |
|
| 56 | - private $cacheFactory; |
|
| 57 | - /** @var Util */ |
|
| 58 | - private $util; |
|
| 59 | - /** @var IAppManager */ |
|
| 60 | - private $appManager; |
|
| 61 | - /** @var string */ |
|
| 62 | - private $name; |
|
| 63 | - /** @var string */ |
|
| 64 | - private $title; |
|
| 65 | - /** @var string */ |
|
| 66 | - private $entity; |
|
| 67 | - /** @var string */ |
|
| 68 | - private $url; |
|
| 69 | - /** @var string */ |
|
| 70 | - private $slogan; |
|
| 71 | - /** @var string */ |
|
| 72 | - private $color; |
|
| 73 | - |
|
| 74 | - /** @var string */ |
|
| 75 | - private $iTunesAppId; |
|
| 76 | - /** @var string */ |
|
| 77 | - private $iOSClientUrl; |
|
| 78 | - /** @var string */ |
|
| 79 | - private $AndroidClientUrl; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * ThemingDefaults constructor. |
|
| 83 | - * |
|
| 84 | - * @param IConfig $config |
|
| 85 | - * @param IL10N $l |
|
| 86 | - * @param IURLGenerator $urlGenerator |
|
| 87 | - * @param \OC_Defaults $defaults |
|
| 88 | - * @param IAppData $appData |
|
| 89 | - * @param ICacheFactory $cacheFactory |
|
| 90 | - * @param Util $util |
|
| 91 | - * @param IAppManager $appManager |
|
| 92 | - */ |
|
| 93 | - public function __construct(IConfig $config, |
|
| 94 | - IL10N $l, |
|
| 95 | - IURLGenerator $urlGenerator, |
|
| 96 | - IAppData $appData, |
|
| 97 | - ICacheFactory $cacheFactory, |
|
| 98 | - Util $util, |
|
| 99 | - IAppManager $appManager |
|
| 100 | - ) { |
|
| 101 | - parent::__construct(); |
|
| 102 | - $this->config = $config; |
|
| 103 | - $this->l = $l; |
|
| 104 | - $this->urlGenerator = $urlGenerator; |
|
| 105 | - $this->appData = $appData; |
|
| 106 | - $this->cacheFactory = $cacheFactory; |
|
| 107 | - $this->util = $util; |
|
| 108 | - $this->appManager = $appManager; |
|
| 109 | - |
|
| 110 | - $this->name = parent::getName(); |
|
| 111 | - $this->title = parent::getTitle(); |
|
| 112 | - $this->entity = parent::getEntity(); |
|
| 113 | - $this->url = parent::getBaseUrl(); |
|
| 114 | - $this->slogan = parent::getSlogan(); |
|
| 115 | - $this->color = parent::getColorPrimary(); |
|
| 116 | - $this->iTunesAppId = parent::getiTunesAppId(); |
|
| 117 | - $this->iOSClientUrl = parent::getiOSClientUrl(); |
|
| 118 | - $this->AndroidClientUrl = parent::getAndroidClientUrl(); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - public function getName() { |
|
| 122 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - public function getHTMLName() { |
|
| 126 | - return $this->config->getAppValue('theming', 'name', $this->name); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - public function getTitle() { |
|
| 130 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->title)); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - public function getEntity() { |
|
| 134 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->entity)); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - public function getBaseUrl() { |
|
| 138 | - return $this->config->getAppValue('theming', 'url', $this->url); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - public function getSlogan() { |
|
| 142 | - return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - public function getShortFooter() { |
|
| 146 | - $slogan = $this->getSlogan(); |
|
| 147 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 148 | - ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'. |
|
| 149 | - ($slogan !== '' ? ' – ' . $slogan : ''); |
|
| 150 | - |
|
| 151 | - return $footer; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Color that is used for the header as well as for mail headers |
|
| 156 | - * |
|
| 157 | - * @return string |
|
| 158 | - */ |
|
| 159 | - public function getColorPrimary() { |
|
| 160 | - return $this->config->getAppValue('theming', 'color', $this->color); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Themed logo url |
|
| 165 | - * |
|
| 166 | - * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
| 167 | - * @return string |
|
| 168 | - */ |
|
| 169 | - public function getLogo($useSvg = true) { |
|
| 170 | - $logo = $this->config->getAppValue('theming', 'logoMime', false); |
|
| 171 | - |
|
| 172 | - $logoExists = true; |
|
| 173 | - try { |
|
| 174 | - $this->appData->getFolder('images')->getFile('logo'); |
|
| 175 | - } catch (\Exception $e) { |
|
| 176 | - $logoExists = false; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 180 | - |
|
| 181 | - if(!$logo || !$logoExists) { |
|
| 182 | - if($useSvg) { |
|
| 183 | - $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); |
|
| 184 | - } else { |
|
| 185 | - $logo = $this->urlGenerator->imagePath('core', 'logo.png'); |
|
| 186 | - } |
|
| 187 | - return $logo . '?v=' . $cacheBusterCounter; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Themed background image url |
|
| 195 | - * |
|
| 196 | - * @return string |
|
| 197 | - */ |
|
| 198 | - public function getBackground() { |
|
| 199 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 200 | - |
|
| 201 | - $backgroundExists = true; |
|
| 202 | - try { |
|
| 203 | - $this->appData->getFolder('images')->getFile('background'); |
|
| 204 | - } catch (\Exception $e) { |
|
| 205 | - $backgroundExists = false; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 209 | - |
|
| 210 | - if(!$backgroundLogo || !$backgroundExists) { |
|
| 211 | - return $this->urlGenerator->imagePath('core','background.png') . '?v=' . $cacheBusterCounter; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * @return string |
|
| 219 | - */ |
|
| 220 | - public function getiTunesAppId() { |
|
| 221 | - return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * @return string |
|
| 226 | - */ |
|
| 227 | - public function getiOSClientUrl() { |
|
| 228 | - return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * @return string |
|
| 233 | - */ |
|
| 234 | - public function getAndroidClientUrl() { |
|
| 235 | - return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * @return array scss variables to overwrite |
|
| 241 | - */ |
|
| 242 | - public function getScssVariables() { |
|
| 243 | - $cache = $this->cacheFactory->create('theming'); |
|
| 244 | - if ($value = $cache->get('getScssVariables')) { |
|
| 245 | - return $value; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - $variables = [ |
|
| 249 | - 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
| 250 | - 'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime', '') . "'", |
|
| 251 | - 'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime', '') . "'" |
|
| 252 | - ]; |
|
| 253 | - |
|
| 254 | - $variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'"; |
|
| 255 | - $variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'"; |
|
| 256 | - $variables['image-login-plain'] = 'false'; |
|
| 257 | - |
|
| 258 | - if ($this->config->getAppValue('theming', 'color', null) !== null) { |
|
| 259 | - $variables['color-primary'] = $this->getColorPrimary(); |
|
| 260 | - $variables['color-primary-text'] = $this->getTextColorPrimary(); |
|
| 261 | - $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary()); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') { |
|
| 265 | - $variables['image-login-plain'] = 'true'; |
|
| 266 | - } |
|
| 267 | - $cache->set('getScssVariables', $variables); |
|
| 268 | - return $variables; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Check if the image should be replaced by the theming app |
|
| 273 | - * and return the new image location then |
|
| 274 | - * |
|
| 275 | - * @param string $app name of the app |
|
| 276 | - * @param string $image filename of the image |
|
| 277 | - * @return bool|string false if image should not replaced, otherwise the location of the image |
|
| 278 | - */ |
|
| 279 | - public function replaceImagePath($app, $image) { |
|
| 280 | - if($app==='') { |
|
| 281 | - $app = 'core'; |
|
| 282 | - } |
|
| 283 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 284 | - |
|
| 285 | - if ($image === 'favicon.ico' && $this->shouldReplaceIcons()) { |
|
| 286 | - return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
| 287 | - } |
|
| 288 | - if ($image === 'favicon-touch.png' && $this->shouldReplaceIcons()) { |
|
| 289 | - return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
| 290 | - } |
|
| 291 | - if ($image === 'manifest.json') { |
|
| 292 | - try { |
|
| 293 | - $appPath = $this->appManager->getAppPath($app); |
|
| 294 | - if (file_exists($appPath . '/img/manifest.json')) { |
|
| 295 | - return false; |
|
| 296 | - } |
|
| 297 | - } catch (AppPathNotFoundException $e) {} |
|
| 298 | - return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; |
|
| 299 | - } |
|
| 300 | - return false; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Check if Imagemagick is enabled and if SVG is supported |
|
| 305 | - * otherwise we can't render custom icons |
|
| 306 | - * |
|
| 307 | - * @return bool |
|
| 308 | - */ |
|
| 309 | - public function shouldReplaceIcons() { |
|
| 310 | - $cache = $this->cacheFactory->create('theming'); |
|
| 311 | - if($value = $cache->get('shouldReplaceIcons')) { |
|
| 312 | - return (bool)$value; |
|
| 313 | - } |
|
| 314 | - $value = false; |
|
| 315 | - if(extension_loaded('imagick')) { |
|
| 316 | - $checkImagick = new \Imagick(); |
|
| 317 | - if (count($checkImagick->queryFormats('SVG')) >= 1) { |
|
| 318 | - $value = true; |
|
| 319 | - } |
|
| 320 | - $checkImagick->clear(); |
|
| 321 | - } |
|
| 322 | - $cache->set('shouldReplaceIcons', $value); |
|
| 323 | - return $value; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * Increases the cache buster key |
|
| 328 | - */ |
|
| 329 | - private function increaseCacheBuster() { |
|
| 330 | - $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 331 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
| 332 | - $this->cacheFactory->create('theming')->clear('getScssVariables'); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Update setting in the database |
|
| 337 | - * |
|
| 338 | - * @param string $setting |
|
| 339 | - * @param string $value |
|
| 340 | - */ |
|
| 341 | - public function set($setting, $value) { |
|
| 342 | - $this->config->setAppValue('theming', $setting, $value); |
|
| 343 | - $this->increaseCacheBuster(); |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * Revert settings to the default value |
|
| 348 | - * |
|
| 349 | - * @param string $setting setting which should be reverted |
|
| 350 | - * @return string default value |
|
| 351 | - */ |
|
| 352 | - public function undo($setting) { |
|
| 353 | - $this->config->deleteAppValue('theming', $setting); |
|
| 354 | - $this->increaseCacheBuster(); |
|
| 355 | - |
|
| 356 | - switch ($setting) { |
|
| 357 | - case 'name': |
|
| 358 | - $returnValue = $this->getEntity(); |
|
| 359 | - break; |
|
| 360 | - case 'url': |
|
| 361 | - $returnValue = $this->getBaseUrl(); |
|
| 362 | - break; |
|
| 363 | - case 'slogan': |
|
| 364 | - $returnValue = $this->getSlogan(); |
|
| 365 | - break; |
|
| 366 | - case 'color': |
|
| 367 | - $returnValue = $this->getColorPrimary(); |
|
| 368 | - break; |
|
| 369 | - default: |
|
| 370 | - $returnValue = ''; |
|
| 371 | - break; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - return $returnValue; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * Color of text in the header and primary buttons |
|
| 379 | - * |
|
| 380 | - * @return string |
|
| 381 | - */ |
|
| 382 | - public function getTextColorPrimary() { |
|
| 383 | - return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#FFFFFF'; |
|
| 384 | - } |
|
| 47 | + /** @var IConfig */ |
|
| 48 | + private $config; |
|
| 49 | + /** @var IL10N */ |
|
| 50 | + private $l; |
|
| 51 | + /** @var IURLGenerator */ |
|
| 52 | + private $urlGenerator; |
|
| 53 | + /** @var IAppData */ |
|
| 54 | + private $appData; |
|
| 55 | + /** @var ICacheFactory */ |
|
| 56 | + private $cacheFactory; |
|
| 57 | + /** @var Util */ |
|
| 58 | + private $util; |
|
| 59 | + /** @var IAppManager */ |
|
| 60 | + private $appManager; |
|
| 61 | + /** @var string */ |
|
| 62 | + private $name; |
|
| 63 | + /** @var string */ |
|
| 64 | + private $title; |
|
| 65 | + /** @var string */ |
|
| 66 | + private $entity; |
|
| 67 | + /** @var string */ |
|
| 68 | + private $url; |
|
| 69 | + /** @var string */ |
|
| 70 | + private $slogan; |
|
| 71 | + /** @var string */ |
|
| 72 | + private $color; |
|
| 73 | + |
|
| 74 | + /** @var string */ |
|
| 75 | + private $iTunesAppId; |
|
| 76 | + /** @var string */ |
|
| 77 | + private $iOSClientUrl; |
|
| 78 | + /** @var string */ |
|
| 79 | + private $AndroidClientUrl; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * ThemingDefaults constructor. |
|
| 83 | + * |
|
| 84 | + * @param IConfig $config |
|
| 85 | + * @param IL10N $l |
|
| 86 | + * @param IURLGenerator $urlGenerator |
|
| 87 | + * @param \OC_Defaults $defaults |
|
| 88 | + * @param IAppData $appData |
|
| 89 | + * @param ICacheFactory $cacheFactory |
|
| 90 | + * @param Util $util |
|
| 91 | + * @param IAppManager $appManager |
|
| 92 | + */ |
|
| 93 | + public function __construct(IConfig $config, |
|
| 94 | + IL10N $l, |
|
| 95 | + IURLGenerator $urlGenerator, |
|
| 96 | + IAppData $appData, |
|
| 97 | + ICacheFactory $cacheFactory, |
|
| 98 | + Util $util, |
|
| 99 | + IAppManager $appManager |
|
| 100 | + ) { |
|
| 101 | + parent::__construct(); |
|
| 102 | + $this->config = $config; |
|
| 103 | + $this->l = $l; |
|
| 104 | + $this->urlGenerator = $urlGenerator; |
|
| 105 | + $this->appData = $appData; |
|
| 106 | + $this->cacheFactory = $cacheFactory; |
|
| 107 | + $this->util = $util; |
|
| 108 | + $this->appManager = $appManager; |
|
| 109 | + |
|
| 110 | + $this->name = parent::getName(); |
|
| 111 | + $this->title = parent::getTitle(); |
|
| 112 | + $this->entity = parent::getEntity(); |
|
| 113 | + $this->url = parent::getBaseUrl(); |
|
| 114 | + $this->slogan = parent::getSlogan(); |
|
| 115 | + $this->color = parent::getColorPrimary(); |
|
| 116 | + $this->iTunesAppId = parent::getiTunesAppId(); |
|
| 117 | + $this->iOSClientUrl = parent::getiOSClientUrl(); |
|
| 118 | + $this->AndroidClientUrl = parent::getAndroidClientUrl(); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + public function getName() { |
|
| 122 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + public function getHTMLName() { |
|
| 126 | + return $this->config->getAppValue('theming', 'name', $this->name); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + public function getTitle() { |
|
| 130 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->title)); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + public function getEntity() { |
|
| 134 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->entity)); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + public function getBaseUrl() { |
|
| 138 | + return $this->config->getAppValue('theming', 'url', $this->url); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + public function getSlogan() { |
|
| 142 | + return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + public function getShortFooter() { |
|
| 146 | + $slogan = $this->getSlogan(); |
|
| 147 | + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 148 | + ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'. |
|
| 149 | + ($slogan !== '' ? ' – ' . $slogan : ''); |
|
| 150 | + |
|
| 151 | + return $footer; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Color that is used for the header as well as for mail headers |
|
| 156 | + * |
|
| 157 | + * @return string |
|
| 158 | + */ |
|
| 159 | + public function getColorPrimary() { |
|
| 160 | + return $this->config->getAppValue('theming', 'color', $this->color); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Themed logo url |
|
| 165 | + * |
|
| 166 | + * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
| 167 | + * @return string |
|
| 168 | + */ |
|
| 169 | + public function getLogo($useSvg = true) { |
|
| 170 | + $logo = $this->config->getAppValue('theming', 'logoMime', false); |
|
| 171 | + |
|
| 172 | + $logoExists = true; |
|
| 173 | + try { |
|
| 174 | + $this->appData->getFolder('images')->getFile('logo'); |
|
| 175 | + } catch (\Exception $e) { |
|
| 176 | + $logoExists = false; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 180 | + |
|
| 181 | + if(!$logo || !$logoExists) { |
|
| 182 | + if($useSvg) { |
|
| 183 | + $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); |
|
| 184 | + } else { |
|
| 185 | + $logo = $this->urlGenerator->imagePath('core', 'logo.png'); |
|
| 186 | + } |
|
| 187 | + return $logo . '?v=' . $cacheBusterCounter; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Themed background image url |
|
| 195 | + * |
|
| 196 | + * @return string |
|
| 197 | + */ |
|
| 198 | + public function getBackground() { |
|
| 199 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 200 | + |
|
| 201 | + $backgroundExists = true; |
|
| 202 | + try { |
|
| 203 | + $this->appData->getFolder('images')->getFile('background'); |
|
| 204 | + } catch (\Exception $e) { |
|
| 205 | + $backgroundExists = false; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 209 | + |
|
| 210 | + if(!$backgroundLogo || !$backgroundExists) { |
|
| 211 | + return $this->urlGenerator->imagePath('core','background.png') . '?v=' . $cacheBusterCounter; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * @return string |
|
| 219 | + */ |
|
| 220 | + public function getiTunesAppId() { |
|
| 221 | + return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * @return string |
|
| 226 | + */ |
|
| 227 | + public function getiOSClientUrl() { |
|
| 228 | + return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * @return string |
|
| 233 | + */ |
|
| 234 | + public function getAndroidClientUrl() { |
|
| 235 | + return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * @return array scss variables to overwrite |
|
| 241 | + */ |
|
| 242 | + public function getScssVariables() { |
|
| 243 | + $cache = $this->cacheFactory->create('theming'); |
|
| 244 | + if ($value = $cache->get('getScssVariables')) { |
|
| 245 | + return $value; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + $variables = [ |
|
| 249 | + 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
| 250 | + 'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime', '') . "'", |
|
| 251 | + 'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime', '') . "'" |
|
| 252 | + ]; |
|
| 253 | + |
|
| 254 | + $variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'"; |
|
| 255 | + $variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'"; |
|
| 256 | + $variables['image-login-plain'] = 'false'; |
|
| 257 | + |
|
| 258 | + if ($this->config->getAppValue('theming', 'color', null) !== null) { |
|
| 259 | + $variables['color-primary'] = $this->getColorPrimary(); |
|
| 260 | + $variables['color-primary-text'] = $this->getTextColorPrimary(); |
|
| 261 | + $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary()); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') { |
|
| 265 | + $variables['image-login-plain'] = 'true'; |
|
| 266 | + } |
|
| 267 | + $cache->set('getScssVariables', $variables); |
|
| 268 | + return $variables; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Check if the image should be replaced by the theming app |
|
| 273 | + * and return the new image location then |
|
| 274 | + * |
|
| 275 | + * @param string $app name of the app |
|
| 276 | + * @param string $image filename of the image |
|
| 277 | + * @return bool|string false if image should not replaced, otherwise the location of the image |
|
| 278 | + */ |
|
| 279 | + public function replaceImagePath($app, $image) { |
|
| 280 | + if($app==='') { |
|
| 281 | + $app = 'core'; |
|
| 282 | + } |
|
| 283 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 284 | + |
|
| 285 | + if ($image === 'favicon.ico' && $this->shouldReplaceIcons()) { |
|
| 286 | + return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
| 287 | + } |
|
| 288 | + if ($image === 'favicon-touch.png' && $this->shouldReplaceIcons()) { |
|
| 289 | + return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
| 290 | + } |
|
| 291 | + if ($image === 'manifest.json') { |
|
| 292 | + try { |
|
| 293 | + $appPath = $this->appManager->getAppPath($app); |
|
| 294 | + if (file_exists($appPath . '/img/manifest.json')) { |
|
| 295 | + return false; |
|
| 296 | + } |
|
| 297 | + } catch (AppPathNotFoundException $e) {} |
|
| 298 | + return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; |
|
| 299 | + } |
|
| 300 | + return false; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Check if Imagemagick is enabled and if SVG is supported |
|
| 305 | + * otherwise we can't render custom icons |
|
| 306 | + * |
|
| 307 | + * @return bool |
|
| 308 | + */ |
|
| 309 | + public function shouldReplaceIcons() { |
|
| 310 | + $cache = $this->cacheFactory->create('theming'); |
|
| 311 | + if($value = $cache->get('shouldReplaceIcons')) { |
|
| 312 | + return (bool)$value; |
|
| 313 | + } |
|
| 314 | + $value = false; |
|
| 315 | + if(extension_loaded('imagick')) { |
|
| 316 | + $checkImagick = new \Imagick(); |
|
| 317 | + if (count($checkImagick->queryFormats('SVG')) >= 1) { |
|
| 318 | + $value = true; |
|
| 319 | + } |
|
| 320 | + $checkImagick->clear(); |
|
| 321 | + } |
|
| 322 | + $cache->set('shouldReplaceIcons', $value); |
|
| 323 | + return $value; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * Increases the cache buster key |
|
| 328 | + */ |
|
| 329 | + private function increaseCacheBuster() { |
|
| 330 | + $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 331 | + $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
| 332 | + $this->cacheFactory->create('theming')->clear('getScssVariables'); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Update setting in the database |
|
| 337 | + * |
|
| 338 | + * @param string $setting |
|
| 339 | + * @param string $value |
|
| 340 | + */ |
|
| 341 | + public function set($setting, $value) { |
|
| 342 | + $this->config->setAppValue('theming', $setting, $value); |
|
| 343 | + $this->increaseCacheBuster(); |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * Revert settings to the default value |
|
| 348 | + * |
|
| 349 | + * @param string $setting setting which should be reverted |
|
| 350 | + * @return string default value |
|
| 351 | + */ |
|
| 352 | + public function undo($setting) { |
|
| 353 | + $this->config->deleteAppValue('theming', $setting); |
|
| 354 | + $this->increaseCacheBuster(); |
|
| 355 | + |
|
| 356 | + switch ($setting) { |
|
| 357 | + case 'name': |
|
| 358 | + $returnValue = $this->getEntity(); |
|
| 359 | + break; |
|
| 360 | + case 'url': |
|
| 361 | + $returnValue = $this->getBaseUrl(); |
|
| 362 | + break; |
|
| 363 | + case 'slogan': |
|
| 364 | + $returnValue = $this->getSlogan(); |
|
| 365 | + break; |
|
| 366 | + case 'color': |
|
| 367 | + $returnValue = $this->getColorPrimary(); |
|
| 368 | + break; |
|
| 369 | + default: |
|
| 370 | + $returnValue = ''; |
|
| 371 | + break; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + return $returnValue; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * Color of text in the header and primary buttons |
|
| 379 | + * |
|
| 380 | + * @return string |
|
| 381 | + */ |
|
| 382 | + public function getTextColorPrimary() { |
|
| 383 | + return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#FFFFFF'; |
|
| 384 | + } |
|
| 385 | 385 | } |