Index: supported/cck/content.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_import/supported/cck/Attic/content.inc,v
retrieving revision 1.1.2.2.2.6
diff -u -p -r1.1.2.2.2.6 content.inc
--- supported/cck/content.inc	17 Mar 2008 13:48:12 -0000	1.1.2.2.2.6
+++ supported/cck/content.inc	24 Jun 2008 17:00:47 -0000
@@ -58,7 +58,6 @@ function content_node_import_fields($typ
 function content_node_import_prepare(&$node, $preview = FALSE) {
   $errors = array();
   $globals = $node->content_import_node;
-  unset($node->content_import_node);
 
   $types = (array) content_types();
   if (isset($types[$node->type])) {
@@ -86,6 +85,7 @@ function content_node_import_prepare(&$n
         }
 
         foreach ($values as $delta => $value) {
+          $add_field=TRUE;
           switch ($field['type']) {
             case 'date':
             case 'datestamp':
@@ -156,6 +156,27 @@ function content_node_import_prepare(&$n
             case 'number_decimal':
               $value = floatval($value);
               break;
+              
+            case 'image':
+              if ($column =='fid' && !empty($node->$dummy_name)){
+                $node->$dummy_name=file_create_path($field['widget']['image_path'].'/'.$value);
+                $p=$node->$dummy_name;
+                if (!$node->$dummy_name ) {
+                  $errors[]=t('This file does not exist: ').$value;
+                  unset($node->$dummy_name);
+                }
+                else {
+                  if (!file_exists($node->$dummy_name)) { 
+                    $errors[]=t('This file does not exist, checked by file_exists: ').$value;
+                    unset($node->$dummy_name);
+                  }
+                }
+                // your content filters must allow images!
+                if ($preview){
+                  $node->body=theme('image', $node->$dummy_name, $value, $value);
+                }
+              }
+              break;
           }
 
           // Set the correct node field values.
@@ -167,8 +188,7 @@ function content_node_import_prepare(&$n
           }
         }
 
-        // Unset the dummy column value.
-        unset($node->$dummy_name);
+      
       }
 
     }
@@ -177,6 +197,74 @@ function content_node_import_prepare(&$n
   return $errors;
 }
 
+/*
+ * post-process the node, adding files
+ */
+function content_node_import_postprocess(&$node, $preview = FALSE, $any_errors=FALSE){
+  // no post-node-processing on preview.
+  if ($preview) return;
+
+  $files=array();
+  $types = (array) content_types();
+  if (isset($types[$node->type])) {
+    $content_type = $types[$node->type];
+    foreach ($content_type['fields'] as $fieldname=>$field) {
+      $dummy_name="{$fieldname}_fid";
+      if (isset($node->$dummy_name)){ // fid is set.
+        switch($field['type']){
+          case 'image':
+            if (!isset($files[$fieldname])){ // first pass, or last time failed.
+              $files[$fieldname]=array(
+                'fid'=>db_next_id('{files}_fid'),
+                'filepath'=> $node->$dummy_name,
+                'filename'=>basename($node->$dummy_name),
+                'filemime'=>mime_content_type($node->$dummy_name),
+                'filesize'=>filesize($node->$dummy_name),
+              );
+
+              $ok=db_query("INSERT into {files} (fid, nid, filename, filepath, filemime, filesize)
+                   VALUES (%d, %d, '%s','%s','%s',%d)",
+                  $files[$fieldname]['fid'], $node->nid, $files[$fieldname]['filename'], $files[$fieldname]['filepath'], $files[$fieldname]['filemime'], $files[$fieldname]['filesize'] );
+
+              if (!$ok){
+                // this will try again on the next pass of this loop, and finally not add it to the files array.
+                unset($files[$fieldname]);
+              }
+            }
+            break;
+        }
+      }
+    }
+  }
+
+  // second pass, save images
+  foreach($files as $fieldname=>$file){
+    $node->$fieldname=array(array(
+      'fid'=>$file['fid'],
+    ));
+    $node->{$fieldname.'_fid'}=$file['fid'];
+    $node->{$fieldname}[0]['alt']=(isset($node->{$fieldname.'_alt'}))? $node->{$fieldname.'_alt'} : $file['filename'];
+    $node->{$fieldname}[0]['title']=(isset($node->{$fieldname.'_title'}))? $node->{$fieldname.'_title'} : $file['filename'];
+  }
+  
+        
+  // re-save node with new file data
+  node_save($node);
+  // Unset the dummy column value.
+  unset($node->$dummy_name);
+}
+
+// add support for depracated function
+if (!function_exists('mime_content_type')) {
+    function mime_content_type($filename) {
+        $finfo    = finfo_open(FILEINFO_MIME);
+        $mimetype = finfo_file($finfo, $filename);
+        finfo_close($finfo);
+        return $mimetype;
+    }
+}
+
+
 /**
  * Implementation of hook_node_import_global().
  */
@@ -199,8 +287,10 @@ function content_node_import_global($typ
         $form['content_import_node']['fields'][$field['field_name'] .'_'. $column] = array(
           '#type' => 'textfield',
           '#title' => $field['widget']['label'] .' '. $column,
-          '#default_value' => $value,
         );
+        if (!empty($field['widget']['default_value'][0]['value'])){
+          $form['content_import_node']['fields'][$field['field_name'] .'_'. $column]['#default_value']=$field['widget']['default_value'][0]['value'];
+        }
       }
     }
   }
