You are here

function location_map_link_options_form in Location 7.3

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

Settings page for map links.

1 string reference to 'location_map_link_options_form'
location_menu in ./location.module
Implements hook_menu().

File

./location.admin.inc, line 118
Admin forms for Location.

Code

function location_map_link_options_form($form, &$form_state) {
  $form = array();
  $form['countries'] = array(
    '#type' => 'markup',
    '#markup' => '',
  );
  foreach (_location_supported_countries() as $country_iso => $country_name) {
    location_load_country($country_iso);
    $form['countries'][$country_iso] = array(
      '#type' => 'markup',
      '#markup' => '',
    );
    $form['countries'][$country_iso]['label_' . $country_iso] = array(
      '#type' => 'markup',
      '#markup' => $country_name,
    );

    // Set up '#options' array for mapping providers for the current country.
    $mapping_options = array();
    $provider_function = 'location_map_link_' . $country_iso . '_providers';
    $default_provider_function = 'location_map_link_' . $country_iso . '_default_providers';

    // Default providers will be taken from the country specific default providers
    // function if it exists, otherwise it will use the global function.
    $checked = variable_get('location_map_link_' . $country_iso, function_exists($default_provider_function) ? $default_provider_function() : location_map_link_default_providers());

    // Merge the global providers with country specific ones so that countries
    // can add to or override the defaults.
    $providers = function_exists($provider_function) ? array_merge(location_map_link_providers(), $provider_function()) : location_map_link_providers();
    foreach ($providers as $name => $details) {
      $mapping_options[$name] = '<a href="' . $details['url'] . '">' . $details['name'] . '</a> (<a href="' . $details['tos'] . '">Terms of Use</a>)';
    }
    if (count($mapping_options)) {
      $form['countries'][$country_iso]['location_map_link_' . $country_iso] = array(
        '#title' => '',
        '#type' => 'checkboxes',
        '#default_value' => $checked,
        '#options' => $mapping_options,
      );
    }
    else {
      $form['countries'][$country_iso]['location_map_link_' . $country_iso] = array(
        '#type' => 'markup',
        '#markup' => t('None supported.'),
      );
    }
  }
  $form = system_settings_form($form);
  $form['#theme'] = 'location_map_link_options';
  return $form;
}