You are here

function customerror_admin_settings in Customerror 6

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

Callback, page arguments.

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

File

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

Code

function customerror_admin_settings() {
  $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.'),
    ),
  );
  $themes = system_theme_data();
  ksort($themes);
  $theme_options[0] = t('System default');
  foreach ($themes as $theme) {
    if ($theme->status) {
      $theme_options[$theme->name] = $theme->name;
    }
  }
  $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('Error reporting settings page'), 'admin/settings/error-reporting'),
      )), 'error');
    }
  }
  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,
    );
    $form[$group]['customerror_' . $code . '_title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title for @code', array(
        '@code' => $code,
      )),
      '#default_value' => variable_get('customerror_' . $code . '_title', $desc),
      '#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),
      '#rows' => 10,
      '#description' => t('This text will be displayed if a @code (@desc) error occurs.', array(
        '@code' => $code,
        '@desc' => $desc,
      )),
    );
    $form[$group]['customerror_' . $code . '_theme'] = array(
      '#type' => 'select',
      '#options' => $theme_options,
      '#title' => t('Theme'),
      '#description' => t('Theme to be used on the error page below the admin path.'),
      '#default_value' => variable_get('customerror_' . $code . '_theme', 0),
    );
    $form[$group]['customerror_' . $code . '_php'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow PHP code to be executed for @code', array(
        '@code' => $code,
      )),
      '#default_value' => variable_get('customerror_' . $code . '_php', FALSE),
      '#description' => t('This allows you to include PHP code (enclosed in <?php ?> tags) for the @code (@desc) message. Note that this can be dangerous in some situations. Make sure that you are aware of the implications.', array(
        '@code' => $code,
        '@desc' => $desc,
      )),
    );
  }
  $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>.'),
  );
  return system_settings_form($form);
}