View source
<?php
define('BLOCKS404_PAGE', 'blocks404');
function blocks404_init() {
$site_404 = variable_get('site_404', '');
if ($site_404 == '') {
variable_set('site_404', BLOCKS404_PAGE);
}
define('BLOCKS404_ORIGINAL_QUERY', $_GET['q']);
}
function blocks404_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => BLOCKS404_PAGE,
'title' => 'Page not found',
'access' => TRUE,
'callback' => 'blocks404_404_page',
'type' => MENU_CALLBACK,
);
}
return $items;
}
function blocks404_404_page() {
return t('The requested page could not be found.');
}
function blocks404_preprocess_page(&$vars, $hook) {
if (strpos(drupal_get_headers(), 'HTTP/1.1 404 Not Found') !== FALSE) {
module_load_include('inc', 'blocks404', 'blocks404.active');
_blocks404_preprocess_page($vars);
}
}
function blocks404_form_alter($form_id, &$form) {
if ($form_id == 'system_error_reporting_settings') {
if ($form['site_404']['#default_value'] == BLOCKS404_PAGE) {
$form['site_404']['#default_value'] = '';
}
}
elseif ($_GET['q'] == BLOCKS404_PAGE) {
include_once './' . drupal_get_path('module', 'blocks404') . '/blocks404.active.inc';
_blocks404_form_alter($form_id, $form);
}
}