Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/theming/lib/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,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);
Expand Down
14 changes: 8 additions & 6 deletions core/templates/layout.public.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
<?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">
Expand Down Expand Up @@ -81,11 +83,11 @@
<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>
Expand Down
8 changes: 8 additions & 0 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,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);
Expand Down
Loading