Allow "?theme=(dark/light)" query parameter on public pages.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-07-13 00:57:24 -05:00
parent 23af29f953
commit b572b3dbc7
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
2 changed files with 11 additions and 5 deletions

View File

@ -23,6 +23,8 @@ class Customization
protected string $theme = self::DEFAULT_THEME;
protected string $publicTheme = self::DEFAULT_THEME;
protected string $instanceName = '';
public function __construct(
@ -41,9 +43,13 @@ class Customization
$queryParams = $request->getQueryParams();
if (!empty($queryParams['theme'])) {
$this->theme = $queryParams['theme'];
} elseif (null !== $this->user && !empty($this->user->getTheme())) {
$this->theme = (string)$this->user->getTheme();
$this->publicTheme = $this->theme = $queryParams['theme'];
} else {
$this->publicTheme = $this->settingsRepo->getSetting(Entity\Settings::PUBLIC_THEME, $this->publicTheme);
if (null !== $this->user && !empty($this->user->getTheme())) {
$this->theme = (string)$this->user->getTheme();
}
}
// Set up the PHP translator
@ -162,7 +168,7 @@ class Customization
*/
public function getPublicTheme(): string
{
return $this->settingsRepo->getSetting(Entity\Settings::PUBLIC_THEME, self::DEFAULT_THEME);
return $this->publicTheme;
}
/**

View File

@ -14,7 +14,7 @@
*/
$page_class ??= '';
$page_class .= ' theme-' . $customization->getTheme();
$page_class .= ' theme-' . $customization->getPublicTheme();
?>
<html>
<head>