You are here

globalredirect_admin.module in Global Redirect 5

This is the GlobalRedirect Admin module which provides an interface to global redirect to change some of the default settings

File

globalredirect_admin/globalredirect_admin.module
View source
<?php

/**
 * @file
 *  This is the GlobalRedirect Admin module which provides an interface to global redirect to change some of the default settings
 */

/**
 * Implementation of hook_menu().
 */
function globalredirect_admin_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/globalredirect',
      'title' => t('Global Redirect'),
      'description' => t('Chose which features you would like enabled for Global Redirect'),
      'access' => user_access('administer site configuration'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'globalredirect_admin_settings',
      ),
    );
    return $items;
  }
}

/**
 *  Function to generate the form setting array
 */
function globalredirect_admin_settings() {
  $form = array();
  $form['globalredirect_deslash'] = array(
    '#type' => 'radios',
    '#title' => t('Deslash'),
    '#description' => t('If enabled, this option will remove the trailing slash from requests. This stops requests such as <code>example.com/node/1/</code> failing to match the corresponding alias and can cause duplicate content. On the other hand, if you require certain requests to have a trailing slash, this feature can cause problems so may need to be disabled.'),
    '#options' => array(
      GLOBALREDIRECT_FEATURE_DISABLED => t('Off'),
      GLOBALREDIRECT_DESLASH_ENABLED => t('On'),
    ),
    '#default_value' => variable_get('globalredirect_deslash', GLOBALREDIRECT_DESLASH_ENABLED),
  );
  $form['globalredirect_nonclean2clean'] = array(
    '#type' => 'radios',
    '#title' => t('Non-clean to Clean'),
    '#description' => t('If enabled, this option will redirect from non-clean to clean URL (if Clean URL\'s are enabled). This will stop, for example, node 1  existing on both <code>example.com/node/1</code> AND <code>example.com?q=node/1</code>.'),
    '#options' => array(
      GLOBALREDIRECT_FEATURE_DISABLED => t('Off'),
      GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED => t('On'),
    ),
    '#default_value' => variable_get('globalredirect_nonclean2clean', GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED),
  );
  $form['globalredirect_trailingzero'] = array(
    '#type' => 'radios',
    '#title' => t('Remove Trailing Zero Argument'),
    '#description' => t('If enabled, any instance of "/0" will be trimmed from the right of the URL. This stops duplicate pages such as "taxonomy/term/1" and "taxonomy/term/1/0" where 0 is the default depth. There is an option of limiting this feature to taxonomy term pages ONLY or allowing it to effect any page. <strong>By default this feature is disabled to avoid any unexpected behaviour</strong>'),
    '#options' => array(
      GLOBALREDIRECT_FEATURE_DISABLED => t('Disabled'),
      GLOBALREDIRECT_TRAILINGZERO_TAXTERM => t('Enabled for taxonomy term pages only'),
      GLOBALREDIRECT_TRAILINGZERO_ALL => t('Enabled for all pages'),
    ),
    '#default_value' => variable_get('globalredirect_trailingzero', GLOBALREDIRECT_FEATURE_DISABLED),
  );
  $form['globalredirect_case_sensitive_urls'] = array(
    '#type' => 'radios',
    '#title' => t('Case Sensitive URLs'),
    '#description' => t('If enabled, the module will compare the current URL to the alias stored in the system. If there are any differences in case then the user will be redirected to the correct URL.'),
    '#options' => array(
      GLOBALREDIRECT_FEATURE_DISABLED => t('Off'),
      GLOBALREDIRECT_CASE_SENSITIVE_URLS_ENABLED => t('On'),
    ),
    '#default_value' => variable_get('globalredirect_case_sensitive_urls', GLOBALREDIRECT_CASE_SENSITIVE_URLS_ENABLED),
  );
  return system_settings_form($form);
}

Functions

Namesort descending Description
globalredirect_admin_menu Implementation of hook_menu().
globalredirect_admin_settings Function to generate the form setting array