From dd0ce4f6c3dd51790567f912e529ef0d66cf1144 Mon Sep 17 00:00:00 2001
From: Silvio <silvio@devlet.com.br>
Date: Fri, 8 Oct 2010 18:17:12 -0300
Subject: Adding mass_image_import_types()

---
 mass_image_import.module | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/mass_image_import.module b/mass_image_import.module
index 54edacf..858fe0b 100644
--- a/mass_image_import.module
+++ b/mass_image_import.module
@@ -42,19 +42,12 @@ function mass_image_import() {
  * Mass import form.
  */
 function mass_image_import_form(&$form_state) {
-  $node_types = node_get_types();
-  $node_codes = array();
-
-  foreach ($node_types as $item) {
-    $node_codes[$item->type] = $item->name;
-  }
-
   $form['node_type'] = array(
     '#type'          => 'select',
     '#title'         => t('Node type'),
-    '#options'       => $node_codes,
-    '#default_value' => variable_get('mass_image_import_nodetype', array()),
-    '#description'   => t('Select node type to import images. In case the node type contains more than one filefield, make sure that the imagefield is the first one.'),
+    '#options'       => mass_image_import_types(),
+    '#default_value' => variable_get('mass_image_import_node_type', array()),
+    '#description'   => t('Select node type to import images. For CCK, if node type contains more than one filefield, make sure that the imagefield is the first one.'),
   );
 
   $form['submit'] = array(
@@ -65,6 +58,23 @@ function mass_image_import_form(&$form_state) {
   return $form;
 }
 
+/**
+ * Return the existing content types.
+ *
+ * @return
+ *   Content types.
+ */
+function mass_image_import_types() {
+  $node_types = node_get_types();
+  $node_codes = array();
+
+  foreach ($node_types as $item) {
+    $node_codes[$item->type] = $item->name;
+  }
+
+  return $node_codes;  
+}
+
 /**
  * Handle post-validation form-submission.
  *
@@ -73,10 +83,10 @@ function mass_image_import_form(&$form_state) {
  */
 function mass_image_import_form_submit($form, &$form_state) {
   // Save form input.
-  variable_set('node_truncate_node_type', $type);
+  $type  = $form_state['values']['node_type'];  
+  variable_set('mass_image_import_node_type', $type);
 
   // Setup batch configuration
-  $type  = $form_state['values']['node_type'];  
   $batch = array(
     'title'            => t('Importing images'),
     'operations'       => array(array('mass_image_import_batch', array($type))),
-- 
cgit v1.2.3