--- taxonomy_menu.module	2005-11-25 11:29:34.000000000 +0100
+++ taxonomy_menu.module.new	2005-11-25 11:35:34.000000000 +0100
@@ -16,42 +16,59 @@
  *
  * Most of the heavy lifting of the module is done here.
  */
-function taxonomy_menu_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $access = user_access('access content');
-
-    foreach (taxonomy_get_vocabularies() as $vocabulary) {
-      if (variable_get('taxonomy_menu_show_'. $vocabulary->vid, 1)) {
-        $path = 'taxonomy_menu/'. $vocabulary->vid;
-        $items[] = array('path' => $path, 'title' => t($vocabulary->name),
-          'callback' => 'taxonomy_menu_page', 'access' => $access,
-          'weight' => $vocabulary->weight);
-
-        $tree = taxonomy_get_tree($vocabulary->vid);
-        $old_depth = -1;
-        $old_path = $path;
-
-        foreach ($tree as $term) {
-          if ($term->depth <= $old_depth) {
-            $slashes_to_remove = $old_depth - $term->depth + 1;
-            for ($i = 0; $i < $slashes_to_remove; $i++) {
-              $old_path = substr($old_path, 0, strrpos($old_path, '/'));
+ 
+ function taxonomy_menu_menu($may_cache) {
+   
+   $items = array();
+   
+   if ($may_cache) {
+     $use_path_auto = (variable_get('taxonomy_menu_use_pathauto',0) && module_exist('pathauto'));
+     $access = user_access('access content');
+     foreach (taxonomy_get_vocabularies() as $vocabulary) {
+        if (variable_get('taxonomy_menu_show_'. $vocabulary->vid, 1)) {
+          $path = ($use_path_auto) ? strtolower(pathauto_cleanstring($vocabulary->name)) : 'taxonomy_menu/'.$vocabulary->vid;
+          
+          $items[] = array(
+            'path'                =>  $path,
+            'title'               =>  t($vocabulary->name),
+            'weight'              =>  $vocabulary->weight,
+            'callback'            =>  'taxonomy_menu_page', 
+            'access'              =>  $access,
+            'callback arguments' => Array($vocabulary->vid),
+          );
+          
+          $tree = taxonomy_get_tree($vocabulary->vid);
+          $old_depth = -1;
+          $old_path = $path;
+          
+          foreach ($tree as $term) {
+            if ($term->depth <= $old_depth) {
+              $slashes_to_remove = $old_depth - $term->depth + 1;
+              for ($i = 0; $i < $slashes_to_remove; $i++) {
+                $old_path = substr($old_path, 0, strrpos($old_path, '/'));
+              }
             }
+            
+            $path = $old_path .'/';
+            $path .= ($use_path_auto) ? strtolower(pathauto_cleanstring($term->name)) : $term->tid;
+            $old_depth = $term->depth;
+            $old_path = $path;
+            $items[] = array(
+              'path' => $path, 
+              'title' => t($term->name),
+              'callback'  =>  'taxonomy_menu_page', 
+              'weight' => $term->weight,
+              'access'            =>  $access,
+              'callback arguments' => Array($vocabulary->vid, $term->tid),
+              );
           }
-          $path = $old_path .'/'. $term->tid;
-          $old_depth = $term->depth;
-          $old_path = $path;
-          $items[] = array('path' => $path, 'title' => t($term->name),
-            'weight' => $term->weight);
         }
-      }
-    }
-  }
-
-  return $items;
-}
+     }
+     //print_r($items);
+   }
+   
+   return $items;
+ }
 
 /**
  * Implementation of hook_taxonomy().
@@ -67,7 +84,7 @@
  */
 function taxonomy_menu_settings() {
   $form .= form_checkbox(t('Display descendants'), 'taxonomy_menu_display_descendants', 1, variable_get('taxonomy_menu_display_descendants', 1), t('If checked, then when a term is selected all nodes belonging to subterms are also displayed.'));
-
+  $form .= form_checkbox(t('Use names of vocabularies/terms instead of their ids to build links'),'taxonomy_menu_use_pathauto',  1, variable_get('taxonomy_menu_use_pathauto', 0), t('If checked, then the link is generated of the names of terms and vocabularies, taxonomy_menu/1/3 gets to news/general. (Requires the module pathauto)'));
   foreach (taxonomy_get_vocabularies() as $vocabulary) {
     $form .= form_checkbox(t('Show "%vocab" in menu', array('%vocab' => t($vocabulary->name))), 'taxonomy_menu_show_' . $vocabulary->vid, 1, variable_get('taxonomy_menu_show_' . $vocabulary->vid, 1));
   }
@@ -79,9 +96,11 @@
  * Page callback that renders a node listing for the selected term.
  */
 function taxonomy_menu_page() {
-  if (arg(2)) {
+  $args = func_get_args();
+
+  if ($args[1]) {
     $arguments = explode('/', $_GET['q']);
-    $main_tid = db_escape_string(array_pop($arguments));
+    $main_tid = $args[1]; //db_escape_string(array_pop($arguments));
     
     drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('taxonomy/term/'. $main_tid .'/'. (variable_get('taxonomy_menu_display_descendants', 1) ? 'all' : 0) .'/feed') .'" />');
     
@@ -90,7 +109,7 @@
   else {
     // If no arg(2), we're looking at just the vid. If display_descendants
     // is on, grab all terms regardless of depth. If off, grab depth 0 terms.
-    $tree = taxonomy_get_tree(arg(1));
+    $tree = taxonomy_get_tree($args[0]);
     $descendants = variable_get('taxonomy_menu_display_descendants', 1);
     foreach ($tree as $term) {
       if ($descendants || $term->depth == 0) {
@@ -116,9 +135,11 @@
     case 'view':
       if ($a4 == TRUE) {
         // The node is being displayed on its own page.
+        $use_path_auto = (variable_get('taxonomy_menu_use_pathauto',0) && module_exist('pathauto'));
+        
         foreach (taxonomy_get_vocabularies() as $vocabulary) {
           if (variable_get('taxonomy_menu_show_'. $vocabulary->vid, 1)) {
-            $path = 'taxonomy_menu/' . $vocabulary->vid;
+            $path = ($use_path_auto) ? strtolower(pathauto_cleanstring($vocabulary->name)) : 'taxonomy_menu/'.$vocabulary->vid;
 
             $tree = taxonomy_get_tree($vocabulary->vid);
             $old_depth = -1;
@@ -131,11 +152,15 @@
                   $old_path = substr($old_path, 0, strrpos($old_path, "/"));
                 }
               }
-              $path = $old_path .'/'. $term->tid;
+              $path = $old_path .'/';
+              $path .= ($use_path_auto) ? strtolower(pathauto_cleanstring($term->name))  : $term->tid;
               $old_depth = $term->depth;
               $old_path = $path;
+
               if (in_array($term->tid, array_keys(taxonomy_node_get_terms($node->nid)))) {
                 menu_set_location(array(array('path' => $path, 'title' => t($term->name)), array('path' => 'node/'. $node->nid, 'title' => $node->title)));
+                //menu_set_active_item($path);
+                
                 // Quit after the first match.
                 return;
               }
