Index: customerror.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/customerror/customerror.module,v retrieving revision 1.13.2.7 diff -u -F^f -r1.13.2.7 customerror.module --- customerror.module 27 Dec 2007 20:12:50 -0000 1.13.2.7 +++ customerror.module 5 Jul 2008 02:43:32 -0000 @@ -60,8 +60,17 @@ function customerror_admin_settings() '#value' => t('Enter the error pages that will be seen by your visitors when they get the respective errors. You can enter any HTML text. You can point the users to the FAQ, inform them that you reorganized the site, ask them to report the error, login or register, ...etc.') ) ); - + $errors = _customerror_enum_errors(); + + // get custom themes. + $themes = system_theme_data(); + ksort($themes); + $options[0] = t('System default'); + foreach ($themes as $theme) { + $options[$theme->name] = $theme->name; + } + foreach($errors as $error_code => $error_desc) { $form['customerror_' . $error_code . '_title'] = array( '#type' => 'textfield', @@ -84,6 +93,14 @@ function customerror_admin_settings() '#default_value' => variable_get('customerror_' . $error_code . '_php', FALSE), '#description' => t('This allows you to include PHP code (enclosed in <?php ?> tags) for the @error_code (@error_desc) message. Note that this can be dangerous in some situations. Make sure that you are aware of the implications.', array('@error_code' => $error_code, '@error_desc' => $error_desc)), ); + + $form['customerror_' . $error_code . '_theme'] = array( + '#type' => 'select', + '#options' => $options, + '#title' => t(' Theme'), + '#description' => t('Choose which theme the dould be used on the error page.'), + '#default_value' => customerror_get_theme($error_code), + ); } $form['customerror_redirect'] = array( @@ -99,7 +116,6 @@ function customerror_admin_settings() function customerror_menu($may_cache) { $items = array(); - if ($may_cache) { $items[] = array( 'path' => 'admin/settings/customerror', @@ -134,8 +150,15 @@ function customerror_simpletest() { * Implementation of hook_page(). */ function customerror_page() { - $error_code = arg(1); - + $error_code = (int)arg(1); + + // set custom theme for error_page if any has been selected, 0 => default + global $custom_theme; + $theme = customerror_get_theme($error_code); + if(!empty($theme)){ + $custom_theme = $theme; + } + switch($error_code) { case 403: case 404: @@ -173,6 +196,7 @@ function customerror_user($op, $edit, $u } } } + function customerror_check_redirect() { $destination = $_REQUEST['destination']; if (isset($destination)) { @@ -192,3 +216,13 @@ function customerror_check_redirect() { } } } + +function customerror_get_theme($error_code = 404) { + $theme = 0; + + $admin_theme = variable_get('admin_theme', FALSE); + if ($admin_theme) { + $theme = variable_get('customerror_' . $error_code . '_theme', $admin_theme); + } + return $theme; +}