diff --git a/src/Pluf/Dispatcher.php b/src/Pluf/Dispatcher.php index b62ff61..4410a7d 100644 --- a/src/Pluf/Dispatcher.php +++ b/src/Pluf/Dispatcher.php @@ -116,7 +116,7 @@ class Pluf_Dispatcher } } } - return new Pluf_HTTP_Response_NotFound(sprintf(__('The page %s was not found on the server.'), htmlspecialchars($req->query))); + return new Pluf_HTTP_Response_NotFound($req); } /** diff --git a/src/Pluf/HTTP/Response/NotFound.php b/src/Pluf/HTTP/Response/NotFound.php index 92bef8c..e3cfd34 100644 --- a/src/Pluf/HTTP/Response/NotFound.php +++ b/src/Pluf/HTTP/Response/NotFound.php @@ -23,8 +23,20 @@ class Pluf_HTTP_Response_NotFound extends Pluf_HTTP_Response { - function __construct($content, $mimetype=null) + function __construct($request) { + $content = ''; + try { + $context = new Pluf_Template_Context(array('query' => $request->query)); + $tmpl = new Pluf_Template('404.html'); + $content = $tmpl->render($context); + $mimetype = null; + } catch (Exception $e) { + $mimetype = 'text/plain'; + $content = sprintf('The requested URL %s was not found on this server.'."\n" + .'Please check the URL and try again.'."\n\n".'404 - Not Found', + Pluf_esc($request->query)); + } parent::__construct($content, $mimetype); $this->status_code = 404; }