? taxonomy_xml/cvs
Index: taxonomy_xml/taxonomy_xml.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_xml/taxonomy_xml.info,v
retrieving revision 1.1
diff -u -u -p -r1.1 taxonomy_xml.info
--- taxonomy_xml/taxonomy_xml.info	3 Jul 2007 07:04:38 -0000	1.1
+++ taxonomy_xml/taxonomy_xml.info	7 Jan 2008 12:52:43 -0000
@@ -1,4 +1,5 @@
 ; $Id: taxonomy_xml.info,v 1.1 2007/07/03 07:04:38 nicolash Exp $
 name = Taxonomy import/export via XML
 description = Makes it possible to import and export taxonomy terms via XML.
-dependencies = taxonomy
\ No newline at end of file
+dependencies[] = taxonomy
+core = 6.x
Index: taxonomy_xml/taxonomy_xml.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_xml/taxonomy_xml.module,v
retrieving revision 1.8
diff -u -u -p -r1.8 taxonomy_xml.module
--- taxonomy_xml/taxonomy_xml.module	18 Dec 2007 02:15:24 -0000	1.8
+++ taxonomy_xml/taxonomy_xml.module	7 Jan 2008 12:52:44 -0000
@@ -21,8 +21,8 @@
 /**
  * Implementation of hook_help().
  */
