You are here

function location_node_import_fields in Node import 6

Same name and namespace in other branches
  1. 5 supported/location.inc \location_node_import_fields()

Implementation of hook_node_import_fields().

File

supported/location/location.inc, line 11
Support file for contrib Location module.

Code

function location_node_import_fields($type) {
  $fields = array();
  if (($node_type = node_import_type_is_node($type)) !== FALSE) {
    $settings = variable_get('location_settings_node_' . $node_type, array());
    if (isset($settings['multiple']['max']) && $settings['multiple']['max'] > 0) {
      $fields['location:latitude'] = array(
        'title' => t('Latitude'),
        'group' => t('Location'),
        'has_multiple' => $settings['multiple']['max'] > 1,
      );
      $fields['location:longitude'] = array(
        'title' => t('Longitude'),
        'group' => t('Location'),
        'has_multiple' => $settings['multiple']['max'] > 1,
      );
      foreach (location_field_names() as $fieldname => $fieldtitle) {
        if ($settings['form']['fields'][$fieldname]['collect']) {
          $fields['location:' . $fieldname] = array(
            'title' => $fieldtitle,
            'group' => t('Location'),
            'has_multiple' => $settings['multiple']['max'] > 1,
            'map_required' => $settings['multiple']['min'] > 0,
            'default_value' => $settings['form']['fields'][$fieldname]['default'],
            'weight' => $settings['form']['fields'][$fieldname]['weight'],
          );
          switch ($fieldname) {
            case 'name':
            case 'street':
            case 'additional':
            case 'city':
            case 'province':
            case 'postal_code':
              break;
            case 'country':
              $fields['location:' . $fieldname]['allowed_values'] = array_merge(array(
                'xx' => 'NOT LISTED',
              ), location_get_iso3166_list());
              break;
          }
        }
      }
    }
  }
  return $fields;
}