diff --git a/apps/theming/lib/Capabilities.php b/apps/theming/lib/Capabilities.php index b43779a27b..1b6bb8927b 100644 --- a/apps/theming/lib/Capabilities.php +++ b/apps/theming/lib/Capabilities.php @@ -75,7 +75,7 @@ class Capabilities implements IPublicCapability { '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' ? diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index eb1051b13c..fa43dd50cc 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -256,13 +256,8 @@ class ThemingDefaults extends \OC_Defaults { $variables['image-login-plain'] = 'false'; if ($this->config->getAppValue('theming', 'color', null) !== null) { - if ($this->util->invertTextColor($this->getColorPrimary())) { - $colorPrimaryText = '#000000'; - } else { - $colorPrimaryText = '#ffffff'; - } $variables['color-primary'] = $this->getColorPrimary(); - $variables['color-primary-text'] = $colorPrimaryText; + $variables['color-primary-text'] = $this->getTextColorPrimary(); $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary()); } @@ -378,4 +373,13 @@ class ThemingDefaults extends \OC_Defaults { return $returnValue; } + + /** + * Color of text in the header and primary buttons + * + * @return string + */ + public function getTextColorPrimary() { + return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff'; + } } diff --git a/apps/theming/tests/CapabilitiesTest.php b/apps/theming/tests/CapabilitiesTest.php index 17fc253fa4..c760c89642 100644 --- a/apps/theming/tests/CapabilitiesTest.php +++ b/apps/theming/tests/CapabilitiesTest.php @@ -65,7 +65,7 @@ class CapabilitiesTest extends TestCase { public function dataGetCapabilities() { return [ - ['name', 'url', 'slogan', '#FFFFFF', 'logo', 'background', 'http://absolute/', [ + ['name', 'url', 'slogan', '#FFFFFF', '#000000', 'logo', 'background', 'http://absolute/', [ 'name' => 'name', 'url' => 'url', 'slogan' => 'slogan', @@ -75,22 +75,22 @@ class CapabilitiesTest extends TestCase { 'logo' => 'http://absolute/logo', 'background' => 'http://absolute/background', ]], - ['name1', 'url2', 'slogan3', '#01e4a0', 'logo5', 'background6', 'http://localhost/', [ + ['name1', 'url2', 'slogan3', '#01e4a0', '#ffffff', 'logo5', 'background6', 'http://localhost/', [ 'name' => 'name1', 'url' => 'url2', 'slogan' => 'slogan3', 'color' => '#01e4a0', - 'color-text' => '#FFFFFF', + 'color-text' => '#ffffff', 'color-element' => '#01e4a0', 'logo' => 'http://localhost/logo5', 'background' => 'http://localhost/background6', ]], - ['name1', 'url2', 'slogan3', '#000000', 'logo5', 'backgroundColor', 'http://localhost/', [ + ['name1', 'url2', 'slogan3', '#000000', '#ffffff', 'logo5', 'backgroundColor', 'http://localhost/', [ 'name' => 'name1', 'url' => 'url2', 'slogan' => 'slogan3', 'color' => '#000000', - 'color-text' => '#FFFFFF', + 'color-text' => '#ffffff', 'color-element' => '#000000', 'logo' => 'http://localhost/logo5', 'background' => '#000000', @@ -105,11 +105,12 @@ class CapabilitiesTest extends TestCase { * @param string $slogan * @param string $color * @param string $logo + * @param string $textColor * @param string $background * @param string $baseUrl * @param string[] $expected */ - public function testGetCapabilities($name, $url, $slogan, $color, $logo, $background, $baseUrl, array $expected) { + public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $logo, $background, $baseUrl, array $expected) { $this->config->expects($this->once()) ->method('getAppValue') ->willReturn($background); @@ -128,6 +129,9 @@ class CapabilitiesTest extends TestCase { $this->theming->expects($this->once()) ->method('getLogo') ->willReturn($logo); + $this->theming->expects($this->once()) + ->method('getTextColorPrimary') + ->willReturn($textColor); if($background !== 'backgroundColor') { $this->theming->expects($this->once()) diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index 1d905635d5..0535dabc13 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -234,7 +234,7 @@ EOF;
- %s + %s
@@ -287,7 +287,7 @@ EOF;
- %s + %s
@@ -531,8 +531,9 @@ EOF; $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; @@ -561,7 +562,8 @@ EOF; } $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 . ': '; diff --git a/lib/private/legacy/defaults.php b/lib/private/legacy/defaults.php index 8b5cef3643..494c65ef22 100644 --- a/lib/private/legacy/defaults.php +++ b/lib/private/legacy/defaults.php @@ -50,6 +50,7 @@ class OC_Defaults { private $defaultDocVersion; private $defaultSlogan; private $defaultColorPrimary; + private $defaultTextColorPrimary; public function __construct() { $this->l = \OC::$server->getL10N('lib'); @@ -66,6 +67,7 @@ class OC_Defaults { $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)) { @@ -318,4 +320,11 @@ class OC_Defaults { } return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion())); } + + public function getTextColorPrimary() { + if ($this->themeExist('getTextColorPrimary')) { + return $this->theme->getTextColorPrimary(); + } + return $this->defaultTextColorPrimary; + } } diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php index 4bf638fda9..bf790bb723 100644 --- a/lib/public/Defaults.php +++ b/lib/public/Defaults.php @@ -213,4 +213,13 @@ class Defaults { public function getTitle() { return $this->defaults->getTitle(); } + + /** + * Returns primary color + * @return string + * @since 13.0.0 + */ + public function getTextColorPrimary() { + return $this->defaults->getTextColorPrimary(); + } } diff --git a/tests/Settings/Mailer/NewUserMailHelperTest.php b/tests/Settings/Mailer/NewUserMailHelperTest.php index f05a963e53..84553cc900 100644 --- a/tests/Settings/Mailer/NewUserMailHelperTest.php +++ b/tests/Settings/Mailer/NewUserMailHelperTest.php @@ -157,6 +157,10 @@ class NewUserMailHelperTest extends TestCase { ->expects($this->any()) ->method('getName') ->willReturn('TestCloud'); + $this->defaults + ->expects($this->any()) + ->method('getTextColorPrimary') + ->willReturn('#ffffff'); $expectedHtmlBody = << @@ -281,7 +285,7 @@ class NewUserMailHelperTest extends TestCase {
- Set your password + Set your password
@@ -390,6 +394,10 @@ EOF; ->expects($this->any()) ->method('getName') ->willReturn('TestCloud'); + $this->defaults + ->expects($this->any()) + ->method('getTextColorPrimary') + ->willReturn('#ffffff'); $expectedHtmlBody = << @@ -514,7 +522,7 @@ EOF;
- Go to TestCloud + Go to TestCloud
diff --git a/tests/data/emails/new-account-email-custom.html b/tests/data/emails/new-account-email-custom.html index 9d35a7f351..601aa0b63d 100644 --- a/tests/data/emails/new-account-email-custom.html +++ b/tests/data/emails/new-account-email-custom.html @@ -120,7 +120,7 @@
- Set your password + Set your password
diff --git a/tests/data/emails/new-account-email-single-button.html b/tests/data/emails/new-account-email-single-button.html index 3746d5d2cb..db8ab86868 100644 --- a/tests/data/emails/new-account-email-single-button.html +++ b/tests/data/emails/new-account-email-single-button.html @@ -120,7 +120,7 @@
- Set your password + Set your password
diff --git a/tests/data/emails/new-account-email.html b/tests/data/emails/new-account-email.html index d33cb540c3..f7ffbb8abf 100644 --- a/tests/data/emails/new-account-email.html +++ b/tests/data/emails/new-account-email.html @@ -120,7 +120,7 @@
- Set your password + Set your password
diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php index 339cd95def..d4687c44b0 100644 --- a/tests/lib/Mail/EMailTemplateTest.php +++ b/tests/lib/Mail/EMailTemplateTest.php @@ -68,6 +68,10 @@ class EMailTemplateTest extends TestCase { ->expects($this->any()) ->method('getName') ->willReturn('TestCloud'); + $this->defaults + ->expects($this->any()) + ->method('getTextColorPrimary') + ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) ->method('getAbsoluteURL') @@ -109,6 +113,10 @@ class EMailTemplateTest extends TestCase { ->expects($this->any()) ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); + $this->defaults + ->expects($this->any()) + ->method('getTextColorPrimary') + ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) ->method('getAbsoluteURL') @@ -148,6 +156,10 @@ class EMailTemplateTest extends TestCase { ->expects($this->any()) ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); + $this->defaults + ->expects($this->any()) + ->method('getTextColorPrimary') + ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) ->method('getAbsoluteURL') @@ -189,6 +201,10 @@ class EMailTemplateTest extends TestCase { ->expects($this->any()) ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); + $this->defaults + ->expects($this->any()) + ->method('getTextColorPrimary') + ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) ->method('getAbsoluteURL')