Elgg  Version 6.0
error.php
Go to the documentation of this file.
1 <?php
15 $exception = elgg_extract('exception', $vars);
16 
17 $params = elgg_extract('params', $vars, []);
18 $params['exception'] = elgg_extract('exception', $params, $exception);
19 
20 $title = elgg_echo('error:default:title');
21 if (elgg_language_key_exists("error:{$type}:title")) {
22  // use custom error title is available
23  $title = elgg_echo("error:{$type}:title");
24 }
25 
26 if (elgg_view_exists("errors/{$type}")) {
27  $content = elgg_view("errors/{$type}", $params);
28 } else {
29  $content = elgg_view('errors/default', $params);
30 }
31 
33  '400' => 'Bad Request',
34  '401' => 'Unauthorized',
35  '403' => 'Forbidden',
36  '404' => 'Not Found',
37  '407' => 'Proxy Authentication Required',
38  '500' => 'Internal Server Error',
39  '503' => 'Service Unavailable',
40 ];
41 
42 if (isset($httpCodes[$type])) {
43  elgg_set_http_header("HTTP/1.1 {$type} {$httpCodes[$type]}");
44 }
45 
46 $layout = elgg_in_context('admin') && elgg_is_admin_logged_in() ? 'admin' : 'error';
47 
49  'title' => $title,
50  'content' => $content,
51  'filter' => false,
52 ]);
53 
55 if (!elgg_is_logged_in() && elgg_get_config('walled_garden')) {
56  $shell = 'walled_garden';
57 }
58 
$title
Definition: error.php:20
$httpCodes
Definition: error.php:32
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:43
elgg_view_layout(string $layout_name, array $vars=[])
Displays a layout with optional parameters.
Definition: views.php:352
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:52
$vars['filter']
Definition: error.php:17
$shell
Definition: error.php:54
elgg_in_context(string $context)
Check if this context exists anywhere in the stack.
Definition: context.php:78
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$type
The generic error page.
Definition: error.php:14
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_set_http_header(string $header, bool $replace=true)
Set a response HTTP header.
Definition: elgglib.php:26
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
elgg_language_key_exists(string $key, string $language= 'en')
Check if a given language key exists.
Definition: languages.php:44
elgg_view_page(string $title, string|array $body, string $page_shell= 'default', array $vars=[])
Assembles and outputs a full page.
Definition: views.php:235
if(isset($httpCodes[$type])) $layout
Definition: error.php:46
$params
Definition: error.php:17
$body
Definition: error.php:48
$content
Set robots.txt action.
Definition: set_robots.php:6
$exception
Definition: error.php:15
elgg_view_exists(string $view, string $viewtype= '', bool $recurse=true)
Returns whether the specified view exists.
Definition: views.php:131