Index: taxonomy_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_node/taxonomy_node.module,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 taxonomy_node.module
--- taxonomy_node.module	22 Oct 2008 17:45:50 -0000	1.1.2.4
+++ taxonomy_node.module	23 Oct 2008 21:21:08 -0000
@@ -27,7 +27,6 @@ function _taxonomy_node_get_tid_from_nid
   return $tid;
 }
 
-
 function _taxonomy_node_create_node($tid, $vid, $term_name, $parents) {
   $taxonomy_node_settings = variable_get("taxonomy_node_{$vid}", array());
   if ($taxonomy_node_settings['content_type']) {
@@ -78,6 +77,13 @@ function taxonomy_node_menu($may_cache) 
   $items = array();
 
   if ($may_cache) {
+      $items[]= array (
+        'path' => 'admin/content/taxonomy/taxonomy_node',
+        'title' => 'Taxonomy Node',
+        'callback' => 'drupal_get_form',
+        'callback arguments' => array('taxonomy_node_settings'),
+        'access' => user_access('administer taxonomy'),
+      );
   } else {
     if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'taxonomy' && arg(3) == 'edit' && arg(4) == 'term') {
       $items[]= array (
@@ -87,6 +93,44 @@ function taxonomy_node_menu($may_cache) 
         'type' => MENU_CALLBACK,
       );
     }
+    if (variable_get('taxonomy_node_tab_interface', FALSE)) {
+      if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'taxonomy' && arg(3) == 'edit' && arg(4) == 'term' && is_numeric(arg(5))) {
+        $tid = arg(5);
+        // Root callback for this item needed to create tabs
+        $items[] = array('path' => 'admin/content/taxonomy/edit/term/'. $tid,
+          'title' => t('Edit term'),
+          'callback' => 'taxonomy_admin_term_edit',
+          'callback arguments' => array($tid),
+          'access' => user_access('administer taxonomy'),
+          'type' => MENU_CALLBACK,
+          'weight' => 0,
+        );
+        // Default tab - will be selected for above callback
+        $items[] = array('path' => 'admin/content/taxonomy/edit/term/'. $tid .'/basic',
+          'title' => t('Basic'),
+          'access' => user_access('administer taxonomy'),
+          'type' => MENU_DEFAULT_LOCAL_TASK,
+          'weight' => 1,
+        );
+        // Make sure term node exists
+        $nid = _taxonomy_node_get_nid_from_tid($tid);
+        // Term node does not exist yet
+        if ($nid) {
+          $node = node_load($nid);
+        } else {
+          // Create it, but don't redirect, and return the newly created node
+          $node = taxonomy_node_create($tid, FALSE);
+        }
+        $items[] = array('path' => 'admin/content/taxonomy/edit/term/'. $tid .'/advanced',
+          'title' => t('Advanced'),
+          'callback' => 'node_page_edit',
+          'callback arguments' => array($node),
+          'access' => user_access('administer taxonomy') && node_access('update', $node),
+          'type' => MENU_LOCAL_TASK,
+          'weight' => 2,
+        );
+      }
+    }      
   }
 
   return $items;
