diff --git a/apps/theming/lib/Service/ThemesService.php b/apps/theming/lib/Service/ThemesService.php index 8244e69e21911..d7127173848bb 100644 --- a/apps/theming/lib/Service/ThemesService.php +++ b/apps/theming/lib/Service/ThemesService.php @@ -170,12 +170,15 @@ public function isEnabled(ITheme $theme): bool { * @return string[] */ public function getEnabledThemes(): array { + $enforcedTheme = $this->config->getSystemValueString('enforce_theme', ''); $user = $this->userSession->getUser(); if ($user === null) { + if ($enforcedTheme !== '') { + return [$enforcedTheme]; + } return []; } - $enforcedTheme = $this->config->getSystemValueString('enforce_theme', ''); $enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '["default"]')); if ($enforcedTheme !== '') { return array_merge([$enforcedTheme], $enabledThemes); diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 5ebada9293403..363fe9dde2628 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -25,7 +25,9 @@ - + data-themes=""> $initialState) { ?> diff --git a/core/templates/layout.public.php b/core/templates/layout.public.php index 81b384987b8f8..8743554226961 100644 --- a/core/templates/layout.public.php +++ b/core/templates/layout.public.php @@ -26,11 +26,13 @@ - - - $initialState) { ?> - - + data-themes=""> + + $initialState) { ?> + +
t('Skip to main content')); ?> t('Skip to navigation of app')); ?> diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index cb2678acce41d..5d29b06a73b8f 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -183,6 +183,8 @@ public function __construct($renderAs, $appId = '') { if ($user) { $userDisplayName = $user->getDisplayName(); } + $theme = $this->config->getSystemValueString('enforce_theme', ''); + $this->assign('enabledThemes', $theme === '' ? [] : [$theme]); $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', \OC_User::getUser()); } elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) { @@ -190,6 +192,14 @@ public function __construct($renderAs, $appId = '') { $this->assign('appid', $appId); $this->assign('bodyid', 'body-public'); + // Set body data-theme + $this->assign('enabledThemes', []); + if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) { + /** @var \OCA\Theming\Service\ThemesService $themesService */ + $themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class); + $this->assign('enabledThemes', $themesService->getEnabledThemes()); + } + // Set logo link target $logoUrl = $this->config->getSystemValueString('logo_url', ''); $this->assign('logoUrl', $logoUrl);