system_clean_url_settings

Versions
5 – 6
system_clean_url_settings()
7
system_clean_url_settings($form, &$form_state)

Form builder; Configure clean URL settings.

See also

system_settings_form()

Related topics

Code

modules/system/system.admin.inc, line 1973

<?php
function system_clean_url_settings($form, &$form_state) {
  global $base_url;

  // When accessing this form using a non-clean URL, allow a re-check to make
  // sure clean URLs can be disabled at all times.
  $available = FALSE;
  if (strpos(request_uri(), '?q=') === FALSE || !empty($_SESSION['clean_url'])) {
    $available = TRUE;
  }
  else {
    $request = drupal_http_request($base_url . '/admin/config/search/clean-urls/check');
    if (isset($request->code) && $request->code == 200) {
      $available = TRUE;
    }
  }

  if ($available) {
    $_SESSION['clean_url'] = TRUE;

    $form['clean_url'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable clean URLs'),
      '#default_value' => 0,
      '#description' => t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.'),
    );
    $form = system_settings_form($form);
  }
  else {
    drupal_add_js(drupal_get_path('module', 'system') . '/system.js');

    $form_state['redirect'] = $base_url . '/admin/config/search/clean-urls';
    $form['clean_url_description'] = array(
      '#type' => 'markup',
      '#markup' => '<p>' . t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.') . ' ' . t('If you are directed to a <em>Page not found (404)</em> error after testing for clean URLs, see the <a href="@handbook">online handbook</a>.', array('@handbook' => 'http://drupal.org/node/15365')) . '</p>',
    );
    $form['clean_url_test'] = array(
      '#type' => 'submit',
      '#value' => t('Run the clean URL test'),
    );
  }

  return $form;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.