Elgg  Version 2.3
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 if (elgg_view_exists("errors/$type")) {
7  $title = elgg_echo("error:$type:title");
8  if ($title == "error:$type:title") {
9  // use default if there is no title for this error type
10  $title = elgg_echo("error:default:title");
11  }
12 
13  $content = elgg_view("errors/$type", $params);
14 } else {
15  $title = elgg_echo("error:default:title");
16  $content = elgg_view("errors/default", $params);
17 }
18 
19 $httpCodes = array(
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 ));
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:293
$content
Definition: error.php:16
$httpCodes
Definition: error.php:19
if(isset($vars['class'])) $vars['class']
Definition: error.php:14
elgg_set_http_header($header, $replace=true)
Set a response HTTP header.
Definition: elgglib.php:114
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:60
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_layout($layout_name, $vars=array())
Displays a layout with optional parameters.
Definition: views.php:689
$type
Definition: error.php:3
$title
Definition: save.php:22
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:241
if(isset($httpCodes[$type])) $layout
Definition: error.php:33
elgg echo
Translates a string.
Definition: languages.js:48
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
$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:1375
$body
Definition: error.php:35
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
Definition: views.php:447