You are here

function location_configured_countries in Location 5

Returns an associative array of countries currently recognized by the site admin's configuration where: -> the keys represent the two-letter ISO code and -> the values represent the English name of the country.

The array is sorted by the values.

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

5 calls to location_configured_countries()
location_geocoding_options_form in ./location.module
location_map_link_options_form in ./location.module
_location_country_select_options in ./location.inc
Given a pre-selected value, whether or not the form-item is required, and an optional form name, generates an HTML select for selecting a country in an location form.
_location_include_configured in ./location.inc
This function simply loads the include file for each country whose locationes are configured to be recognized by the location system.
_location_province_select_options in ./location.inc
The array that is returned is a complete list of state/provinces that belong to the countries enabled by the site's location system.
3 string references to 'location_configured_countries'
location_admin_settings in ./location.module
Callback for admin/settings/location
location_get_configured_countries in ./location.module
Returns an array of countries whose locations will be allowed entry into the site's location system. The array returned is an associative array where the keys are the ISO codes (see location.inc) and the values are the shortened English names.
location_update_2 in ./location.install

File

./location.inc, line 1091

Code

function location_configured_countries() {
  static $configured_countries_associative;
  if (!count($configured_countries)) {
    $configured_countries = variable_get('location_configured_countries', array(
      'us' => 'us',
    ));

    // <integer index> => <ISO code>
    $configured_countries = is_array($configured_countries) ? $configured_countries : array();
    $supported_countries = _location_supported_countries();

    // <ISO code> => <English name>
    $configured_countries_associative = array();
    foreach ($configured_countries as $country_code) {
      if (array_key_exists($country_code, $supported_countries)) {
        $configured_countries_associative[$country_code] = $supported_countries[$country_code];
      }
    }
    asort($configured_countries_associative);
  }
  return $configured_countries_associative;
}