You are here

function location_admin_settings in Location 5

Same name and namespace in other branches
  1. 5.3 location.d5.inc \location_admin_settings()
  2. 6.3 location.admin.inc \location_admin_settings()
  3. 7.5 location.admin.inc \location_admin_settings()
  4. 7.3 location.admin.inc \location_admin_settings()
  5. 7.4 location.admin.inc \location_admin_settings()

Callback for admin/settings/location

1 string reference to 'location_admin_settings'
location_menu in ./location.module
Implementation of hook_menu.

File

./location.module, line 1327

Code

function location_admin_settings() {
  cache_clear_all('location:supported-countries', 'cache');
  $supported_countries = _location_supported_countries();
  $default_country = variable_get('location_default_country', 'us');
  $configured_countries = location_get_configured_countries();
  $iso_list_sorted = _location_get_iso3166_list();
  array_multisort($iso_list_sorted);
  $iso_list_sorted = array_merge(array(
    '' => '',
  ), $iso_list_sorted);
  if ($default_country && in_array($default_country, array_keys($supported_countries)) && !in_array($default_country, $configured_countries)) {
    $configured_countries = variable_get('location_configured_countries', array(
      'us' => 1,
    ));
    $configured_countries[$default_country] = 1;
    variable_set('location_configured_countries', $configured_countries);

    // clear the views cache to pick up any changes
    if (function_exists('views_invalidate_cache')) {
      views_invalidate_cache();
    }
  }
  $form = array();
  $form['location_default_country'] = array(
    '#type' => 'select',
    '#title' => t('Default country selection'),
    '#default_value' => variable_get('location_default_country', 'us'),
    '#options' => $iso_list_sorted,
    '#description' => t('This will be the country that is automatically selected when a location form is served for a new location.'),
  );
  $form['location_suppress_country'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide country selection'),
    '#return_value' => 1,
    '#default_value' => variable_get('location_suppress_country', 0),
    '#description' => t("If your site is specific to a country and you would like to hide the country field on search forms and content creation forms, check this box.  Doing so will automatically assume the country to be the country you have chosen for the 'default country selection' above."),
  );
  $form['location_search_distance_unit'] = array(
    '#type' => 'radios',
    '#title' => t('Distance unit for location-based searches'),
    '#default_value' => variable_get('location_search_distance_unit', 0),
    '#options' => array(
      0 => t('Allow both miles and kilometers.'),
      'mile' => t('Only allow a search-radius to be specified in miles'),
      'km' => t('Only allow a search-radius to be specified in kilometers'),
    ),
    '#description' => t('Select the distance unit that applies when users search for content by a specified location and search-radius.'),
  );
  $form['location_display_location'] = array(
    '#type' => 'radios',
    '#title' => t('Toggle location display'),
    '#default_value' => variable_get('location_display_location', 1),
    '#options' => array(
      0 => t('Disable the display of locations.'),
      1 => t('Enable the display of locations.'),
    ),
    '#description' => t('If you are interested in turning off locations and having a custom theme control their display, you may want to disable the display of locations so your theme can take that function.'),
  );
  $form['location_user'] = array(
    '#type' => 'radios',
    '#title' => 'User locations',
    '#default_value' => variable_get('location_user', 0),
    '#options' => array(
      'Disable',
      'Enable',
    ),
    '#description' => t('Collect user addresses (partial or full) if users wish to submit them for their user accounts.'),
  );
  $form['location_usegmap'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use a Google Map to set latitude and longitude '),
    '#return_value' => 1,
    '#default_value' => variable_get('location_usegmap', 1),
    '#description' => t('If the gmap.module is installed and <a href="@enabled">enabled</a>, and this is setting is turned on, users that are allowed to manually enter latitude/longitude coordinates will be able to do so with an interactive Google Map.  You should also make sure you have entered a <a href="@google_maps_api_key">Google Maps API key</a> into your <a href="@gmap_module_settings">gmap module settings</a>.', array(
      '@enabled' => 'admin/build/modules',
      '@google_maps_api_key' => 'http://www.google.com/apis/maps',
      '@gmap_module_settings' => 'admin/settings/gmap',
    )),
  );
  $form['maplink_external'] = array(
    '#type' => 'fieldset',
    '#title' => t('Map link'),
  );
  $form['maplink_external']['location_maplink_external'] = array(
    '#type' => 'checkbox',
    '#title' => t('Open map link in new window'),
    '#default_value' => variable_get('location_maplink_external', 0),
    '#description' => t('Select this if you want the map link to open in a separate window'),
  );
  $form['maplink_external']['location_maplink_external_method'] = array(
    '#type' => 'radios',
    '#title' => t('Open in new window method'),
    '#options' => array(
      'target="_blank"' => 'target="_blank"',
      'rel="external"' => 'rel="external"',
    ),
    '#default_value' => variable_get('location_maplink_external_method', 'target="_blank"'),
    '#description' => t('If you have selected to open map in a new window this controls the method used to open in a new window.  target="_blank" will just work but is not XTHML Strict compliant.  rel="external" is XHTML Strict compliant but will not open in a new window unless you add some jQuery to your site to add the target attribute. If you are unsure leave set to target="_blank"'),
  );
  $form['location_configured_countries'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Enable all <em>available</em> features for locations from the following countries'),
    '#default_value' => location_get_configured_countries(),
    '#options' => $supported_countries,
    '#description' => t('Currently, your Drupal site is capable of supporting extra features (e.g., postal code proximity searches) for locations from this list of countries.  Please narrow the list down to countries for which you want to support these extra features.  It may be useful for performance to narrow down this list if most the locations in your system are from only a handful of the listed countries.'),
  );
  return system_settings_form($form);
}