Elgg  Version 3.0
error.php
Go to the documentation of this file.
1 <?php
2 
3 $type = elgg_extract('type', $vars);
4 $params = elgg_extract('params', $vars, []);
5 
6 $title = elgg_echo('error:default:title');
7 
8 if (elgg_view_exists("errors/$type")) {
9  if (elgg_language_key_exists("error:$type:title")) {
10  // use custom error title is available
11  $title = elgg_echo("error:$type:title");
12  }
13 
14  $content = elgg_view("errors/$type", $params);
15 } else {
16  $content = elgg_view("errors/default", $params);
17 }
18 
20  '400' => 'Bad Request',
21  '401' => 'Unauthorized',
22  '403' => 'Forbidden',
23  '404' => 'Not Found',
24  '407' => 'Proxy Authentication Required',
25  '500' => 'Internal Server Error',
26  '503' => 'Service Unavailable',
27 ];
28 
29 if (isset($httpCodes[$type])) {
30  elgg_set_http_header("HTTP/1.1 $type {$httpCodes[$type]}");
31 }
32 
33 $layout = elgg_in_context('admin') && elgg_is_admin_logged_in() ? 'admin' : 'error';
34 
36  'title' => $title,
37  'content' => $content,
38 ]);
39 
41 if (!elgg_is_logged_in() && elgg_get_config('walled_garden')) {
42  $shell = 'walled_garden';
43 }
44 
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:96
$title
Definition: error.php:6
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:205
$httpCodes
Definition: error.php:19
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:48
$layout
Definition: error.php:24
elgg_set_http_header($header, $replace=true)
Set a response HTTP header.
Definition: elgglib.php:57
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:57
$shell
Definition: error.php:40
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$type
Definition: error.php:3
elgg_view_page($title, $body, $page_shell= 'default', $vars=[])
Assembles and outputs a full page.
Definition: views.php:360
$body
Definition: error.php:22
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:238
elgg echo
Translates a string.
Definition: languages.js:43
$params
Definition: error.php:4
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
elgg_view_layout($layout_name, $vars=[])
Displays a layout with optional parameters.
Definition: views.php:593
$vars['breadcrumbs']
Definition: error.php:18
$content
Set robots.txt action.
Definition: set_robots.php:6
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
elgg_get_config($name, $default=null)
Get an Elgg configuration value.