summaryrefslogtreecommitdiff
path: root/engine/Skin.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-01-31 06:11:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-01-31 20:45:40 +0300
commitc0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch)
tree2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /engine/Skin.php
parent48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff)
make it simple, but not simpler
Diffstat (limited to 'engine/Skin.php')
-rw-r--r--engine/Skin.php63
1 files changed, 0 insertions, 63 deletions
diff --git a/engine/Skin.php b/engine/Skin.php
deleted file mode 100644
index b1523e6..0000000
--- a/engine/Skin.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-class Skin {
-
- public string $title = 'title';
- public array $static = [];
- public array $meta = [];
-
- protected array $langKeys = [];
- protected array $options = [
- 'full_width' => false,
- 'wide' => false,
- 'dynlogo_enabled' => true,
- 'logo_path_map' => [],
- 'logo_link_map' => [],
- ];
-
- public function renderPage($f, ...$vars): Response {
- $f = '\\skin\\'.str_replace('/', '\\', $f);
- $ctx = new SkinContext(substr($f, 0, ($pos = strrpos($f, '\\'))));
- $body = call_user_func_array([$ctx, substr($f, $pos+1)], $vars);
- if (is_array($body))
- list($body, $js) = $body;
- else
- $js = null;
-
- $theme = themes::getUserTheme();
- if ($theme != 'auto' && !themes::themeExists($theme))
- $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,
- meta: $this->meta,
- unsafe_lang: $lang,
- unsafe_body: $body,
- exec_time: exectime()
- ));
- }
-
- public function addLangKeys(array $keys): void {
- $this->langKeys = array_merge($this->langKeys, $keys);
- }
-
- protected function getLang(): array {
- $lang = [];
- $ld = LangData::getInstance();
- foreach ($this->langKeys as $key)
- $lang[$key] = $ld[$key];
- return $lang;
- }
-
- public function setOptions(array $options): void {
- $this->options = array_merge($this->options, $options);
- }
-
-}