You are here

function _node_import_location_get_province_code in Node import 5

Convert the province from human-readable form to a province code.

1 call to _node_import_location_get_province_code()
location_node_import_prepare in supported/location.inc
Implementation of hook_node_import_prepare().

File

supported/location.inc, line 163

Code

function _node_import_location_get_province_code($province, $country) {
  static $codes = array();
  if (!isset($codes[$country])) {
    $form = _location_province_select_options('', FALSE, $country);
    $codes[$country] = (array) $form['#options'];
  }
  $province = strtolower($province);
  foreach ((array) $codes[$country] as $code => $name) {
    if (in_array(strtolower($code), array(
      $province,
      "{$country}-{$province}",
    )) || $province == strtolower($name)) {
      return $code;
    }
  }
  return '';
}