forked from Public/pics
ErrorPage: display debug info in separate box
This commit is contained in:
@@ -44,6 +44,19 @@ class Dispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public static function errorPage($title, $body)
|
||||
{
|
||||
$page = new MainTemplate($title);
|
||||
$page->adopt(new ErrorPage($title, $body));
|
||||
|
||||
if (Registry::get('user')->isAdmin())
|
||||
{
|
||||
$page->appendStylesheet(BASEURL . '/css/admin.css');
|
||||
}
|
||||
|
||||
$page->html_main();
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks a guest to a login form, redirecting them back to this page upon login.
|
||||
*/
|
||||
@@ -60,37 +73,24 @@ class Dispatcher
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function trigger400()
|
||||
private static function trigger400()
|
||||
{
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
$page = new MainTemplate('Bad request');
|
||||
$page->adopt(new DummyBox('Bad request', '<p>The server does not understand your request.</p>'));
|
||||
$page->html_main();
|
||||
http_response_code(400);
|
||||
self::errorPage('Bad request', 'The server does not understand your request.');
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function trigger403()
|
||||
private static function trigger403()
|
||||
{
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
$page = new MainTemplate('Access denied');
|
||||
$page->adopt(new DummyBox('Forbidden', '<p>You do not have access to the page you requested.</p>'));
|
||||
$page->html_main();
|
||||
http_response_code(403);
|
||||
self::errorPage('Forbidden', 'You do not have access to this page.');
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function trigger404()
|
||||
private static function trigger404()
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
$page = new MainTemplate('Page not found');
|
||||
|
||||
if (Registry::has('user') && Registry::get('user')->isAdmin())
|
||||
{
|
||||
$page->appendStylesheet(BASEURL . '/css/admin.css');
|
||||
}
|
||||
|
||||
$page->adopt(new DummyBox('Well, this is a bit embarrassing!', '<p>The page you requested could not be found. Don\'t worry, it\'s probably not your fault. You\'re welcome to browse the website, though!</p>', 'errormsg'));
|
||||
$page->addClass('errorpage');
|
||||
$page->html_main();
|
||||
exit;
|
||||
http_response_code(404);
|
||||
$page = new ViewErrorPage('Page not found!');
|
||||
$page->showContent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user