Same name and namespace in other branches
  1. 5.x modules/system/system.module \system_clean_url_settings()
  2. 7.x modules/system/system.admin.inc \system_clean_url_settings()

Form builder; Configure Clean URL settings.

See also

system_settings_form()

Related topics

1 string reference to 'system_clean_url_settings'
system_menu in modules/system/system.module
Implementation of hook_menu().

File

modules/system/system.admin.inc, line 1691
Admin page callbacks for the system module.

Code

function system_clean_url_settings() {
  $form['clean_url'] = array(
    '#type' => 'radios',
    '#title' => t('Clean URLs'),
    '#default_value' => variable_get('clean_url', 0),
    '#options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    '#description' => t('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'),
  );
  if (!variable_get('clean_url', 0)) {
    if (strpos(request_uri(), '?q=') !== FALSE) {
      drupal_add_js(drupal_get_path('module', 'system') . '/system.js', 'module');
      $form['clean_url']['#description'] .= ' <span>' . t('Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The <a href="@handbook">handbook page on Clean URLs</a> has additional troubleshooting information.', array(
        '@handbook' => 'http://drupal.org/node/15365',
      )) . '</span>';
      $form['clean_url']['#disabled'] = TRUE;
      $form['clean_url']['#prefix'] = '<div id="clean-url">';
      $form['clean_url']['#suffix'] = '<p>' . t('<a href="@clean_url">Run the clean url test</a>.', array(
        '@clean_url' => base_path() . 'admin/settings/clean-urls',
      )) . '</p></div>';
    }
    else {
      $form['clean_url']['#description'] .= ' <div class="ok">' . t('Your server has been successfully tested to support this feature.') . '</div>';
    }
  }
  return system_settings_form($form);
}