-function taxonomy_xml_help($section) {
-  switch ($section) {
+function taxonomy_xml_help($path, $arg) {
+  switch ($path) {
     case 'admin/modules#description':
       return t('Makes it possible to import and export taxonomy terms via XML.');
     case 'admin/content/taxonomy/import':
@@ -35,7 +35,7 @@ function taxonomy_xml_help($section) {
     case 'admin/help#taxonomy_xml':
       return t("This module makes it possible to import and export vocabularies and taxonomy terms via XML (requires taxonomy.module). ".
                "Once installed and enabled, it module provides a list of downloadable XML documents for each vocabulary at !downloads. To import a vocabulary, use !upload.",
-        array('!downloads' => l(t("taxonomy XML"), "admin/taxonomy/export"), '!upload' => l("administer &raquo; categories &raquo; import", "admin/taxonomy/import", array(), NULL, NULL, FALSE, TRUE)));
+        array('!downloads' => l(t("taxonomy XML"), "admin/taxonomy/export"), '!upload' => l("administer &raquo; categories &raquo; import", "admin/taxonomy/import", array('html' => TRUE))));
   }
 }
 
@@ -44,27 +44,25 @@ function taxonomy_xml_help($section) {
  * 
  * @note See hook_menu for a description of parameters and return values.
  */
-function taxonomy_xml_menu($may_cache) {
+function taxonomy_xml_menu() {
   if (!module_exists('taxonomy')) {
     return;
   }
   $items = array();
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/content/taxonomy/export',
-      'title' => t('Export'),
-      'access' => user_access('administer taxonomy'),
-      'callback' => 'taxonomy_xml_export',
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/content/taxonomy/import',
-      'title' => t('Import'),
-      'access' => user_access('administer taxonomy'),
-      'callback' => 'taxonomy_xml_import',
-      'type' => MENU_LOCAL_TASK);
-  }
-  $items[] = array('path' => 'taxonomy_xml',
-    'title' => t('Taxonomy XML'),
-    'callback' => 'taxonomy_xml_file',
-    'access' => true,
+  $items['admin/content/taxonomy/export'] = array(
+    'title' => 'Export',
+    'access arguments' => array('administer taxonomy'),
+    'page callback' => 'taxonomy_xml_export',
+    'type' => MENU_LOCAL_TASK);
+  $items['admin/content/taxonomy/import'] = array(
+    'title' => 'Import',
+    'access arguments' => array('administer taxonomy'),
+    'page callback' => 'taxonomy_xml_import',
+    'type' => MENU_LOCAL_TASK);
+
+  $items['taxonomy_xml'] = array(
+    'title' => 'Taxonomy XML',
+    'page callback' => 'taxonomy_xml_file',
     'type' => MENU_CALLBACK);
   return $items;
 }
@@ -131,8 +129,9 @@ function taxonomy_xml_import() {
 /**
  * Imports the actual XML.
  */
-function taxonomy_xml_import_form_validate($form_id, $form_values) {
-  if ($file = file_check_upload('xml')) {
+function taxonomy_xml_import_form_validate($form, &$form_state) {
+  $form_values = $form_state['values'];
+  if ($file = file_save_upload('xml')) {
     $fd = fopen($file->filepath, "rb");
     if (!$fd) {
       form_set_error('xml', t('Vocabulary import failed: file %filename cannot be read.', array('%filename' => $file->filename)));
@@ -144,7 +143,7 @@ function taxonomy_xml_import_form_valida
 
       fclose($fd);
       drupal_set_message(t('Loaded file %filename.', array('%filename' => $file->filename)));
-      taxonomy_xml_parse($text, $form_values['vid'], $form_values['term'], $form_values['duplicate']);
+      taxonomy_xml_parse($text, $form_state['values']['vid'], NULL, $form_state['values']['duplicate']);
     }
   }
   else {
@@ -296,11 +295,11 @@ function taxonomy_xml_element_data($pars
         }
       }
       else {
-        $_tx_terms[$_tx_term][$_tx_tag] .= trim($data);
+        $_tx_terms[$_tx_term][$_tx_tag] = trim($data);
       }
       break;
     default:
-      $_tx_vocabulary[$_tx_tag] .= trim($data);
+      $_tx_vocabulary[$_tx_tag] = trim($data);
   }
 }
 
@@ -316,11 +315,12 @@ function taxonomy_xml_element_data($pars
  */
 function taxonomy_xml_parse(&$data, $vid = 0, $parent_tid = NULL, $duplicate = 0) {
   global $_tx_terms, $_tx_vocabulary;
+  $skipped_terms = array();
 
   // Unset the global variables before we use them:
-  unset($GLOBALS['element'], $GLOBALS['term'], $GLOBALS['tag']);
+  unset($GLOBALS['_tx_element'], $GLOBALS['_tx_term'], $GLOBALS['_tx_tag']);
   $_tx_terms = array();
-  $_tx_vocabulary = array();
+  $_tx_vocabulary = array('name' => 'un-named vocabulary', 'vid' => NULL);
   $new_terms = array();
 
   // parse the data:
@@ -342,8 +342,8 @@ function taxonomy_xml_parse(&$data, $vid
   if ($vid == 0) {
     $name = $_tx_vocabulary['name'];
     $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE LOWER('%s') LIKE LOWER(name)", trim($name)));
-    if ($vid) {
-      $_tx_vocabulary = (array) (module_invoke('taxonomy', 'get_vocabulary', $vid));
+    if ($vid && $retrieved = module_invoke('taxonomy', 'get_vocabulary', $vid)) {
+      $_tx_vocabulary = (array) $retrieved;
     }
     else {
       unset($_tx_vocabulary['vid']);
@@ -373,10 +373,15 @@ function taxonomy_xml_parse(&$data, $vid
       if ($term['depth'] != $i) {
         continue;
       }
-      $term['vid'] = $_tx_vocabulary['vid'];
+      if (isset($_tx_vocabulary['vid'])) { 
+        $term['vid'] = $_tx_vocabulary['vid'];
+      }
+      else {
+        drupal_set_message(t("No valid vocab id. "));
+      }
       $term['old_tid'] = $term['tid'];
       unset($term['tid']);
-      if (is_array($term['parent'])) {
+      if (isset($term['parent']) && is_array($term['parent'])) {
         foreach ($term['parent'] as $key => $value) {
           if ($value) {
             $term['parent'][$key] = $new_tid[$value];
@@ -405,7 +410,7 @@ function taxonomy_xml_parse(&$data, $vid
         $new_terms[] = $term['name'];
       }
     }
-  
+    $output = "";
     $output .= t('Vocabulary %name: ', array('%name' => $_tx_vocabulary['name']));
     if ($new_terms) {
       $output .= t('Added term(s) %terms', array('%terms' => implode(', ', $new_terms)));
