Index: mappers/nodereference.inc
--- mappers/nodereference.inc No Base Revision
+++ mappers/nodereference.inc Locally New
@@ -0,0 +1,63 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * On behalf implementation of Feeds mapping API for nodereference.module (CCK).
+ *
+ * @todo Support mapping using nid of referenced node.
+ */
+
+/**
+ * Implementation of hook_feeds_node_processor_targets_alter().
+ *
+ * @see FeedsNodeProcessor::getMappingTargets()
+ */
+function nodereference_feeds_node_processor_targets_alter(&$targets, $content_type) {
+  $info = content_types($content_type);
+  $fields = array();
+  if (isset($info['fields']) && count($info['fields'])) {
+    foreach ($info['fields'] as $field_name => $field) {
+      if (in_array($field['type'], array('nodereference'))) {
+        $fields[$field_name] = isset($field['widget']['label']) ? $field['widget']['label'] : $field_name;
+      }
+    }
+  }
+  foreach ($fields as $k => $name) {
+    $targets[$k] = array(
+      'name' => $name,
+      'callback' => 'nodereference_feeds_set_target',
+      'description' => t('The CCK Node Reference !name of the node.', array('!name' => $name)),
+    );
+  }
+}
+
+/**
+ * Implementation of hook_feeds_set_target().
+ *
+ * @param $node
+ *   The target node.
+ * @param $target
+ *   The name of field on the target node to map to.
+ * @param $value
+ *   The value to be mapped.
+ *
+ */
+function nodereference_feeds_set_target($node, $target, $value) {
+  $field = isset($node->$target) ? $node->$target : array();
+
+  // Load field definition
+  $field_info = content_fields($target, $node->type);
+
+  if (!is_array($value)) {
+    $value = array($value);
+  }
+
+  foreach ($value as $v) {
+    if (!is_array($v) && !is_object($v) && !empty($v)) {
+      // Return list of possible exact matches for the title
+      $nids = _nodereference_potential_references($field_info, $v, 'equals');
+      // Use the first element of the returned array
+      $field[] = array('nid' => key($nids));
+    }
+  }
+
+  $node->$target = $field;
+}
