twig = new \Twig\Environment($loader); } public function prepare($key, $value) { $this->data[$key] = $value; } public function display($template) { global $router; try { $this->render("{$router->namespace}/{$template}.twig"); } catch (\Twig\Error\LoaderError $e) { $this->error(500); } } public function error($errorCode) { $errorTemplate = PATH_ROOT . "/theme/default/error/{$errorCode}.twig"; if (file_exists($errorTemplate)) { echo $this->render("error/{$errorCode}.twig"); } else { echo $this->render("error/generic.twig"); } } private function render($template) { global $controlrow; global $numqueries; global $starttime; $this->prepare("STYLE_FOLDER", '/theme/default/'); $this->prepare("dkgamename", $controlrow["gamename"]); $this->prepare("totaltime", round(getmicrotime() - $starttime, 4)); $this->prepare("numqueries", $numqueries); $this->prepare("version", DRAGONFORK_VERSION); $this->prepare("build", DRAGONFORK_BUILD); echo $this->twig->render($template, $this->data); die(); } public function redirect($redirection) { header("Location: " . $redirection); die(); } }