You are here

function countries_get_countries in Countries 7

Same name and namespace in other branches
  1. 8 countries.module \countries_get_countries()
  2. 7.2 countries.module \countries_get_countries()

Helper function to load all countries.

6 calls to countries_get_countries()
countries_countries_alter in ./countries.module
Implement hook_countries_alter().
countries_country_expand in ./countries.module
Our process callback to expand the control.
countries_country_lookup in ./countries.module
A helper function to find a country based on any country property.
countries_filter in ./countries.module
countries_get_country in ./countries.module
Helper function to load a country by it's primary key.

... See full list

File

./countries.module, line 292

Code

function countries_get_countries($property = 'all') {
  $countries =& drupal_static(__FUNCTION__, array());
  if (empty($countries)) {
    $cids = db_select('countries_country', 'c')
      ->fields('c', array(
      'cid',
    ))
      ->orderBy('name', 'ASC')
      ->execute()
      ->fetchCol();
    $_countríes = countries_load_multiple($cids);
    foreach ($_countríes as $country) {

      // TODO: I18n
      // countries_localize_country($country);
      $countries[$country->iso2] = $country;
    }
  }
  if ($property == 'all') {
    return $countries;
  }
  $mapped_countries = array();
  foreach ($countries as $country) {
    $mapped_countries[$country->iso2] = $country->{$property};
  }
  return $mapped_countries;
}