You are here

function customerror_page in Customerror 7

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

Returns the content to display on the the 403 or 404 error page.

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

File

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

Code

function customerror_page($code) {
  switch ($code) {
    case 403:
      $internal_path = substr(request_uri(), strlen(base_path()));
      if ($internal_path) {

        // Lets determine if we have a prefix from our languages.
        if (module_exists('locale') && function_exists('language_url_split_prefix')) {

          // Turn the path into a string so we can then remove our prefix.
          list($language, $internal_path) = language_url_split_prefix($internal_path, language_list());
        }
        $dest = drupal_parse_url($internal_path);
        if (isset($dest['query']['destination'])) {
          $_GET['destination'] = $dest['query']['destination'];
        }
        else {
          $_GET['destination'] = $internal_path;
        }
      }
      else {
        $_GET['destination'] = variable_get('site_frontpage', 'node');
      }

      // If the user is not logged in, save destination to redirect if they do.
      if (!$GLOBALS['user']->uid) {
        $_SESSION['customerror_destination'] = $_GET['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);
      if (module_exists('customerroralt') && customerroralt_code($code)) {
        $code = customerroralt_code($code);
      }
      $desc = _customerror_fetch_error($code);

      //drupal_set_title(variable_get('customerror_' . $code . '_title', $desc[0]));
      $output = theme('customerror', array(
        'code' => $code,
        'content' => variable_get('customerror_' . $code, $desc[1]),
      ));
      if (module_exists('php')) {
        $output = php_eval($output);
      }
      break;
  }
  return $output;
}