You are here

public function UcAddressesUcCountryFieldHandler::getMappingTargets in Ubercart Addresses 7

Overrides UcAddressesFieldHandler::getMappingTargets().

The country field has some extra mapping targets.

Overrides UcAddressesFieldHandler::getMappingTargets

File

handlers/ubercart.handlers.inc, line 343
Field handlers for Ubercart core address fields: first_name, last_name, company, etc.

Class

UcAddressesUcCountryFieldHandler
Class for the Ubercart country field.

Code

public function getMappingTargets() {
  $targets = parent::getMappingTargets();

  // Formats ending on "if" have no use for Feeds.
  unset($targets['country:country_name_if']);
  unset($targets['country:country_code2_if']);
  unset($targets['country:country_code3_if']);

  // Specify clearer names and descriptions.
  $targets['country:country_name']['name'] = t('Country name (@language)', array(
    '@language' => 'English',
  ));
  $targets['country:country_code2']['name'] = t('Country code 2');
  $targets['country:country_code3']['name'] = t('Country code 3');
  $targets['country']['description'] = t('Country ID as known to Ubercart');
  $targets['country:country_name']['description'] = t('The name of the country in English.');

  // Add support for countries in native language.
  $targets['country:country_name:current'] = array(
    'name' => t('Country name (current language)'),
    'description' => t('Name of the country in the current language. Country names are expected to be in the language that is active when importing addresses. For example, if are you viewing the site in Dutch when importing addresses, country names should be in Dutch. If you then switch the site to French, country names are expected to be in French.'),
  );
  $languages = language_list();
  foreach ($languages as $key => $language) {
    if ($key == 'en') {

      // English is already handled.
      continue;
    }
    $targets['country:country_name:' . $key] = array(
      'name' => t('Country name (@language)', array(
        '@language' => $language->name,
      )),
      'description' => t('The name of the country in @language-native', array(
        '@language-native' => $language->native,
      )),
    );
  }
  return $targets;
}