You are here

function countries_field_formatter_settings_summary in Countries 7.2

Same name and namespace in other branches
  1. 8 countries.fields.inc \countries_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary().

File

./countries.fields.inc, line 133
All field related code.

Code

function countries_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = (array) $display['settings'];
  $settings += array(
    'countryiconset' => '',
    'property' => '',
  );
  $summary = '';
  if ($display['type'] == 'country_icon' && module_exists('countryicons')) {
    $version = function_exists('countryicons_api_version') ? countryicons_api_version() : '1.0';
    $options = array();
    foreach (countryicons_get_iconsets() as $iconset) {
      $iconset = (array) $iconset;
      $key = version_compare("{$version}", '2.0') >= 0 ? $iconset['key'] : $iconset['name'];
      $name = version_compare("{$version}", '2.0') >= 0 ? $iconset['name'] : $iconset['description'];
      if ('icon_' . $key == $settings['countryiconset']) {
        $summary = t('<strong>Icon:</strong> @country_icon_set', array(
          '@country_icon_set' => empty($name) ? $key : $name,
        ));
        break;
      }
      elseif ('sprite_' . $key == $settings['countryiconset']) {
        $summary = t('<strong>Icon sprite:</strong> @country_icon_set', array(
          '@country_icon_set' => empty($name) ? $key : $name,
        ));
        break;
      }
    }
    if (empty($summary)) {
      $summary = t('Missing icon or spirte plugin');
    }
    if (!empty($settings['property'])) {
      $properties = countries_core_properties();
      $properties['continent_code'] = t('Continent code');
      $summary .= '<br/>' . t('<strong>Suffix:</strong> %property', array(
        '%property' => $properties[$settings['property']],
      ));
    }
  }
  return $summary;
}