From e802d5204b96d645ec3d40b81b4a8bdc6e0ee675 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 4 Nov 2019 23:31:31 +0100 Subject: refactor: switch to psr-4 autoloading --- app/class/controller.php | 100 ----------------------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 app/class/controller.php (limited to 'app/class/controller.php') diff --git a/app/class/controller.php b/app/class/controller.php deleted file mode 100644 index a5bd33b..0000000 --- a/app/class/controller.php +++ /dev/null @@ -1,100 +0,0 @@ -setuser(); - $this->router = $router; - $this->pagemanager = new Modelpage(); - $this->initplates(); - $this->now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); - } - - public function setuser() - { - $this->usermanager = new Modeluser; - $this->user = $this->usermanager->readsession(); - } - - public function initplates() - { - $router = $this->router; - $this->plates = new League\Plates\Engine(Model::TEMPLATES_DIR); - $this->plates->registerFunction('url', function (string $string, array $vars = []) use ($router) { - return $router->generate($string, $vars); - }); - $this->plates->registerFunction('upage', function (string $string, string $id) use ($router) { - return $router->generate($string, ['page' => $id]); - }); - } - - public function showtemplate($template, $params) - { - $params = array_merge($this->commonsparams(), $params); - echo $this->plates->render($template, $params); - } - - public function commonsparams() - { - $commonsparams = []; - $commonsparams['router'] = $this->router; - $commonsparams['user'] = $this->user; - $commonsparams['pagelist'] = $this->pagemanager->list(); - $commonsparams['css'] = Model::csspath(); - return $commonsparams; - } - - - - - - public function redirect($url) - { - header('Location: ' . $url); - } - - public function routedirect(string $route, array $vars = []) - { - $this->redirect($this->router->generate($route, $vars)); - } - - public function routedirectget(string $route, array $vars = []) - { - $get = '?'; - foreach ($vars as $key => $value) { - $get .= $key .'='. $value. '&'; - } - $get = rtrim($get, '&'); - $this->redirect($this->router->generate($route, []) . $get); - } - - public function error(int $code) - { - http_response_code($code); - exit; - } - -} - - - - - -?> \ No newline at end of file -- cgit v1.2.3