Skip to content

Commit b2c197f

Browse files
committed
Fix email buttons for white theme
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
1 parent ef2b096 commit b2c197f

5 files changed

Lines changed: 34 additions & 5 deletions

File tree

apps/theming/lib/Capabilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getCapabilities() {
7575
'url' => $this->theming->getBaseUrl(),
7676
'slogan' => $this->theming->getSlogan(),
7777
'color' => $color,
78-
'color-text' => $this->util->invertTextColor($color) ? '#000000' : '#FFFFFF',
78+
'color-text' => $this->theming->getTextColorPrimary(),
7979
'color-element' => $this->util->elementColor($color),
8080
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
8181
'background' => $backgroundLogo === 'backgroundColor' ?

apps/theming/lib/ThemingDefaults.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,13 @@ public function undo($setting) {
378378

379379
return $returnValue;
380380
}
381+
382+
/**
383+
* Color of text in the header and primary buttons
384+
*
385+
* @return string
386+
*/
387+
public function getTextColorPrimary() {
388+
return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#FFFFFF';
389+
}
381390
}

lib/private/Mail/EMailTemplate.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class EMailTemplate implements IEMailTemplate {
234234
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
235235
<tr style="padding:0;text-align:left;vertical-align:top">
236236
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:%s;border:0 solid %s;border-collapse:collapse!important;color:#fefefe;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">
237-
<a href="%s" style="Margin:0;border:0 solid %s;border-radius:2px;color:#fefefe;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">%s</a>
237+
<a href="%s" style="Margin:0;border:0 solid %s;border-radius:2px;color:%s;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;outline:1px solid %s;text-decoration:none">%s</a>
238238
</td>
239239
</tr>
240240
</table>
@@ -287,7 +287,7 @@ class EMailTemplate implements IEMailTemplate {
287287
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
288288
<tr style="padding:0;text-align:left;vertical-align:top">
289289
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:%s;border:0 solid %s;border-collapse:collapse!important;color:#fefefe;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">
290-
<a href="%s" style="Margin:0;border:0 solid %s;border-radius:2px;color:#fefefe;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">%s</a>
290+
<a href="%s" style="Margin:0;border:0 solid %s;border-radius:2px;color:%s;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;outline:1px solid %s;text-decoration:none">%s</a>
291291
</td>
292292
</tr>
293293
</table>
@@ -531,8 +531,9 @@ public function addBodyButtonGroup($textLeft,
531531
$this->ensureBodyListClosed();
532532

533533
$color = $this->themingDefaults->getColorPrimary();
534+
$textColor = $this->themingDefaults->getTextColorPrimary();
534535

535-
$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]);
536+
$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]);
536537
$this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
537538
$this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
538539

@@ -561,7 +562,8 @@ public function addBodyButton($text, $url, $plainText = '') {
561562
}
562563

563564
$color = $this->themingDefaults->getColorPrimary();
564-
$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]);
565+
$textColor = $this->themingDefaults->getTextColorPrimary();
566+
$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, htmlspecialchars($text)]);
565567

566568
if ($plainText !== false) {
567569
$this->plainBody .= $plainText . ': ';

lib/private/legacy/defaults.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class OC_Defaults {
5050
private $defaultDocVersion;
5151
private $defaultSlogan;
5252
private $defaultColorPrimary;
53+
private $defaultTextColorPrimary;
5354

5455
public function __construct() {
5556
$this->l = \OC::$server->getL10N('lib');
@@ -66,6 +67,7 @@ public function __construct() {
6667
$this->defaultDocVersion = '12'; // used to generate doc links
6768
$this->defaultSlogan = $this->l->t('a safe home for all your data');
6869
$this->defaultColorPrimary = '#0082c9';
70+
$this->defaultTextColorPrimary = '#ffffff';
6971

7072
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
7173
if (file_exists($themePath)) {
@@ -318,4 +320,11 @@ public function getLogo($useSvg = true) {
318320
}
319321
return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
320322
}
323+
324+
public function getTextColorPrimary() {
325+
if ($this->themeExist('getTextColorPrimary')) {
326+
return $this->theme->getTextColorPrimary();
327+
}
328+
return $this->defaultTextColorPrimary;
329+
}
321330
}

lib/public/Defaults.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,13 @@ public function buildDocLinkToKey($key) {
213213
public function getTitle() {
214214
return $this->defaults->getTitle();
215215
}
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+
}
216225
}

0 commit comments

Comments
 (0)