2015-04-22 12:23:57 +02:00
|
|
|
<?php namespace Todaymade\Daux\Server;
|
|
|
|
|
|
|
|
use Todaymade\Daux\SimplePage;
|
2015-04-22 18:24:10 +02:00
|
|
|
use Todaymade\Daux\Template;
|
2015-04-21 17:11:43 +02:00
|
|
|
|
|
|
|
class ErrorPage extends SimplePage
|
|
|
|
{
|
|
|
|
const NORMAL_ERROR_TYPE = 'NORMAL_ERROR';
|
|
|
|
const MISSING_PAGE_ERROR_TYPE = 'MISSING_PAGE_ERROR';
|
|
|
|
const FATAL_ERROR_TYPE = 'FATAL_ERROR';
|
|
|
|
|
|
|
|
private $params;
|
|
|
|
|
2015-04-23 00:32:30 +02:00
|
|
|
public function __construct($title, $content, $params)
|
|
|
|
{
|
2015-04-21 17:11:43 +02:00
|
|
|
parent::__construct($title, $content);
|
|
|
|
$this->params = $params;
|
|
|
|
}
|
|
|
|
|
2015-04-23 00:32:30 +02:00
|
|
|
public function display()
|
|
|
|
{
|
2015-04-22 18:24:10 +02:00
|
|
|
http_response_code(404);
|
2015-04-21 17:11:43 +02:00
|
|
|
parent::display();
|
|
|
|
}
|
|
|
|
|
2015-04-23 00:32:30 +02:00
|
|
|
public function getContent()
|
|
|
|
{
|
2015-04-21 17:11:43 +02:00
|
|
|
if (is_null($this->html)) {
|
2015-04-23 00:32:30 +02:00
|
|
|
$this->html = $this->generatePage();
|
2015-04-21 17:11:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->html;
|
|
|
|
}
|
|
|
|
|
2015-04-23 00:32:30 +02:00
|
|
|
private function generatePage()
|
|
|
|
{
|
2015-04-21 17:11:43 +02:00
|
|
|
$params = $this->params;
|
|
|
|
$page['title'] = $this->title;
|
|
|
|
$page['content'] = $this->content;
|
|
|
|
|
2015-04-23 10:24:50 +02:00
|
|
|
$template = new Template($params['templates'], $params['theme']['templates']);
|
|
|
|
return $template->render('error', ['page' => $page, 'params' => $params]);
|
2015-04-21 17:11:43 +02:00
|
|
|
}
|
|
|
|
}
|