function _addressfield_country_options_list in Address Field 7
Returns the country list in a format suitable for use as an options list.
7 calls to _addressfield_country_options_list()
- addressfield_default_values in ./
addressfield.module - Returns an array of default values for the addressfield form elements.
- addressfield_field_widget_form in ./
addressfield.module - Implements hook_field_widget_form()
- addressfield_field_widget_settings_form in ./
addressfield.module - Implements hook_field_widget_settings_form()
- addressfield_format_address_generate in plugins/
format/ address.inc - Format callback.
- addressfield_tokens in ./
addressfield.tokens.inc - Implements hook_tokens().
1 string reference to '_addressfield_country_options_list'
- addressfield_data_property_info in ./
addressfield.module - Defines info for the properties of the address field data structure.
File
- ./
addressfield.module, line 919 - Defines a field for attaching country-specific addresses to entities.
Code
function _addressfield_country_options_list($field = NULL, $instance = NULL) {
if (module_exists('countries')) {
$countries = countries_get_countries('name', array(
'enabled' => COUNTRIES_ENABLED,
));
}
else {
require_once DRUPAL_ROOT . '/includes/locale.inc';
$countries = country_get_list();
}
if (isset($field)) {
// If the instance is not specified, loop against all the instances of the field.
if (!isset($instance)) {
$instances = array();
foreach ($field['bundles'] as $entity_type => $bundles) {
foreach ($bundles as $bundle_name) {
$instances[] = field_info_instance($entity_type, $field['field_name'], $bundle_name);
}
}
}
else {
$instances = array(
$instance,
);
}
foreach ($instances as $instance) {
if (!empty($instance['widget']['settings']['available_countries'])) {
$countries = array_intersect_key($countries, $instance['widget']['settings']['available_countries']);
break;
}
}
}
return $countries;
}