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; global $messages; $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); $this->prepare("messages", $messages->messageList()); echo $this->twig->render($template, $this->data); die(); } public function simple($title, $content) { $this->prepare("title", $title); $this->prepare("content", $content); $this->render("simplepage.twig"); } }