diff options
Diffstat (limited to 'engine')
-rw-r--r-- | engine/RequestDispatcher.php | 7 | ||||
-rw-r--r-- | engine/Skin.php | 5 | ||||
-rw-r--r-- | engine/SkinContext.php | 8 |
3 files changed, 15 insertions, 5 deletions
diff --git a/engine/RequestDispatcher.php b/engine/RequestDispatcher.php index 38b965d..3c3f684 100644 --- a/engine/RequestDispatcher.php +++ b/engine/RequestDispatcher.php @@ -39,11 +39,14 @@ class RequestDispatcher { } $skin = new Skin(); - $skin->static[] = '/css/common-bundle.css'; + $skin->static[] = '/css/common.css'; $skin->static[] = '/js/common.js'; + $lang = LangData::getInstance(); + $skin->addLangKeys($lang->search('/^theme_/')); + /** @var RequestHandler $handler */ - $handler = new $handler_class($skin, LangData::getInstance(), $router_input); + $handler = new $handler_class($skin, $lang, $router_input); $resp = $handler->beforeDispatch(); if ($resp instanceof Response) { $resp->send(); diff --git a/engine/Skin.php b/engine/Skin.php index 57f8b90..917eef7 100644 --- a/engine/Skin.php +++ b/engine/Skin.php @@ -23,11 +23,16 @@ class Skin { else $js = null; + $theme = ($_COOKIE['theme'] ?? 'auto'); + if (!in_array($theme, ['auto', 'dark', 'light'])) + $theme = 'auto'; + $layout_ctx = new SkinContext('\\skin\\base'); $lang = $this->getLang(); $lang = !empty($lang) ? json_encode($lang, JSON_UNESCAPED_UNICODE) : ''; return new Response(200, $layout_ctx->layout( static: $this->static, + theme: $theme, title: $this->title, opts: $this->options, js: $js, diff --git a/engine/SkinContext.php b/engine/SkinContext.php index cfb5068..c395453 100644 --- a/engine/SkinContext.php +++ b/engine/SkinContext.php @@ -53,10 +53,12 @@ class SkinContext extends SkinBase { return call_user_func_array($fn, $arguments); } - public function __get(string $name) { + public function &__get(string $name) { $fn = $this->ns.'\\'.$name; - if (function_exists($fn)) - return [$this, $name]; + if (function_exists($fn)) { + $f = [$this, $name]; + return $f; + } if (array_key_exists($name, $this->data)) return $this->data[$name]; |