You are here

function _location_taxonomize_create_term_name in Location Taxonomize 7

Same name and namespace in other branches
  1. 7.2 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_loc in ./location_taxonomize.module
Determines if a location needs to be taxonomized. If so, it saves the appropriate terms Returns the number of terms added

File

./location_taxonomize.module, line 291

Code

function _location_taxonomize_create_term_name($hlevel_name, &$location, &$settings) {
  switch ($hlevel_name) {
    case 'country':
      if (empty($location['country'])) {
        $name = $settings['na_text'];
      }
      elseif ($settings['naming']['country'] == 'name') {
        $name = $location['country_name'];
      }
      elseif ($location['country'] == 'us' && $settings['naming']['usa']) {
        $name = 'USA';
      }
      else {
        $name = drupal_strtoupper($location['country']);
      }
      break;
    case 'province':
      if (empty($location['province'])) {
        $name = $settings['na_text'];
      }
      elseif ($settings['naming']['province'] == 'name') {
        $name = $location['province_name'];
      }
      else {
        $name = $location['province'];
      }
      break;
    default:
      if (empty($location[$hlevel_name])) {
        $name = $settings['na_text'];
      }
      else {
        $name = $location[$hlevel_name];
      }
      break;
  }
  return $name;
}