You are here

function customerror_admin_settings in Customerror 5

Same name and namespace in other branches
  1. 6 customerror.module \customerror_admin_settings()
  2. 7 customerror.module \customerror_admin_settings()
1 string reference to 'customerror_admin_settings'
customerror_menu in ./customerror.module

File

./customerror.module, line 53
Enables custom 404 (not found) and 403 (access denied) pages in Drupal with no need for creating real nodes under taxonomies

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.'),
    ),
  );
  $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 check the settings !link.', array(
        '!error' => $code,
        '!link' => l(t('here'), '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 . ' error page',
      )),
    );
    $form[$group]['customerror_' . $code] = array(
      '#type' => 'textarea',
      '#title' => t('Description for ') . $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 . '_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('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);
}