@@ -138,21 +182,27 @@ function taxonomy_node_form_alter($form_
     if ($taxonomy_node_settings['content_type'] && $tid) {
       $nid = db_result(db_query("SELECT nid FROM {taxonomy_node} tn WHERE tn.tid = %d", $tid));
 
-      $form['taxonomy_node'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Taxonomy Node'),
-        '#weight' => -20,
-      );
-      if ($nid) {
-        $form['taxonomy_node']['taxonomy_node_node'] = array(
-          '#type' => 'markup',
-          '#value' => t('You can edit the associated node !node as well.', array('!node' => l($form['name']['#default_value'], 'node/'.$nid.'/edit', array(), drupal_get_destination()))),
-        );
+      if (variable_get('taxonomy_node_tab_interface', FALSE)) {
+        // Tabbed interface should redirect back to the tab, not the term list.
+        $form['#redirect'] = FALSE;
       } else {
-        $form['taxonomy_node']['taxonomy_node_node'] = array(
-          '#type' => 'markup',
-          '#value' => t('There is no associated node available for this term. !link.', array('!link' => l(t('Create it'), 'admin/content/taxonomy/edit/term/'.$tid.'/taxonomy_node/create'))),
+        // Old behavior
+        $form['taxonomy_node'] = array(
+          '#type' => 'fieldset',
+          '#title' => t('Taxonomy Node'),
+          '#weight' => -20,
         );
+        if ($nid) {
+          $form['taxonomy_node']['taxonomy_node_node'] = array(
+            '#type' => 'markup',
+            '#value' => t('You can edit the associated node !node as well.', array('!node' => l($form['name']['#default_value'], 'node/'.$nid.'/edit', array(), drupal_get_destination()))),
+          );
+        } else {
+          $form['taxonomy_node']['taxonomy_node_node'] = array(
+            '#type' => 'markup',
+            '#value' => t('There is no associated node available for this term. !link.', array('!link' => l(t('Create it'), 'admin/content/taxonomy/edit/term/'.$tid.'/taxonomy_node/create'))),
+          );
+        }
       }
     }
   }
@@ -165,21 +215,37 @@ function taxonomy_node_form_alter($form_
       $vid = $row->vid;
       if ($vid) {
         $vocab = taxonomy_get_vocabulary($vid);
+        
+        // Removed for cosmetic reasons...
+        /*
         $form['taxonomy'][$vid . '_disabled'] = $form['taxonomy'][$vid];
         $form['taxonomy'][$vid . '_disabled']['#multiple'] = ($vocab->hierarchy == 2);
         $form['taxonomy'][$vid . '_disabled']['#disabled'] = TRUE;
         $form['taxonomy'][$vid . '_disabled']['#tree'] = FALSE;
         $form['taxonomy'][$vid . '_disabled']['#required'] = FALSE;
+        */
+        
         $form['taxonomy'][$vid] = array(
           '#type' => 'value',
           '#value' => $form['taxonomy'][$vid]['#default_value'],
         );
-        $form['title']['#disabled'] = TRUE;
+        
+        // Title updating now handled by nodeapi
+        // $form['title']['#disabled'] = TRUE;
+        $form['title']['#title'] = t('Term name');
+        
         unset($form['delete']);
 
         $term = taxonomy_get_term($row->tid);
-        if (!$form['#post']) {
-          drupal_set_message(t('Taxonomy Node: Disabled form elements should be only changed on the associated term !term. To delete this node, just delete the term.', array('!term' => l($term->name, 'admin/content/taxonomy/edit/term/'.$row->tid))));
+
+        if (variable_get('taxonomy_node_tab_interface', FALSE)) {
+          // Tabbed interface should redirect back to the tabs, not the node page.
+          $form['#redirect'] = 'admin/content/taxonomy/edit/term/'. $term->tid .'/basic';
+        } else {
+          // Old behavior;
+          if (!$form['#post']) {
+            drupal_set_message(t('Taxonomy Node: Disabled form elements should be only changed on the associated term !term. To delete this node, just delete the term.', array('!term' => l($term->name, 'admin/content/taxonomy/edit/term/'.$row->tid))));
+          }
         }
       }
     }
@@ -260,6 +326,12 @@ function taxonomy_node_taxonomy($op, $ty
  */
 function taxonomy_node_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   switch ($op) {
+    // Update the term name from the node title if a taxonomy node is found
+    case 'update':
+      if ($tid = _taxonomy_node_get_tid_from_nid($node->nid)) {
+        db_query("UPDATE {term_data} SET name = '%s' WHERE tid = %d;", $node->title, $tid);
+      }
+      break;
     case 'delete':
       // In case the node is deleted from the admin content screen, remove
       // the association from the database.
@@ -269,6 +341,19 @@ function taxonomy_node_nodeapi(&$node, $
 }
 
 /**
+ * Implementation of hook_settings().
+ */
+function taxonomy_node_settings() {
+  $form['taxonomy_node_tab_interface'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use tabbed interface'),
+    '#default_value' => variable_get('taxonomy_node_tab_interface', FALSE),
+    '#description' => t('Select this checkbox if you want to manage associated nodes and terms using a tabbed interface.'),
+  );
+  return system_settings_form($form);
+}
+
+/**
  * Callbacks
  */
 
@@ -277,10 +362,15 @@ function taxonomy_node_nodeapi(&$node, $
  *
  * @param unknown_type $tid
  */
-function taxonomy_node_create($tid) {
+function taxonomy_node_create($tid, $redirect = TRUE) {
   $term = taxonomy_get_term($tid);
   $parents = taxonomy_get_parents($tid);
-  _taxonomy_node_create_node($tid, $term->vid, $term->name, array_keys($parents));
+  $newnode = _taxonomy_node_create_node($tid, $term->vid, $term->name, array_keys($parents));
   drupal_set_message(t('Taxonomy Node: Node created.'));
-  drupal_goto('admin/content/taxonomy/edit/term/' . $tid);
-}
\ No newline at end of file
+  if ($redirect) {
+    drupal_goto('admin/content/taxonomy/edit/term/' . $tid);
+  } else {
+    return $newnode;
+  }
+}
+
