Index: i18nsync/i18nsync.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18nsync/i18nsync.module,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 i18nsync.module
--- i18nsync/i18nsync.module	8 Aug 2008 20:11:06 -0000	1.1.2.7
+++ i18nsync/i18nsync.module	8 Aug 2008 20:22:36 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: i18nsync.module,v 1.1.2.7 2008/08/08 20:11:06 drewish Exp $
+// $Id: i18nsync.module,v 1.1.2.6 2008/06/24 11:17:34 jareyero Exp $
 
 /**
  * @file
@@ -143,8 +143,14 @@ function i18nsync_nodeapi(&$node, $op, $
  * Prepare node translation. Copy over sincronizable fields
  */
 function i18nsync_prepare_translation(&$node, $source, $field_list){
+    // Collect info on any CCK fields.
+  $content = module_invoke('content', 'types', $node->type);
+
   foreach ($field_list as $field) {
     if (empty($source->$field)) continue;
+    // CCK handles the prepare op for its own fields.
+    if (isset($content['fields'][$field])) continue;
+
     switch($field) {
       case 'taxonomy':
         i18nsync_taxonomyfield($node, $source);
@@ -178,41 +184,67 @@ function i18nsync_prepare_translation(&$
 function i18nsync_node_translation($node, $translation, $fields, $op) {
   // Load full node, we need all data here
   $translation = node_load($translation->nid);
+
+  // Collect info on any CCK fields.
+  $content = module_invoke('content', 'types', $node->type);
+
   foreach ($fields as $field) {
-    switch($field) {
-      case 'taxonomy': // Do nothing it has already been syncd
-        i18nsync_taxonomyfield($translation, $node);
-        break;
-      case 'parent': // Book outlines, translating parent page if exists
-      case 'iid': // Attached image nodes
-        i18nsync_node_translation_attached_node($node, $translation, $field);
-        break;
-      case 'files':
-        // Sync existing attached files
-        foreach ($node->files as $fid => $file) {
-          if (isset($translation->files[$fid])) {
-            $translation->files[$fid]->list = $file->list;
-          } else {
-            // New file. Create new revision of file for the translation
-            $translation->files[$fid] = $file;
-            // If it's a new node revision it will just be created, but if it's not
-            // we have to update the table directly. The revision field was before this one in the list
-            if (!isset($translation->revision) || !$translation->revision) {
-              db_query("INSERT INTO {upload} (fid, nid, vid, list, description) VALUES (%d, %d, %d, %d, '%s')", $file->fid, $translation->nid, $translation->vid, $file->list, $file->description);
+    // Check for CCK fields first
+    if (isset($content['fields'][$field])) {
+      dvm($node->$field);
+      switch ($content['fields'][$field]['type']) {
+        // TODO take type specific actions.
+        case 'filefield':
+        case 'imagefield':
+          dvm($content['fields'][$field]);
+          break;
+
+        default:
+          // For fields that don't need special handling
+          if (isset($node->$field)) {
+            $translation->$field = $node->$field;
+          }
+      }
+      // Skip over the regular handling.
+      continue;
+    }
+    else {
+      switch($field) {
+        case 'taxonomy': // Do nothing it has already been syncd
+          i18nsync_taxonomyfield($translation, $node);
+          break;
+        case 'parent': // Book outlines, translating parent page if exists
+        case 'iid': // Attached image nodes
+          i18nsync_node_translation_attached_node($node, $translation, $field);
+          break;
+        case 'files':
+          // Sync existing attached files
+          foreach ($node->files as $fid => $file) {
+            if (isset($translation->files[$fid])) {
+              $translation->files[$fid]->list = $file->list;
+            } else {
+              // New file. Create new revision of file for the translation
+              $translation->files[$fid] = $file;
+              // If it's a new node revision it will just be created, but if it's not
+              // we have to update the table directly. The revision field was before this one in the list
+              if (!isset($translation->revision) || !$translation->revision) {
+                db_query("INSERT INTO {upload} (fid, nid, vid, list, description) VALUES (%d, %d, %d, %d, '%s')", $file->fid, $translation->nid, $translation->vid, $file->list, $file->description);
+              }
             }
           }
-        }
-        // Drop removed files
-        foreach ($translation->files as $fid => $file) {
-          if (!isset($node->files[$fid])) {
-            $translation->files[$fid]->remove = TRUE;
+          // Drop removed files
+          foreach ($translation->files as $fid => $file) {
+            if (!isset($node->files[$fid])) {
+              $translation->files[$fid]->remove = TRUE;
+            }
           }
-        }
-        break;
-      default: // For fields that don't need special handling
-        if (isset($node->$field)) {
-          $translation->$field = $node->$field;
-        }
+          break;
+        default:
+          // For fields that don't need special handling
+          if (isset($node->$field)) {
+            $translation->$field = $node->$field;
+          }
+      }
     }
   }
   node_save($translation);
@@ -310,7 +342,6 @@ function i18nsync_node_available_fields(
   }
 
   // Get CCK fields
-  /* Disabled until there's a stable version of CCK + views
   if (($content = module_invoke('content', 'types', $type)) && isset($content['fields'])) {
     // Get context information
     $info = module_invoke('content', 'fields', NULL, $type);
@@ -319,25 +350,5 @@ function i18nsync_node_available_fields(
       $fields['cck']['#options'][$data['field_name']] = $data['widget']['label'];
     }
   }
-  */
   return $fields;
 }
-
-/*
- * Sample CCK field definition for Drupal 5
-'field_text' =>
-    array
-      'field_name' => string 'field_text' (length=10)
-      'type' => string 'text' (length=4)
-      'required' => string '0' (length=1)
-      'multiple' => string '1' (length=1)
-      'db_storage' => string '0' (length=1)
-      'text_processing' => string '0' (length=1)
-      'max_length' => string '' (length=0)
-      'allowed_values' => string '' (length=0)
-      'allowed_values_php' => string '' (length=0)
-      'widget' =>
-        array
-          ...
-      'type_name' => string 'test' (length=4)
-*/
