Index: mappers/location.inc =================================================================== RCS file: mappers/location.inc diff -N mappers/location.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mappers/location.inc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,55 @@ + 0) { + $subfields = $settings['form']['fields']; + if ($subfields['locpick']['collect']) { + $subfields['locpick][user_latitude'] = $subfields['locpick']; + $subfields['locpick][user_longitude'] = $subfields['locpick']; + } + foreach ($subfields as $subfield => $values) { + if ($values['collect']) { + $targets[ locations . ':' . $subfield] = array( + 'name' => t('Location module (!label)', array('!label' => $subfield)), + 'callback' => 'location_feeds_set_target', + 'description' => t('The !label for the location of the node.', array('!label' => $subfield)), + ); + + } + } + } +} + +function location_feeds_set_target($node, $target, $value) { + list($field_name, $sub_field) = split(':', $target); + if (strpos($sub_field, '][') > 0) { + // TODO : this should be done better but it works + list($sub_field, $last_field) = split('\]\[', $sub_field, 2); + } + if (is_array($value)) { + foreach ($value as $i => $val) { + if (isset($last_field)) { + $node->locations[$i][$sub_field][$last_field] = $val; + } + else { + $node->locations[$i][$sub_field] = $val; + } + } + } else { + $node->locations[0][$sub_field] = $value; + } + return $node; +} Index: mappers/location_cck.inc =================================================================== RCS file: mappers/location_cck.inc diff -N mappers/location_cck.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mappers/location_cck.inc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,64 @@ + $field) { + if (in_array($field['type'], array('location'))) { + $subfields = array( + 'street' => 'street', + 'city' => 'city', + 'province' => 'state/province', + 'postal_code' => 'postal/zip code', + 'locpick][user_latitude' => 'latitude', + 'locpick][user_longitude' => 'longitude', + ); + $name = isset($field['widget']['label']) ? $field['widget']['label'] : $field_name; + foreach ($subfields as $subfield => $label) { + $targets[$field_name .':' . $subfield] = array( + 'name' => t('!field_name (!label)', array('!field_name' => $name, '!label' => $label)), + 'callback' => 'location_cck_feeds_set_target', + 'description' => t('The !label for the CCK !name field of the node.', array('!name' => $name, '!label' => $label)), + ); + } + } + } + } +} + +/** + * Settings the mapping values for location CCK + */ + +function location_cck_feeds_set_target($node, $target, $value) { + list($field_name, $sub_field) = split(':', $target); + + if (strpos($sub_field, '][') > 0) { + // TODO : this should be done better but it works + list($sub_field, $last_field) = split('\]\[', $sub_field, 2); + } + if (is_array($value)) { + foreach ($value as $i => $val) { + if (isset($last_field)) { + $node->{$field_name}[$i][$sub_field][$last_field] = $val; + } + else { + $node->{$field_name}[$i][$sub_field] = $val; + } + } + } else { + $node->{$field_name}[0][$sub_field] = $value; + } + return $node; +}