aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/pagehandler.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-12-19 17:55:21 -0800
committerCash Costello <cash.costello@gmail.com>2011-12-19 17:55:21 -0800
commit742f7630b8f2628b977e59756ac2844d1bd4683b (patch)
tree8c1fde819ce841d0b4d57ce23d31bc34ca386916 /engine/lib/pagehandler.php
parent5ee43086ec79b38e3f2cdb288f80bd5f24d413b1 (diff)
parentf003120fba687d14630b690c50e2316f717eca7d (diff)
downloadelgg-742f7630b8f2628b977e59756ac2844d1bd4683b.tar.gz
elgg-742f7630b8f2628b977e59756ac2844d1bd4683b.tar.bz2
Merge pull request #118 from cash/404
Fixes #4103 adds a 404 page
Diffstat (limited to 'engine/lib/pagehandler.php')
-rw-r--r--engine/lib/pagehandler.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php
index aba921416..ffcfc5b6a 100644
--- a/engine/lib/pagehandler.php
+++ b/engine/lib/pagehandler.php
@@ -110,3 +110,36 @@ function elgg_unregister_page_handler($handler) {
unset($CONFIG->pagehandler[$handler]);
}
+
+/**
+ * Serve an error page
+ *
+ * @todo not sending status codes yet
+ *
+ * @param string $hook The name of the hook
+ * @param string $type The type of the hook
+ * @param bool $result The current value of the hook
+ * @param array $params Parameters related to the hook
+ */
+function elgg_error_page_handler($hook, $type, $result, $params) {
+ if (elgg_view_exists("errors/$type")) {
+ $content = elgg_view("errors/$type", $params);
+ } else {
+ $content = elgg_view("errors/default", $params);
+ }
+ $body = elgg_view_layout('error', array('content' => $content));
+ echo elgg_view_page($title, $body, 'error');
+ exit;
+}
+
+/**
+ * Initializes the page handler/routing system
+ *
+ * @return void
+ * @access private
+ */
+function page_handler_init() {
+ elgg_register_plugin_hook_handler('forward', '404', 'elgg_error_page_handler');
+}
+
+elgg_register_event_handler('init', 'system', 'page_handler_init');