You are here

function _location_taxonomize_create_term_name in Location Taxonomize 7.2

Same name and namespace in other branches
  1. 7 location_taxonomize.module \_location_taxonomize_create_term_name()

Helper function to create the name for a term to be saved, considering all the config options

1 call to _location_taxonomize_create_term_name()
location_taxonomize_process_item in ./location_taxonomize.module
Determines if a location needs to be taxonomized. If so, it saves the appropriate terms Returns an array containing two items: the first is the number of new terms saved, and the second is an array of all the terms that correspond to this object,…

File

./location_taxonomize.module, line 345

Code

function _location_taxonomize_create_term_name($hlevel_name, &$location, &$settings) {

  // convert this hlevel_name to an internal primary field name if necessary
  $field_name = location_taxonomize_convert_field_name($hlevel_name);
  switch ($field_name) {
    case 'country':
      if (empty($location[$hlevel_name])) {
        $name = $settings['na_text'];
      }
      elseif ($settings['naming']['country'] == 'name') {
        $name = $location[location_taxonomize_source_field_name('country_name')];
      }
      elseif ($location[$hlevel_name] == 'us' && $settings['naming']['usa']) {
        $name = 'USA';
      }
      else {
        $name = drupal_strtoupper($location[$hlevel_name]);
      }
      break;
    case 'province':
      $us_states = location_taxonomize_us_states();
      if (empty($location[$hlevel_name])) {
        $name = $settings['na_text'];
      }
      elseif ($settings['naming']['province'] == 'name') {
        if (!empty($location[location_taxonomize_source_field_name('province_name')])) {
          $name = $location[location_taxonomize_source_field_name('province_name')];
        }
        else {
          if (isset($us_states[strtoupper($location[$hlevel_name])])) {
            $name = $us_states[strtoupper($location[$hlevel_name])];
          }
          else {
            $name = $location[$hlevel_name];
          }
        }
      }
      else {
        $name = $location[$hlevel_name];
      }
      break;
    default:
      if (empty($location[$hlevel_name])) {
        $name = $settings['na_text'];
      }
      else {
        $name = $location[$hlevel_name];
      }
      break;
  }
  return $name;
}