You are here

function _location_supported_countries in Location 7.5

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

Returns an associative array of countries currently supported by the location system where -> the keys represent the two-letter ISO code and -> the values represent the English name of the country. The array is sorted the index (i.e., by the short English name of the country).

Please note the different between "supported" countries and "configured" countries: A country being "supported" means that there is an include file to support the country while "configure" implies that the site admin has configured the site to actually use that country.

Related topics

3 calls to _location_supported_countries()
location_admin_settings in ./location.admin.inc
Admin settings form.
location_geocoding_options_form in ./location.admin.inc
location_map_link_options_form in ./location.admin.inc
Settings page for map links.

File

./location.inc, line 433

Code

function _location_supported_countries() {
  $supported_countries =& drupal_static(__FUNCTION__, array());

  // If this function has already been called this request, we can avoid a DB hit.
  if (!empty($supported_countries)) {
    return $supported_countries;
  }

  // Try first to load from cache, it's much faster than the scan below.
  if ($cache = cache_get('location:supported-countries', 'cache_location')) {
    $supported_countries = $cache->data;
  }
  else {

    // '<ISO two-letter code>' => '<English name for country>'
    $iso_list = location_get_iso3166_list();
    $path = drupal_get_path('module', 'location') . '/supported/location.';
    foreach ($iso_list as $cc => $name) {
      if (file_exists($path . $cc . '.inc')) {
        $supported_countries[$cc] = $name;
      }
    }
    cache_set('location:supported-countries', $supported_countries, 'cache_location');
  }
  return $supported_countries;
}