diff options
-rw-r--r-- | apps/theming/lib/Service/ThemesService.php | 5 | ||||
-rw-r--r-- | core/templates/layout.public.php | 14 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 8 |
3 files changed, 20 insertions, 7 deletions
diff --git a/apps/theming/lib/Service/ThemesService.php b/apps/theming/lib/Service/ThemesService.php index 433555c980c..39a8eeff410 100644 --- a/apps/theming/lib/Service/ThemesService.php +++ b/apps/theming/lib/Service/ThemesService.php @@ -154,12 +154,15 @@ class ThemesService { * @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.public.php b/core/templates/layout.public.php index bd46ee4f7fc..c39ebf35f33 100644 --- a/core/templates/layout.public.php +++ b/core/templates/layout.public.php @@ -36,7 +36,9 @@ p($theme->getTitle()); <?php emit_script_loading_tags($_); ?> <?php print_unescaped($_['headers']); ?> </head> -<body id="<?php p($_['bodyid']);?>"> +<body id="<?php p($_['bodyid']);?>" <?php foreach ($_['enabledThemes'] as $themeId) { + p("data-theme-$themeId "); +}?> data-themes="<?php p(join(',', $_['enabledThemes'])) ?>"> <?php include('layout.noscript.warning.php'); ?> <?php include('layout.initial-state.php'); ?> <div id="skip-actions"> @@ -81,11 +83,11 @@ p($theme->getTitle()); <main id="content" class="app-<?php p($_['appid']) ?>"> <h1 class="hidden-visually"> <?php - if (isset($template) && $template->getHeaderTitle() !== '') { - p($template->getHeaderTitle()); - } else { - p($theme->getName()); - } ?> + if (isset($template) && $template->getHeaderTitle() !== '') { + p($template->getHeaderTitle()); + } else { + p($theme->getName()); + } ?> </h1> <?php print_unescaped($_['content']); ?> </main> diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 2bc9ff5a2af..e4978916ec3 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -158,6 +158,14 @@ class TemplateLayout extends \OC_Template { $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); |