Elgg  Version master
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 
22 if (elgg_view_exists("errors/{$type}")) {
23  if (elgg_language_key_exists("error:{$type}:title")) {
24  // use custom error title is available
25  $title = elgg_echo("error:{$type}:title");
26  }
27 
28  $content = elgg_view("errors/{$type}", $params);
29 } else {
30  $content = elgg_view('errors/default', $params);
31 }
32 
34  '400' => 'Bad Request',
35  '401' => 'Unauthorized',
36  '403' => 'Forbidden',
37  '404' => 'Not Found',
38  '407' => 'Proxy Authentication Required',
39  '500' => 'Internal Server Error',
40  '503' => 'Service Unavailable',
41 ];
42 
43 if (isset($httpCodes[$type])) {
44  elgg_set_http_header("HTTP/1.1 {$type} {$httpCodes[$type]}");
45 }
46 
47 $layout = elgg_in_context('admin') && elgg_is_admin_logged_in() ? 'admin' : 'error';
48 
50  'title' => $title,
51  'content' => $content,
52  'filter' => false,
53 ]);
54 
56 if (!elgg_is_logged_in() && elgg_get_config('walled_garden')) {
57  $shell = 'walled_garden';
58 }
59 
$title
Definition: error.php:20
$httpCodes
Definition: error.php:33
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:43
$layout
Definition: error.php:22
elgg_view_layout(string $layout_name, array $vars=[])
Displays a layout with optional parameters.
Definition: views.php:373
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:55
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:177
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:256
$body
Definition: error.php:20
$params
Definition: error.php:17
$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:152