You are here

function theme_addressfield_formatter__components in Addressfield Tokens 7

File

./addressfield_tokens.theme.inc, line 110
Theme Controllers.

Code

function theme_addressfield_formatter__components($vars) {
  $loc = $vars['address'];
  $components = $vars['components'];
  $separator = $vars['separator'];
  $out = array();
  foreach ($components as $key) {
    if (!empty($loc[$key])) {
      $out[$key] = $loc[$key];
    }
    elseif ($key == 'country_full' && !empty($loc['country'])) {
      $out[$key] = _addressfield_tokens_country($loc['country']);
    }
    elseif ($key == 'administrative_area_full' && !empty($loc['country']) && !empty($loc['administrative_area'])) {
      $out[$key] = addressfield_tokens_state($loc['country'], $loc['administrative_area']);
    }
  }
  return implode($separator, $out);
}