--- D:/vito/  !  test/edit_term.module	Tue Sep 30 00:30:37 2008
+++ D:/vito/  !  test/new/edit_term.module	Tue Sep 30 01:02:22 2008
@@ -71,52 +71,36 @@
 function edit_term_menu($may_cache) {
   $items = array();
 
-  if (arg(0) == 'taxonomy' && arg(1) == 'term') {
-    // Add an edit tab to taxonomy pages for easy access
-    // Need two dummy default items - parent and default - for the advanced tab to show :-/
-    // There may be an easier way
-    $items[] = array(
-      'path' => 'taxonomy/term/'. arg(2) , 
-      'type' => MENU_CALLBACK,
-    );
-    $items[] = array(
-      'path' => 'taxonomy/term/'. arg(2) .'/view' , 
-      'title' => t('View'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'access' => TRUE,
-    );
-    $items[] = array(
-      'path' => 'taxonomy/term/'. arg(2) .'/edit-term' , 
-      'title' => t('Edit Term'),
-      'callback' => 'edit_term_edit_taxonomy_term',
-      'callback arguments' => array(arg(2)),
-      'access' => node_access('administer taxonomy'),
-      'weight' => 1,
-      'type' => MENU_LOCAL_TASK,
-    );
-  }
-  if (arg(0) == 'image' && arg(1) == 'tid') {
-    // Add an edit tab to gallery pages for easy access
-    // Needs default view tabs for the advanced tab to show :-/
-    $items[] = array(
-      'path' => 'image/tid/'. arg(2) , 
-      'type' => MENU_CALLBACK,
-    );
-    $items[] = array(
-      'path' => 'image/tid/'. arg(2) .'/view', 
-      'title' => t('View'),
-      'weight' => 0,
-      'type' => MENU_DEFAULT_LOCAL_TASK
-    );
-    $items[] = array(
-      'path' => 'image/tid/'. arg(2) .'/edit-term', 
-      'title' => t('Edit Gallery'),
-      'callback' => 'edit_term_edit_taxonomy_term',
-      'callback arguments' => array(arg(2)),
-      'access' => node_access('administer images'),
-      'weight' => 1,
-      'type' => MENU_LOCAL_TASK
-    );
+  $faketerm->tid = '';
+  foreach (taxonomy_get_vocabularies() as $vocab) {
+    $faketerm->vid = $vocab->vid;
+    $v_path = taxonomy_term_path($faketerm);
+    $v_path_elements = count(explode('/',$v_path));
+    $path = strtolower($_GET['q']);
+    if (stripos($path,$v_path) == 0 && is_numeric(arg($v_path_elements-1))) {
+      // Add an edit tab to taxonomy pages for easy access
+      // Need two dummy default items - parent and default - for the advanced tab to show :-/
+      // There may be an easier way
+      $items[] = array(
+        'path' => $v_path. arg($v_path_elements-1) ,
+        'type' => MENU_CALLBACK,
+      );
+      $items[] = array(
+        'path' => $v_path. arg($v_path_elements-1) .'/view' ,
+        'title' => t('View'),
+        'type' => MENU_DEFAULT_LOCAL_TASK,
+        'access' => TRUE,
+      );
+      $items[] = array(
+        'path' => $v_path. arg($v_path_elements-1) .'/edit-term' ,
+        'title' => t('Edit Term'),
+        'callback' => 'edit_term_edit_taxonomy_term',
+        'callback arguments' => array(arg($v_path_elements-1)),
+        'access' => node_access('administer taxonomy'),
+        'weight' => 1,
+        'type' => MENU_LOCAL_TASK,
+      );
+    }
   }
   return $items;
 }
@@ -178,9 +162,11 @@
 function edit_term_edit_taxonomy_term($tid) {
   $term = taxonomy_get_term($tid);
 
-  $termpath = 'taxonomy/term/'. $tid;
-  if ( ($gvid = variable_get('image_gallery_nav_vocabulary', '')) && ($term->vid == $gvid)) {
-    $termpath = 'image/tid/'. $tid;
+  // universal path
+  $termpath = taxonomy_term_path($term);
+  // special case - forum
+  if ($fvid = variable_get('forum_nav_vocabulary', '') && ($term->vid == $fvid)) {
+    $termpath = 'forum/'. $tid;
   }
   
   $_REQUEST['destination'] = $termpath;
@@ -229,9 +215,10 @@
 function edit_term_menu_form($term, &$form) {
   $item = array();
 
-  $termpath = 'taxonomy/term/'. $form['tid']['#value'];
-  if ( ($gvid = variable_get('image_gallery_nav_vocabulary', '')) && ($term->vid == $gvid)) {
-    $termpath = 'image/tid/'. $form['tid']['#value'];
+  $termpath = taxonomy_term_path($term);
+  // special case - forum
+  if ($fvid = variable_get('forum_nav_vocabulary', '') && ($term->vid == $fvid)) {
+    $termpath = 'forum/'. $term->tid;
   }
 
   if ($form['tid']['#value'] > 0) {
@@ -322,16 +309,15 @@
  */
 function edit_term_path_form($term, &$form) {
   if ($term->tid) {
-    $system_paths = array(
-      'taxonomy/term/'. $term->tid,
-      'image/tid/'. $term->tid,
-    );
-    foreach ($system_paths as $system_path) {
-      $found_path = drupal_get_path_alias($system_path);
-      if ($found_path != $system_path) {
+    $termpath = taxonomy_term_path($term);
+    // special case - forum
+    if ($fvid = variable_get('forum_nav_vocabulary', '') && ($term->vid == $fvid)) {
+      $termpath = 'forum/'. $term->tid;
+    }
+    $found_path = drupal_get_path_alias($termpath);
+    if ($found_path != $termpath) {
         // Found an alias
         $path = $found_path; 
-      }
     }
     if ($path) {
       $form['path']['pid'] = array(
@@ -366,9 +352,10 @@
 function edit_term_taxonomy($op, $type, $form_values = NULL) {
   if ($type == "term" && user_access('administer menu')) {
     $term = (object) $form_values;
-    $termpath = 'taxonomy/term/'. $term->tid;
-    if ( ($gvid = variable_get('image_gallery_nav_vocabulary', '')) && ($term->vid == $gvid)) {
-      $termpath = 'image/tid/'. $term->tid;
+    $termpath = taxonomy_term_path($term);
+    // special case - forum
+    if ($fvid = variable_get('forum_nav_vocabulary', '') && ($term->vid == $fvid)) {
+      $termpath = 'forum/'. $term->tid;
     }
 
     switch ($op) {
