function getlocations_get_countries_list in Get Locations 7
Same name and namespace in other branches
- 7.2 getlocations.module \getlocations_get_countries_list()
Fetch a list of the core Drupal list of countries. from location module
Parameters
bool $upper Default uppercase:
Return value
array The countries array
13 calls to getlocations_get_countries_list()
- getlocations_blocks_country_autocomplete in modules/
getlocations_blocks/ getlocations_blocks.module - autocomplete for country
- getlocations_blocks_country_get in modules/
getlocations_blocks/ getlocations_blocks.module - getlocations_fields_country_autocomplete in modules/
getlocations_fields/ getlocations_fields.functions.inc - autocomplete for country
- getlocations_fields_element_country in modules/
getlocations_fields/ getlocations_fields.functions.inc - getlocations_fields_field_widget_form in modules/
getlocations_fields/ getlocations_fields.module - Implements hook_field_widget_form(). Return the form for a single field widget.
File
- ./
getlocations.module, line 5838 - getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_get_countries_list($upper = TRUE, $only_continents = '', $only_countries = '') {
if (module_exists('countries')) {
$filter = array(
'enabled' => COUNTRIES_ENABLED,
);
if ($only_countries) {
$only_countries = drupal_strtoupper($only_countries);
$oc = explode(',', $only_countries);
if (!empty($oc)) {
$filter['countries'] = $oc;
}
}
elseif (is_array($only_continents)) {
$oc = array();
foreach ($only_continents as $v) {
$oc[] = $v;
}
if (!empty($oc)) {
$filter['continents'] = $oc;
}
}
$countries = countries_get_countries('name', $filter);
}
else {
include_once DRUPAL_ROOT . '/includes/locale.inc';
// Statically cache a version of the core Drupal list of countries
$countries =& drupal_static(__FUNCTION__);
if (!isset($countries) || empty($countries)) {
$countries = country_get_list();
}
}
if (!$upper) {
$countries = array_change_key_case($countries, CASE_LOWER);
}
return $countries;
}