Index: mappers/feedapi_mapper_phone.inc
===================================================================
RCS file: mappers/feedapi_mapper_phone.inc
diff -N mappers/feedapi_mapper_phone.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mappers/feedapi_mapper_phone.inc	31 Jan 2009 17:49:22 -0000
@@ -0,0 +1,49 @@
+<?php
+// $Id$
+
+/**
+ * On behalf implementation of hook_feedapi_mapper for phone.module (CCK).
+ * Phone field module available at http://drupal.org/project/phone
+ * based on feedapi_mapper_link and feedapi_mapper_content.inc
+ *
+ * @param string $op
+ * @param Drupal node $node
+ * @param string $field_name
+ * @param string, number or array of string or number $feed_element
+ * @param string or number as id $sub_field
+ *
+ */
+function phone_feedapi_mapper($op, $node, $field_name, $feed_element = array(), $sub_field = '') {
+  // Test for the node field that we would like to map to.
+  if (strpos($field_name, 'field_') === 0) {
+    // List all supported phone types.
+    $phone_cck_types = array('fr_phone', 'it_phone', 'ca_phone', 'cr_phone', 'uk_phone', 'ru_phone', 'es_phone', 'au_phone', 'cs_phone', 'hu_phone');
+    if ($op == 'describe') {
+      if (feedapi_mapper_content_is_cck_type($field_name, $phone_cck_types)) {
+        return t('Maps a phone number to this phone CCK field.');
+      }
+      // Describe what we are doing in this mapper. This shows up as help text on the mapping page.
+    }
+    else if ($op == 'list') {
+      if (feedapi_mapper_content_is_cck_type($field_name, $phone_cck_types)) {
+        return TRUE;
+      }
+      // Here we are being asked to list sub fields we would like to map to.
+      // In this case, we only map to the CCK field or not, so we return just TRUE.
+      return FALSE;
+    }
+    else if ($op == 'map') {
+      // Here is where the actual mapping happens.
+      // When we are called at this point, $field_name contains the name of the field the user has
+      // decided to map to and $field_element is the feed item element the user has decided to map.
+      // We just need to put the two things together. The data structure here depends a lot on
+      // CCK. We stick the value in $feed_element into $node->$field_name[0]['value'].
+      if (!is_array($feed_element)) {
+        $field = $node->$field_name;
+        $field[0]['value'] = $feed_element;
+        $node->$field_name = $field;
+        return $node;
+      }
+    }
+  }
+}
