You are here

function redirect_settings_form in Redirect 7.2

Same name and namespace in other branches
  1. 7 redirect.admin.inc \redirect_settings_form()

Form builder for redirection settings.

See also

system_settings_form()

redirect_settings_form_submit()

1 string reference to 'redirect_settings_form'
redirect_menu in ./redirect.module
Implements hook_menu().

File

./redirect.admin.inc, line 647
Administrative page callbacks for the redirect module.

Code

function redirect_settings_form($form, &$form_state) {
  $form['redirect_auto_redirect'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically create redirects when URL aliases are changed.'),
    '#default_value' => variable_get('redirect_auto_redirect', TRUE),
    '#disabled' => !module_exists('path'),
  );
  $form['redirect_auto_redirect_delete'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically create redirects when URL aliases are deleted.'),
    '#default_value' => variable_get('redirect_auto_redirect_delete', FALSE),
    '#disabled' => !module_exists('path'),
  );
  $form['redirect_passthrough_querystring'] = array(
    '#type' => 'checkbox',
    '#title' => t('Retain query string through redirect.'),
    '#default_value' => variable_get('redirect_passthrough_querystring', 1),
    '#description' => t('For example, given a redirect from %source to %redirect, if a user visits %sourcequery they would be redirected to %redirectquery. The query strings in the redirection will always take precedence over the current query string.', array(
      '%source' => 'source-path',
      '%redirect' => 'node?a=apples',
      '%sourcequery' => 'source-path?a=alligators&b=bananas',
      '%redirectquery' => 'node?a=apples&b=bananas',
    )),
  );
  $form['redirect_delete_by_source_path'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically delete redirects when an entity with the redirect\'s source has been deleted.'),
    '#default_value' => variable_get('redirect_delete_by_source_path', TRUE),
  );
  $form['redirect_warning'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display a warning message to users when they are redirected.'),
    '#default_value' => variable_get('redirect_warning', FALSE),
    '#access' => FALSE,
  );
  $form['redirect_default_status_code'] = array(
    '#type' => 'select',
    '#title' => t('Default redirect status'),
    '#description' => t('You can find more information about HTTP redirect status codes at <a href="@status-codes">@status-codes</a>.', array(
      '@status-codes' => 'http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection',
    )),
    '#options' => redirect_status_code_options(),
    '#default_value' => variable_get('redirect_default_status_code', 301),
  );
  $form['redirect_page_cache'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow redirects to be saved into the page cache.'),
    '#default_value' => variable_get('redirect_page_cache', 0),
    '#description' => t('This feature requires <a href="@performance">Cache pages for anonymous users</a> to be enabled and the %variable variable to be true (currently set to @value).', array(
      '@performance' => url('admin/config/development/performance'),
      '%variable' => "\$conf['page_cache_invoke_hooks']",
      '@value' => var_export(variable_get('page_cache_invoke_hooks', TRUE), TRUE),
    )),
    '#disabled' => !variable_get('cache', 0) || !variable_get('page_cache_invoke_hooks', TRUE),
  );
  $form['redirect_purge_inactive'] = array(
    '#type' => 'select',
    '#title' => t('Delete redirects that have not been accessed for'),
    '#default_value' => variable_get('redirect_purge_inactive', 0),
    '#options' => array(
      0 => t('Never (do not discard)'),
    ) + drupal_map_assoc(array(
      604800,
      1209600,
      1814400,
      2592000,
      5184000,
      7776000,
      10368000,
      15552000,
      31536000,
    ), 'format_interval'),
    '#description' => t('Only redirects managed by the redirect module itself will be deleted. Redirects managed by other modules will be left alone.'),
    '#disabled' => variable_get('redirect_page_cache', 0) && !variable_get('page_cache_invoke_hooks', TRUE),
  );
  $form['redirect_purge_amount'] = array(
    '#type' => 'select',
    '#title' => t('Maximum number of redirects to delete per cron run'),
    '#default_value' => variable_get('redirect_purge_amount', 100),
    '#options' => drupal_map_assoc(array(
      10,
      20,
      50,
      100,
      200,
      500,
    )),
    '#description' => t('The maximum number of redirects that can be deleted in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors.', array(
      '@cron' => url('admin/reports/status'),
    )),
    '#states' => array(
      'invisible' => array(
        ':input[name="redirect_purge_inactive"]' => array(
          'value' => '0',
        ),
      ),
    ),
  );
  $form['globals'] = array(
    '#type' => 'fieldset',
    '#title' => t('Always enabled redirections'),
    '#description' => t('(formerly Global Redirect features)'),
    '#access' => FALSE,
  );
  $form['globals']['redirect_global_home'] = array(
    '#type' => 'checkbox',
    '#title' => t('Redirect from paths like index.php and /node to the root directory.'),
    '#default_value' => variable_get('redirect_global_home', 1),
    '#access' => FALSE,
  );
  $form['globals']['redirect_global_clean'] = array(
    '#type' => 'checkbox',
    '#title' => t('Redirect from non-clean URLs to clean URLs.'),
    '#default_value' => variable_get('redirect_global_clean', 1),
    '#disabled' => !variable_get('clean_url', 0),
    '#access' => FALSE,
  );
  $form['globals']['redirect_global_canonical'] = array(
    '#type' => 'checkbox',
    '#title' => t('Redirect from non-canonical URLs to the canonical URLs.'),
    '#default_value' => variable_get('redirect_global_canonical', 1),
  );
  $form['globals']['redirect_global_deslash'] = array(
    '#type' => 'checkbox',
    '#title' => t('Remove trailing slashes from paths.'),
    '#default_value' => variable_get('redirect_global_deslash', 0),
    '#access' => FALSE,
  );
  $form['globals']['redirect_global_admin_paths'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow redirections on admin paths.'),
    '#default_value' => variable_get('redirect_global_admin_paths', 0),
  );
  $form['#submit'][] = 'redirect_settings_form_submit';
  return system_settings_form($form);
}