You are here

function customerror_page in Customerror 6

Same name and namespace in other branches
  1. 5 customerror.module \customerror_page()
  2. 7 customerror.module \customerror_page()

Displays the 403 or 404 error page.

1 string reference to 'customerror_page'
customerror_menu in ./customerror.module
Implements hook_menu().

File

./customerror.module, line 185
Enables custom 404 (not found) and 403 (access denied) pages in Drupal.

Code

function customerror_page() {
  $code = arg(1);

  // Set custom theme for error_page if any has been selected, 0 => default.
  $theme = customerror_get_theme($code);
  if (!empty($theme)) {
    global $custom_theme;
    $custom_theme = $theme;
  }
  switch ($code) {
    case 403:
      $internal_path = substr(request_uri(), strlen(base_path()));
      if ($internal_path) {
        $_REQUEST['destination'] = $internal_path;
      }
      else {
        $_REQUEST['destination'] = variable_get('site_frontpage', 'node');
      }
      $_SESSION['destination'] = $_REQUEST['destination'];
    case 404:
    default:

      // Treat an unknown method as a 404.
      // Check if we should redirect.
      customerror_check_redirect();

      // Make sure that we sent an appropriate header.
      customerror_header($code);
      module_invoke_all('customerror_pre_render', $code);
      drupal_set_title(variable_get('customerror_' . $code . '_title', _customerror_fetch_error($code)));
      $output = theme('customerror', $code, variable_get('customerror_' . $code, _customerror_fetch_error($code)));
      $output = variable_get('customerror_' . $code . '_php', FALSE) ? drupal_eval($output) : $output;
      break;
  }
  return $output;
}