You are here

function location_map_link_options_form in Location 5

Same name and namespace in other branches
  1. 5.3 location.d5.inc \location_map_link_options_form()
  2. 6.3 location.admin.inc \location_map_link_options_form()
  3. 7.5 location.admin.inc \location_map_link_options_form()
  4. 7.3 location.admin.inc \location_map_link_options_form()
  5. 7.4 location.admin.inc \location_map_link_options_form()
1 string reference to 'location_map_link_options_form'
location_map_link_options_page in ./location.module

File

./location.module, line 290

Code

function location_map_link_options_form() {
  $form = array();
  $form['countries'] = array(
    '#type' => 'markup',
    '#value' => '',
  );
  foreach (location_configured_countries() as $country_iso => $country_name) {
    $form['countries'][$country_iso] = array(
      '#type' => 'markup',
      '#value' => '',
    );
    $form['countries'][$country_iso]['label_' . $country_iso] = array(
      '#type' => 'markup',
      '#value' => $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';
    $checked = variable_get('location_map_link_' . $country_iso, function_exists($default_provider_function) ? $default_provider_function() : array());

    //print "Calling provider function $provider_function";
    if (function_exists($provider_function)) {
      foreach ($provider_function() 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',
        '#value' => t('None supported.'),
      );
    }
  }
  $form['#theme'] = 'location_map_link_options';
  return system_settings_form($form);
}