Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/lib')
-rw-r--r--apps/theming/lib/Service/JSDataService.php1
-rw-r--r--apps/theming/lib/Settings/Admin.php2
-rw-r--r--apps/theming/lib/Themes/CommonThemeTrait.php1
-rw-r--r--apps/theming/lib/Themes/DefaultTheme.php11
-rw-r--r--apps/theming/lib/ThemingDefaults.php42
5 files changed, 44 insertions, 13 deletions
diff --git a/apps/theming/lib/Service/JSDataService.php b/apps/theming/lib/Service/JSDataService.php
index fdc85ea445a..26cda8c0012 100644
--- a/apps/theming/lib/Service/JSDataService.php
+++ b/apps/theming/lib/Service/JSDataService.php
@@ -55,6 +55,7 @@ class JSDataService implements \JsonSerializable {
'url' => $this->themingDefaults->getBaseUrl(),
'slogan' => $this->themingDefaults->getSlogan(),
'color' => $this->themingDefaults->getColorPrimary(),
+ 'defaultColor' => $this->themingDefaults->getDefaultColorPrimary(),
'imprintUrl' => $this->themingDefaults->getImprintUrl(),
'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
'inverted' => $this->util->invertTextColor($this->themingDefaults->getColorPrimary()),
diff --git a/apps/theming/lib/Settings/Admin.php b/apps/theming/lib/Settings/Admin.php
index 6caa174d99b..e89ea6b6fe9 100644
--- a/apps/theming/lib/Settings/Admin.php
+++ b/apps/theming/lib/Settings/Admin.php
@@ -75,7 +75,7 @@ class Admin implements IDelegatedSettings {
'name' => $this->themingDefaults->getEntity(),
'url' => $this->themingDefaults->getBaseUrl(),
'slogan' => $this->themingDefaults->getSlogan(),
- 'color' => $this->themingDefaults->getColorPrimary(),
+ 'color' => $this->themingDefaults->getDefaultColorPrimary(),
'uploadLogoRoute' => $this->urlGenerator->linkToRoute('theming.Theming.uploadImage'),
'canThemeIcons' => $this->imageManager->shouldReplaceIcons(),
'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'),
diff --git a/apps/theming/lib/Themes/CommonThemeTrait.php b/apps/theming/lib/Themes/CommonThemeTrait.php
index 631879ea832..d88a6a319fb 100644
--- a/apps/theming/lib/Themes/CommonThemeTrait.php
+++ b/apps/theming/lib/Themes/CommonThemeTrait.php
@@ -42,6 +42,7 @@ trait CommonThemeTrait {
// primary related colours
return [
'--color-primary' => $this->primaryColor,
+ '--color-primary-default' => $this->defaultPrimaryColor,
'--color-primary-text' => $this->util->invertTextColor($this->primaryColor) ? '#000000' : '#ffffff',
'--color-primary-hover' => $this->util->mix($this->primaryColor, $colorMainBackground, 60),
'--color-primary-light' => $colorPrimaryLight,
diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php
index e295d5d880a..4dce1dca809 100644
--- a/apps/theming/lib/Themes/DefaultTheme.php
+++ b/apps/theming/lib/Themes/DefaultTheme.php
@@ -48,6 +48,7 @@ class DefaultTheme implements ITheme {
public IConfig $config;
public IL10N $l;
+ public string $defaultPrimaryColor;
public string $primaryColor;
public function __construct(Util $util,
@@ -65,9 +66,13 @@ class DefaultTheme implements ITheme {
$this->config = $config;
$this->l = $l;
- $initialPrimaryColor = $this->themingDefaults->getColorPrimary();
- // Override default color if set to improve accessibility
- $this->primaryColor = $initialPrimaryColor === BackgroundService::DEFAULT_COLOR ? BackgroundService::DEFAULT_ACCESSIBLE_COLOR : $initialPrimaryColor;
+ $this->defaultPrimaryColor = $this->themingDefaults->getDefaultColorPrimary();
+ $this->primaryColor = $this->themingDefaults->getColorPrimary();
+
+ // Override default defaultPrimaryColor if set to improve accessibility
+ if ($this->primaryColor === BackgroundService::DEFAULT_COLOR) {
+ $this->primaryColor = BackgroundService::DEFAULT_ACCESSIBLE_COLOR;
+ }
}
public function getId(): string {
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index ae12530fb5c..9d5183a6504 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -214,26 +214,50 @@ class ThemingDefaults extends \OC_Defaults {
/**
* Color that is used for the header as well as for mail headers
- *
- * @return string
*/
- public function getColorPrimary() {
+ public function getColorPrimary(): string {
$user = $this->userSession->getUser();
- $color = $this->config->getAppValue(Application::APP_ID, 'color', '');
- if ($color === '' && !empty($user)) {
- $themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', 'default');
- if ($themingBackground === 'default') {
+ // admin-defined primary color
+ $defaultColor = $this->getDefaultColorPrimary();
+
+ // user-defined primary color
+ $themingBackground = '';
+ if (!empty($user)) {
+ $themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', '');
+ // If the user selected the default background
+ if ($themingBackground === '') {
return BackgroundService::DEFAULT_COLOR;
- } else if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
+ }
+
+ // If the user selected a specific colour
+ if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
+ return $themingBackground;
+ }
+
+ // if the user-selected background is a background reference
+ if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
}
}
- if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
+ // If the default color is not valid, return the default background one
+ if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
return BackgroundService::DEFAULT_COLOR;
}
+ // Finally, return the system global primary color
+ return $defaultColor;
+ }
+
+ /**
+ * Return the default color primary
+ */
+ public function getDefaultColorPrimary(): string {
+ $color = $this->config->getAppValue(Application::APP_ID, 'color');
+ if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
+ $color = '#0082c9';
+ }
return $color;
}