You are here

function location_get_provinces in Location 7.3

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

Fetch the provinces for a country.

8 calls to location_get_provinces()
location_generate_node_presave in contrib/location_generate/location_generate.module
Implements hook_node_presave().
location_handler_filter_location_province::value_form in handlers/location_handler_filter_location_province.inc
Provide a simple textfield for equality.
location_locationapi in ./location.module
Implements hook_locationapi().
location_province_code in ./location.inc
Get a province code from a code or full name and a country.
location_province_name in ./location.inc
Get the full name of a province code.

... See full list

File

./location.inc, line 575
Public API for the Location module.

Code

function location_get_provinces($country = 'us') {
  $provinces =& drupal_static(__FUNCTION__, array());

  // Current language.
  $lang_code = $GLOBALS['language']->language;
  location_standardize_country_code($country);
  if (!isset($provinces[$country])) {
    if ($cache = cache_get("provinces:{$country}:{$lang_code}", 'cache_location')) {
      $provinces[$country] = $cache->data;
    }
    else {
      location_load_country($country);
      $func = 'location_province_list_' . $country;
      if (function_exists($func)) {
        $provinces[$country] = $func();
        cache_set("provinces:{$country}:{$lang_code}", $provinces[$country], 'cache_location');
      }
    }
  }

  // Invoke hook_location_provinces_alter and
  // hook_location_provinces_COUNTRY_CODE_alter.
  drupal_alter(array(
    'location_provinces',
    'location_provinces_' . $country,
  ), $provinces, $country);
  return isset($provinces[$country]) ? $provinces[$country] : array();
}