function countries_field_formatter_settings_form in Countries 8
Same name and namespace in other branches
- 7.2 countries.fields.inc \countries_field_formatter_settings_form()
Implements hook_field_formatter_settings_form().
File
- ./
countries.fields.inc, line 176 - All field related code.
Code
function countries_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = (array) $display['settings'];
$element = array();
if ($display['type'] == 'country_icon' && module_exists('countryicons')) {
$settings += array(
'countryiconset' => '',
'property' => '',
);
$version = function_exists('countryicons_api_version') ? countryicons_api_version() : '1.0';
$options = array();
foreach (countryicons_get_iconsets() as $iconset) {
$iconset = (array) $iconset;
// The only diff between versions 1 & 2 of countryicons is the key value.
$key = version_compare("{$version}", '2.0') >= 0 ? $iconset['key'] : $iconset['name'];
$name = version_compare("{$version}", '2.0') >= 0 ? $iconset['name'] : $iconset['description'];
$options['icon_' . $key] = t('Icon: @country_icon_set', array(
'@country_icon_set' => empty($name) ? $key : $name,
));
if (!empty($iconset['css_sprite'])) {
$options['sprite_' . $key] = t('Icon sprite: @country_icon_set', array(
'@country_icon_set' => empty($name) ? $key : $name,
));
}
}
$element['countryiconset'] = array(
'#type' => 'select',
'#title' => t('Country icon source'),
'#options' => $options,
'#default_value' => $settings['countryiconset'],
);
$properties = countries_core_properties();
$properties['continent_code'] = t('Continent code');
$element['property'] = array(
'#type' => 'select',
'#title' => t('Icon suffix'),
'#options' => array(
'' => t('-- None --'),
) + $properties,
'#default_value' => $settings['property'],
);
}
return $element;
}