You are here

function customerror_admin_settings in Customerror 7

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

Displays the module settings form.

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

File

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

Code

function customerror_admin_settings($form, &$form_state) {
  $form = array(
    'customerror_form_description' => array(
      '#type' => 'markup',
      '#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();
  foreach ($errors as $code => $desc) {
    if (variable_get('site_' . $code, '') != 'customerror/' . $code) {
      drupal_set_message(t('Error reporting is not set for error !error. Please ensure that the default !error page is set to be customerror/!error on the !link.', array(
        '!error' => $code,
        '!link' => l(t('Site information settings page'), 'admin/config/system/site-information'),
      )), 'error');
    }
  }
  $weight = -15;
  foreach ($errors as $code => $desc) {
    $group = 'customerror_' . $code . '_group';
    $form[$group] = array(
      '#type' => 'fieldset',
      '#title' => t('!code Error Settings', array(
        '!code' => $code,
      )),
      '#collapsed' => TRUE,
      '#collapsible' => TRUE,
      '#weight' => $weight,
    );

    // Make room for some additional 403 codes.
    $weight += 8;
    $form[$group]['customerror_' . $code . '_title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title for @code', array(
        '@code' => $code,
      )),
      '#default_value' => variable_get('customerror_' . $code . '_title', $desc[0]),
      '#size' => 70,
      '#maxlength' => 70,
      '#description' => t('Title of @code error page', array(
        '@code' => $code,
      )),
    );
    $form[$group]['customerror_' . $code] = array(
      '#type' => 'textarea',
      '#title' => t('Description for @code', array(
        '@code' => $code,
      )),
      '#default_value' => variable_get('customerror_' . $code, $desc[1]),
      '#rows' => 10,
      '#description' => t('This text will be displayed if a @code (@desc) error occurs.', array(
        '@code' => $code,
        '@desc' => $desc[1],
      )),
    );
  }
  $form['redirects'] = array(
    '#type' => 'fieldset',
    '#title' => t('404 Redirects'),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
  );
  $form['redirects']['customerror_redirect'] = array(
    '#type' => 'textarea',
    '#title' => t('Redirect list'),
    '#default_value' => variable_get('customerror_redirect', ''),
    '#rows' => 10,
    '#description' => t('These are custom redirect pairs, one per line. Each pair requires a path to match (which is a regular expression) and a destination separated by a space. The keyword <em>&lt;front></em> is allowed as a destination. If you are unfamilar with regular expressions, a simple search string will work, but will match any part of the URl. For example <em>index.html &lt;front></em> will match both <em>http://example.com/index.html &amp; http://example.com/archive/index.html</em>.'),
  );
  $themes = system_rebuild_theme_data();
  ksort($themes);
  $theme_options[0] = t('System default');
  foreach ($themes as $theme) {
    if ($theme->status) {
      $theme_options[$theme->name] = $theme->name;
    }
  }
  $form['theme'] = array(
    '#type' => 'fieldset',
    '#title' => t('Theme'),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
  );
  $form['theme']['customerror_theme'] = array(
    '#type' => 'select',
    '#options' => $theme_options,
    '#title' => t('Select theme'),
    '#description' => t('Set theme to be used on the error pages. The first option lets the system set the theme. Each of the remaining options lets you set an explicit theme to be used on error pages (but it will not override the administration theme, if set).'),
    '#default_value' => variable_get('customerror_theme', 0),
  );
  return system_settings_form($form);
}