daux.io/libs/Server/ErrorPage.php

51 lines
1.2 KiB
PHP
Raw Normal View History

2015-04-22 12:23:57 +02:00
<?php namespace Todaymade\Daux\Server;
use Todaymade\Daux\SimplePage;
use Todaymade\Daux\Template;
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;
private static $template;
2015-04-23 00:32:30 +02:00
public function __construct($title, $content, $params)
{
parent::__construct($title, $content);
$this->params = $params;
}
2015-04-23 00:32:30 +02:00
public function display()
{
http_response_code(404);
parent::display();
}
2015-04-23 00:32:30 +02:00
public function getContent()
{
include_once($this->params['theme']['error-template']);
static::$template = new Template();
if (is_null($this->html)) {
2015-04-23 00:32:30 +02:00
$this->html = $this->generatePage();
}
return $this->html;
}
2015-04-23 00:32:30 +02:00
private function generatePage()
{
$params = $this->params;
$page['title'] = $this->title;
$page['theme'] = $params['theme'];
$page['content'] = $this->content;
$page['google_analytics'] = $params['google_analytics'];
$page['piwik_analytics'] = $params['piwik_analytics'];
return static::$template->get_content($page, $params);
}
}