aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/pagehandler.php33
-rw-r--r--languages/en.php3
-rw-r--r--views/default/css/elements/layout.php3
-rw-r--r--views/default/errors/404.php8
-rw-r--r--views/default/errors/default.php8
-rw-r--r--views/default/page/error.php14
-rw-r--r--views/default/page/layouts/error.php12
7 files changed, 81 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');
diff --git a/languages/en.php b/languages/en.php
index a2e6e152e..93099c98f 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -240,6 +240,9 @@ $english = array(
'changebookmark' => 'Please change your bookmark for this page',
'noaccess' => 'This content has been removed, is invalid, or you do not have permission to view it.',
+ 'error:default' => 'Oops...something went wrong.',
+ 'error:404' => 'Sorry. We could not find the page that you requested.',
+
/**
* API
*/
diff --git a/views/default/css/elements/layout.php b/views/default/css/elements/layout.php
index 42d898439..25a2bffb7 100644
--- a/views/default/css/elements/layout.php
+++ b/views/default/css/elements/layout.php
@@ -81,6 +81,9 @@
.elgg-layout-two-sidebar {
background: transparent url(<?php echo elgg_get_site_url(); ?>_graphics/two_sidebar_background.gif) repeat-y right top;
}
+.elgg-layout-error {
+ margin-top: 20px;
+}
.elgg-sidebar {
position: relative;
padding: 20px 10px;
diff --git a/views/default/errors/404.php b/views/default/errors/404.php
new file mode 100644
index 000000000..8bc35acdd
--- /dev/null
+++ b/views/default/errors/404.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Page not found error
+ */
+
+$message = elgg_echo('error:404');
+
+echo "<h2>$message</h2>";
diff --git a/views/default/errors/default.php b/views/default/errors/default.php
new file mode 100644
index 000000000..a0582eba2
--- /dev/null
+++ b/views/default/errors/default.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * General error
+ */
+
+$message = elgg_echo('error:default');
+
+echo "<h2>$message</h2>";
diff --git a/views/default/page/error.php b/views/default/page/error.php
new file mode 100644
index 000000000..b7ba3ae9b
--- /dev/null
+++ b/views/default/page/error.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Page shell for errors
+ *
+ * This is for errors that are not unhandled exceptions. Those are handled
+ * through the failsafe viewtype to guarantee that no further exceptions occur.
+ * An example error would be 404 (page not found).
+ *
+ * @uses $vars['title'] The page title
+ * @uses $vars['body'] The main content of the page
+ * @uses $vars['sysmessages'] A 2d array of various message registers, passed from system_messages()
+ */
+
+echo elgg_view('page/default', $vars);
diff --git a/views/default/page/layouts/error.php b/views/default/page/layouts/error.php
new file mode 100644
index 000000000..cdce28a8e
--- /dev/null
+++ b/views/default/page/layouts/error.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Error layout
+ */
+
+$class = 'elgg-layout-error';
+if (isset($vars['class'])) {
+ $class = "$class {$vars['class']}";
+}
+$vars['class'] = $class;
+
+echo elgg_view('page/layouts/one_column', $vars);