Skip to content

Commit

Permalink
Fix email buttons for white theme
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Dec 8, 2017
1 parent ef2b096 commit b2c197f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/theming/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getCapabilities() {
'url' => $this->theming->getBaseUrl(),
'slogan' => $this->theming->getSlogan(),
'color' => $color,
'color-text' => $this->util->invertTextColor($color) ? '#000000' : '#FFFFFF',
'color-text' => $this->theming->getTextColorPrimary(),
'color-element' => $this->util->elementColor($color),
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
'background' => $backgroundLogo === 'backgroundColor' ?
Expand Down
9 changes: 9 additions & 0 deletions apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,13 @@ public function undo($setting) {

return $returnValue;
}

/**
* Color of text in the header and primary buttons
*
* @return string
*/
public function getTextColorPrimary() {
return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#FFFFFF';
}
}
10 changes: 6 additions & 4 deletions lib/private/Mail/EMailTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class EMailTemplate implements IEMailTemplate {
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
<tr style="padding:0;text-align:left;vertical-align:top">
<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">
<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>
<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>
</td>
</tr>
</table>
Expand Down Expand Up @@ -287,7 +287,7 @@ class EMailTemplate implements IEMailTemplate {
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
<tr style="padding:0;text-align:left;vertical-align:top">
<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">
<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>
<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>
</td>
</tr>
</table>
Expand Down Expand Up @@ -531,8 +531,9 @@ public function addBodyButtonGroup($textLeft,
$this->ensureBodyListClosed();

$color = $this->themingDefaults->getColorPrimary();
$textColor = $this->themingDefaults->getTextColorPrimary();

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

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

$color = $this->themingDefaults->getColorPrimary();
$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]);
$textColor = $this->themingDefaults->getTextColorPrimary();
$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, htmlspecialchars($text)]);

if ($plainText !== false) {
$this->plainBody .= $plainText . ': ';
Expand Down
9 changes: 9 additions & 0 deletions lib/private/legacy/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OC_Defaults {
private $defaultDocVersion;
private $defaultSlogan;
private $defaultColorPrimary;
private $defaultTextColorPrimary;

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

$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
if (file_exists($themePath)) {
Expand Down Expand Up @@ -318,4 +320,11 @@ public function getLogo($useSvg = true) {
}
return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
}

public function getTextColorPrimary() {
if ($this->themeExist('getTextColorPrimary')) {
return $this->theme->getTextColorPrimary();
}
return $this->defaultTextColorPrimary;
}
}
9 changes: 9 additions & 0 deletions lib/public/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,13 @@ public function buildDocLinkToKey($key) {
public function getTitle() {
return $this->defaults->getTitle();
}

/**
* Returns primary color
* @return string
* @since 13.0.0
*/
public function getTextColorPrimary() {
return $this->defaults->getTextColorPrimary();
}
}

0 comments on commit b2c197f

Please sign in to comment.