diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index 90addefa9..17b173490 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -12,7 +12,7 @@ ?> getThemeName(); // keep $theme, $themes1, $themes2 vars for plugin backwards compatibility for the time being $themes1 = $themeHelper->isTopNavTheme(); $themes2 = $themeHelper->isSidebarTheme(); diff --git a/emhttp/plugins/dynamix/include/ThemeHelper.php b/emhttp/plugins/dynamix/include/ThemeHelper.php index ac38c2c2e..54e194012 100644 --- a/emhttp/plugins/dynamix/include/ThemeHelper.php +++ b/emhttp/plugins/dynamix/include/ThemeHelper.php @@ -31,19 +31,44 @@ class ThemeHelper { private bool $sidebarTheme; private bool $darkTheme; private bool $lightTheme; - private string $themeHtmlClass; private string $fgcolor; + private bool $unlimitedWidth = false; /** * Constructor for ThemeHelper * * @param string|null $theme The theme name (optional) + * @param '1'|null $width The width of the theme (optional) */ - public function __construct(?string $theme = null) { - if ($theme === null) { - throw new \RuntimeException(self::INIT_ERROR); + public function __construct(?string $theme = null, ?string $width = null) { + if ($theme !== null) { + $this->initWithCurrentThemeSetting($theme); } - $this->initWithCurrentThemeSetting($theme); + + if ($width !== null) { + $this->setWidth($width); + } + + throw new \RuntimeException(self::INIT_ERROR); + } + + /** + * Set the width setting + * + * @param string $width The width setting ('1' for unlimited, empty string for boxed) + * @return void + */ + public function setWidth(string $width): void { + $this->unlimitedWidth = ($width === '1'); + } + + /** + * Check if unlimited width is enabled + * + * @return bool + */ + public function isUnlimitedWidth(): bool { + return $this->unlimitedWidth; } /** @@ -60,11 +85,6 @@ class ThemeHelper { $this->darkTheme = in_array($this->themeName, self::DARK_THEMES); $this->lightTheme = in_array($this->themeName, self::LIGHT_THEMES); - $this->themeHtmlClass = "Theme--{$this->themeName}"; - if ($this->sidebarTheme) { - $this->themeHtmlClass .= " Theme--sidebar"; - } - $this->fgcolor = self::FGCOLORS[$this->themeName] ?? self::COLOR_BLACK; } @@ -88,8 +108,26 @@ class ThemeHelper { return $this->lightTheme; } + /** + * Get the theme HTML class string + * + * @return string + */ public function getThemeHtmlClass(): string { - return $this->themeHtmlClass; + + $classes = ["Theme--{$this->themeName}"]; + + if ($this->sidebarTheme) { + $classes[] = "Theme--sidebar"; + } + + if ($this->topNavTheme) { + $classes[] = "Theme--nav-top"; + } + + $classes[] = $this->unlimitedWidth ? "Theme--unlimited-width" : "Theme--boxed-width"; + + return implode(' ', $classes); } public function getFgColor(): string { diff --git a/emhttp/plugins/dynamix/styles/themes/README.md b/emhttp/plugins/dynamix/styles/themes/README.md index 18646dbca..f832cc690 100644 --- a/emhttp/plugins/dynamix/styles/themes/README.md +++ b/emhttp/plugins/dynamix/styles/themes/README.md @@ -114,7 +114,7 @@ Files like `UserList.css`, `ShareList.css` that provide reusable styles: ### Theme Classes - Main theme: `.Theme--{themename}` -- Layout variants: `.Theme--sidebar`, `.Theme--topnav` +- Layout variants: `.Theme--sidebar`, `.Theme--nav-top` ## Best Practices