Index: menutrails.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/menutrails/menutrails.module,v
retrieving revision 1.4.2.11
diff -U3 -r1.4.2.11 menutrails.module
--- menutrails.module	2 Feb 2009 15:50:15 -0000	1.4.2.11
+++ menutrails.module	22 May 2009 18:32:58 -0000
@@ -49,6 +49,19 @@
       }
     }
   }
+  if (variable_get('menutrails_taxonomy', 0) && module_exists('taxonomy') && arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
+    if($term = taxonomy_get_term(arg(2))) {
+      $item = menutrails_term_location($term);
+      if ($item) {
+        menu_set_item(NULL, $item);
+        if (variable_get('menutrails_breadcrumbs', 1)) {
+          $crumbs = menutrails_get_breadcrumbs();
+          $crumbs[] = l($term->name, 'taxonomy/term/'. $term->tid);
+          drupal_set_breadcrumb($crumbs);
+        }
+      }
+    }
+  }
 }
 
 /**
@@ -131,6 +144,9 @@
         if ($term_trails[$term->tid]) {
           $href = $term_trails[$term->tid];
         }
+        elseif ($term_trails['vids'][$term->vid]) {
+          $href = $term_trails['vids'][$term->vid];
+        }
       }
     }
   }
@@ -165,6 +181,34 @@
 }
 
 /**
+ * Determine the menu location of a taxonomy term page.
+ *
+ * Inspired by _menu_get_active_trail().
+ */
+function menutrails_term_location($term) {
+  $item = menu_get_item();
+  $href = FALSE;
+  if (db_result(db_query("SELECT count(mlid) FROM {menu_links} WHERE link_path = '%s' AND module = 'menu'", $item['href'])) == 0) {
+    $term_trails = variable_get('menutrails_terms', array());
+    if ($term_trails[$term->tid]) {
+      $href = $term_trails[$term->tid];
+    }
+    elseif ($term_trails['vids'][$term->vid]) {
+      $href = $term_trails['vids'][$term->vid];
+    }
+  }
+  else {
+    // We may want to do some breadcrumbing.
+    return $item;
+  }
+  if ($href) {
+    $item['href'] = $href;
+    return $item;
+  }
+  return FALSE;
+}
+
+/**
  * This implements the same functionality as the nodeapi, but for comment urls.
  */
 function menutrails_comment($comment, $op) {
@@ -215,6 +259,13 @@
     '#title' => t('Set breadcrumbs?'),
     '#description' => t('If checked, menutrails will also synchronize the default drupal breadcrumbs with the menu trails, again giving priority to the menu selected above.'),
   );
+  $form['menutrails_taxonomy'] = array(
+    '#type' => 'checkbox',
+    '#weight' => '-5',
+    '#default_value' => variable_get('menutrails_taxonomy', 0),
+    '#title' => t('Apply to taxonomy term pages?'),
+    '#description' => t('If checked, menutrails will also apply to taxonomy term pages.'),
+  );
   $form['order'] = array(
     '#type' => 'markup',
     '#weight' => '-1',
@@ -271,6 +322,13 @@
         '#collapsed' => TRUE,
         '#title' => t('Categories:') ." $vocab->name",
       );
+      $form[$vocab->vid]['menutrails_terms']['vids'][$vocab->vid] = array(
+        '#type' => 'select',
+        '#title' => t('Parent item for all terms'),
+        '#default_value' => $term_trails['vids'][$vocab->vid],
+        '#options' => $options,
+        '#description' => t('Applies to all terms within this vocabulary that aren\'t set.'),
+      );
       $terms = taxonomy_get_tree($vocab->vid);
       foreach ($terms as $term) {
         $form[$vocab->vid]['menutrails_terms'][$term->tid] = array('#type' => 'select',
