summaryrefslogtreecommitdiff
path: root/localwebsite/handlers/RequestHandler.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-05-21 01:45:56 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-05-21 01:45:56 +0300
commit6f53e6e997c9f4647a667bd58b11bc622fa3b47f (patch)
tree226bd65a04576de4f41bf8396af97cd43ca27829 /localwebsite/handlers/RequestHandler.php
parent902a3bfbe2c4645e6725fb7583500d1a28026fad (diff)
move local website to homekit's tree
Diffstat (limited to 'localwebsite/handlers/RequestHandler.php')
-rw-r--r--localwebsite/handlers/RequestHandler.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/localwebsite/handlers/RequestHandler.php b/localwebsite/handlers/RequestHandler.php
new file mode 100644
index 0000000..2fffdc0
--- /dev/null
+++ b/localwebsite/handlers/RequestHandler.php
@@ -0,0 +1,41 @@
+<?php
+
+class RequestHandler extends request_handler {
+
+ /** @var web_tpl*/
+ protected $tpl;
+
+ public function __construct() {
+ global $__tpl;
+ $__tpl = new web_tpl();
+ $this->tpl = $__tpl;
+
+ $this->tpl->add_static('bootstrap.min.css');
+ $this->tpl->add_static('bootstrap.min.js');
+ $this->tpl->add_static('polyfills.js');
+ $this->tpl->add_static('app.js');
+ $this->tpl->add_static('app.css');
+ }
+
+ public function dispatch(string $act) {
+ global $config;
+ $this->tpl->set_global([
+ '__dev' => $config['is_dev'],
+ ]);
+ return parent::dispatch($act);
+ }
+
+ protected function method_not_found(string $method, string $act)
+ {
+ global $config;
+
+ if ($act != '404' && $config['is_dev'])
+ debugError(get_called_class() . ": act {$method}_{$act} not found.");
+
+ if (!is_xhr_request())
+ $this->tpl->render_not_found();
+ else
+ ajax_error('unknown act "'.$act.'"', 404);
+
+ }
+} \ No newline at end of file