? file_import-remove-require-node-to-simple-import-as-assset.patch
Index: file_import.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/file_import/file_import.module,v
retrieving revision 1.2.2.2
diff -u -p -r1.2.2.2 file_import.module
--- file_import.module	21 Apr 2009 00:00:49 -0000	1.2.2.2
+++ file_import.module	24 Dec 2010 14:24:01 -0000
@@ -110,7 +110,7 @@ function file_import_access_node($node) 
  */
 function file_import_form($form_state, $node = NULL) {
   $form = array();
-  
+
   $dirpath = variable_get('file_import_output_path', file_directory_path());
   if (!file_check_directory($dirpath)) {
     drupal_set_message(t("You need to configure the output directory on the files import module's <a href='!admin-settings-file_import'>settings page</a>.", array('!admin-settings-file_import' => url('admin/settings/file_import'))), 'error');
@@ -210,7 +210,7 @@ function file_import_form($form_state, $
       '#value' => t('Set for selected rows'),
       '#id' => 'node_select_button',
     );
-    
+
     $form += file_import_title_operations_form();
 
     $form['buttons']['submit'] = array(
@@ -304,7 +304,8 @@ function file_import_form_validate($form
     }
 
     if (!is_numeric($node_index)) {
-      form_set_error('nid]['. $index, t('"!nid" is not valid node ID.', array('!nid' => $form_state['values']['nid'][$index])));
+      //form_set_error('nid]['. $index, t('"!nid" is not valid node ID.', array('!nid' => $form_state['values']['nid'][$index])));
+        $node_index = 0;
     }
   }
 }
@@ -317,11 +318,12 @@ function file_import_form_submit($form, 
   if (file_check_directory($dirpath)) {
     $i = 0;
     $list = variable_get('upload_list_default', TRUE);
+    $empty_object =(object) array('nid' => -1 , 'vid' => -1);
     // Array for node objects
     $nodes = array();
     foreach (array_filter($form_state['values']['import_file']) as $index) {
       // Current nid
-      $node_index = $form_state['values']['nid'][$index];
+      $node_index = $form_state['values']['nid'][$index] ? $form_state['values']['nid'][$index] : -1;
       if (!is_numeric($node_index)) {
         preg_match('|^\[#([0-9]*?)\]|', $node_index, $matches);
         $node_index = $matches[1];
@@ -332,7 +334,7 @@ function file_import_form_submit($form, 
         if (empty($nodes[$node_index])) {
           $node = node_load($node_index);
           if (file_import_access_node($node)) {
-            $nodes[$node_index] = $node;
+            $nodes[$node_index] = $node ? $node : $empty_object;
           }
         }
 
@@ -372,8 +374,8 @@ function file_import_form_submit($form, 
             if (!db_error()) {
               $fid = db_last_insert_id('files', 'fid');
               db_query("INSERT INTO {upload} (fid, vid, description, list) VALUES (%d, %d, '%s', %d)",
-                $fid, 
-                $vid, 
+                $fid,
+                $vid,
                 $form_state['values']['title'][$index],
                 $list);
                 $i++;
@@ -514,42 +516,41 @@ function file_import_autocomplete($strin
       $nids['[#'. $node['nid'] .'] '. $node['title']] = '[#'. $node['nid'] .'] '. $node['title'];
     }
   }
-  
+
   drupal_json($nids);
 }
 
 /**
  * Utility function for determining contnt type of the file.
  */
-function content_type($name) { 
-    // Defines the content type based upon the extension of the file 
-    $contenttype  = 'application/octet-stream'; 
-    $contenttypes = array( 'html' => 'text/html', 
-                           'htm'  => 'text/html', 
-                           'txt'  => 'text/plain', 
-                           'gif'  => 'image/gif', 
-                           'jpg'  => 'image/jpeg', 
-                           'png'  => 'image/png', 
-                           'sxw'  => 'application/vnd.sun.xml.writer', 
-                           'sxg'  => 'application/vnd.sun.xml.writer.global', 
-                           'sxd'  => 'application/vnd.sun.xml.draw', 
-                           'sxc'  => 'application/vnd.sun.xml.calc', 
-                           'sxi'  => 'application/vnd.sun.xml.impress', 
-                           'xls'  => 'application/vnd.ms-excel', 
-                           'ppt'  => 'application/vnd.ms-powerpoint', 
-                           'doc'  => 'application/msword', 
-                           'rtf'  => 'text/rtf', 
-                           'zip'  => 'application/zip', 
-                           'mp3'  => 'audio/mpeg', 
-                           'pdf'  => 'application/pdf', 
-                           'tgz'  => 'application/x-gzip', 
-                           'gz'   => 'application/x-gzip', 
-                           'vcf'  => 'text/vcf' ); 
-
-    $name = ereg_replace("§", " ", $name); 
-    foreach ($contenttypes as $type_ext => $type_name) { 
-        if (preg_match ("/$type_ext$/i",  $name)) $contenttype = $type_name; 
-    } 
-    return $contenttype; 
-}
-
+function content_type($name) {
+    // Defines the content type based upon the extension of the file
+    $contenttype  = 'application/octet-stream';
+    $contenttypes = array( 'html' => 'text/html',
+                           'htm'  => 'text/html',
+                           'txt'  => 'text/plain',
+                           'gif'  => 'image/gif',
+                           'jpg'  => 'image/jpeg',
+                           'png'  => 'image/png',
+                           'sxw'  => 'application/vnd.sun.xml.writer',
+                           'sxg'  => 'application/vnd.sun.xml.writer.global',
+                           'sxd'  => 'application/vnd.sun.xml.draw',
+                           'sxc'  => 'application/vnd.sun.xml.calc',
+                           'sxi'  => 'application/vnd.sun.xml.impress',
+                           'xls'  => 'application/vnd.ms-excel',
+                           'ppt'  => 'application/vnd.ms-powerpoint',
+                           'doc'  => 'application/msword',
+                           'rtf'  => 'text/rtf',
+                           'zip'  => 'application/zip',
+                           'mp3'  => 'audio/mpeg',
+                           'pdf'  => 'application/pdf',
+                           'tgz'  => 'application/x-gzip',
+                           'gz'   => 'application/x-gzip',
+                           'vcf'  => 'text/vcf' );
+
+    $name = ereg_replace("§", " ", $name);
+    foreach ($contenttypes as $type_ext => $type_name) {
+        if (preg_match ("/$type_ext$/i",  $name)) $contenttype = $type_name;
+    }
+    return $contenttype;
+}
\ No newline at end of file
