/[drupal]/contributions/modules/blocks404/blocks404.module
ViewVC logotype

Contents of /contributions/modules/blocks404/blocks404.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Tue Jan 6 06:42:50 2009 UTC (10 months, 3 weeks ago) by johnalbin
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, DRUPAL-6--1-1, HEAD
Branch point for: DRUPAL-5
Changes since 1.3: +13 -1 lines
File MIME type: text/x-php
Added form_alter() to allow proper form submissions on 404 pages.
1 <?php
2 // $Id: blocks404.module,v 1.3 2009/01/06 06:39:55 johnalbin Exp $
3
4 define('BLOCKS404_PAGE', 'blocks404');
5
6 /**
7 * Implements hook_init().
8 */
9 function blocks404_init() {
10 // If site_404 is not set, all menu-related items disappear on 404.
11 $site_404 = variable_get('site_404', '');
12 if ($site_404 == '') {
13 variable_set('site_404', BLOCKS404_PAGE);
14 }
15 // drupal_not_found() sets $_GET['q'] to the site_404 variable, so make a copy.
16 define('BLOCKS404_ORIGINAL_QUERY', $_GET['q']);
17 }
18
19 /**
20 * Implements hook_menu().
21 */
22 function blocks404_menu() {
23 $items[BLOCKS404_PAGE] = array(
24 'title' => 'Page not found',
25 'access callback' => TRUE,
26 'page callback' => 'blocks404_404_page',
27 'type' => MENU_CALLBACK,
28 );
29 return $items;
30 }
31
32 /**
33 * Our custom menu callback that returns Drupal's standard 404 message.
34 */
35 function blocks404_404_page() {
36 return t('The requested page could not be found.');
37 }
38
39 /**
40 * Renders the left and right regions and resets the body classes on 404 pages.
41 */
42 function blocks404_preprocess_page(&$vars, $hook) {
43 if (strpos(drupal_get_headers(), 'HTTP/1.1 404 Not Found') !== FALSE) {
44 module_load_include('inc', 'blocks404', 'blocks404.active');
45 _blocks404_preprocess_page($vars);
46 }
47 }
48
49 /**
50 * Implements hook_form_alter().
51 */
52 function blocks404_form_system_error_reporting_settings_alter(&$form, $form_state) {
53 // Since we don't care what site_404 is set to, let the user set it if they want.
54 if ($form['site_404']['#default_value'] == BLOCKS404_PAGE) {
55 $form['site_404']['#default_value'] = '';
56 }
57 }
58
59 /**
60 * Implements hook_form_alter().
61 */
62 function blocks404_form_alter(&$form, $form_state, $form_id) {
63 if ($_GET['q'] == BLOCKS404_PAGE) {
64 module_load_include('inc', 'blocks404', 'blocks404.active');
65 _blocks404_form_alter($form, $form_state, $form_id);
66 }
67 }

  ViewVC Help
Powered by ViewVC 1.1.2