locations[$x-1][$field] = $feed_element; } } /** * On behalf implementation of hook_feedapi_mapper() for location module. * * @see hook_feedapi_mapper() */ function location_feedapi_mapper($op, $node, $feed_element = array(), $field_name = '', $sub_field = '') { $num_locations = variable_get("location_maxnum_".$node->type,0); $field_array = array( 'name' => t('Name'), 'street' => t('Street'), 'additional' => t('Additional'), 'city' => t('City'), 'postal_code' => t('Postal Code'), 'province' => t('State Code'), 'province_name' => t('State [full name]'), 'country' => t('Country Code'), 'country_name' => t('Country [full name]'), 'latitude' => t('Latitude'), 'longitude' => t('Longitude'), 'phone' => t('Phone') ); if ($op == 'describe') { return t('Maps pairs of geographic coordinates to the location of a node.'); } else if ($op == 'list') { for($x=1; $x<=$num_locations; $x++){ foreach($field_array as $field_id => $field_desc){ $fields['Locations '.$x][$field_id.$x] = $field_desc; } } //$fields = array('Locations' => $sub_fields); return $fields; } else if ($op == 'map') { /* $loc_number = substr($sub_field, -1); $node->locations[0]['feedapi_temp'] = array(); $node->locations[0]['feedapi_temp']['fieldname'] = $sub_field; $node->locations[0]['feedapi_temp']['feedelem'] = $feed_element; // cast this array as an object for easier use later $loc = (object) $node->locations[0]; */ // for some reason location module will only except a complete array for these values now, so we construct the entire array here // we also run all mapped values through the feedapi_test_location_var function to keep from overwriting prior set values // TODO: make this do multiple values and cck location fields for($x = 1; $x < $num_locations; $x++){ $primary = $x == 1 ? 1 : 0; foreach($field_array as $field_name => $field_desc){ feedapi_test_location_var($field_name, $x, $sub_field, $feed_element, $node); } $node->locations[$x-1]['source'] = '0'; $node->locations[$x-1]['is_primary'] = $primary; } return $node; } }