You are here

function getlocations_location_taxonomize_fixup in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_location_taxonomize/getlocations_location_taxonomize.inc \getlocations_location_taxonomize_fixup()

Fixup the country name and province name fields

1 call to getlocations_location_taxonomize_fixup()
getlocations_location_taxonomize_element_submitted in modules/getlocations_location_taxonomize/getlocations_location_taxonomize.module
A submit handler for forms that contain an getlocations_fields widget

File

modules/getlocations_location_taxonomize/getlocations_location_taxonomize.inc, line 117
getlocations_location_taxonomize.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_location_taxonomize_fixup($location) {
  if (isset($location['country']) && !empty($location['country'])) {
    if (drupal_strlen($location['country']) == 2) {

      // got code, get full name
      $location['country_name'] = getlocations_get_country_name($location['country']);
    }
    else {

      // got full name, get code if possible
      $location['country_name'] = $location['country'];
      $location['country'] = getlocations_get_country_id($location['country_name']);
    }
  }
  else {
    $location['country'] = '';
    $location['country_name'] = '';
  }

  // getlocations does not use codes for provinces
  if (isset($location['province'])) {
    $location['province_name'] = $location['province'];
  }
  else {
    $location['province'] = '';
    $location['province_name'] = '';
  }
  return $location;
}