Index: node_form_rearrange.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_form_rearrange/node_form_rearrange.install,v
retrieving revision 1.1
diff -u -p -r1.1 node_form_rearrange.install
--- node_form_rearrange.install	17 Nov 2008 21:08:10 -0000	1.1
+++ node_form_rearrange.install	2 Mar 2010 00:25:15 -0000
@@ -3,7 +3,8 @@
 
 /**
  * @file
- * Implements one hook. This sets the weight of this module to be greater than the taxonomy module. 
+ * Implements one hook. This sets the weight of this module to be greater than
+ * the taxonomy module.
  */
 
 /**
@@ -12,4 +13,4 @@
 function node_form_rearrange_install() {
   $weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'"));
   db_query("UPDATE {system} SET weight = %d WHERE name = 'node_form_rearrange'", $weight + 1);
-}
\ No newline at end of file
+}
Index: node_form_rearrange.js
===================================================================
RCS file: node_form_rearrange.js
diff -N node_form_rearrange.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ node_form_rearrange.js	2 Mar 2010 00:25:15 -0000
@@ -0,0 +1,63 @@
+// $Id$
+
+/**
+ * @file
+ * 
+ * provides a vertical tabs summary for each vocabulary when Node Form Rearrange
+ * is enabled for the content type.
+ */
+
+// The following line will prevent a JavaScript error if this file is included and vertical tabs are disabled.
+Drupal.verticalTabs = Drupal.verticalTabs || {};
+
+Drupal.behaviors.node_form_rearrange = function() {
+  $('fieldset[class*=vertical-tabs-vocab_]').each( function() {
+    // there might be multiple classes...
+    var classes = $(this).attr('class').split(' ').sort();
+
+    var fieldsetClass;
+    var fieldsetID; // as in Form API
+    var vocabClassRegExp = 'vertical-tabs-vocab_[0-9]+$';
+
+    // find the relevant class
+    while( testClass = classes.pop() ) {
+      if ( testClass.match(vocabClassRegExp) ) {
+        fieldsetClass = testClass;
+        fieldsetID = testClass.substr( testClass.indexOf('vocab_') ); 
+        break;
+      }
+    }
+
+    // add vertical tabs summary function
+    Drupal.verticalTabs[fieldsetID] = function() {
+      var terms = [];
+      var termCount = 0;
+      $('fieldset.' + fieldsetClass).find('select, input.form-text').each(function() {
+        if (this.value) {
+          if ($(this).is('select')) {
+            $(this).find('option[selected]').each(function() {
+              var termName = $(this).text();
+              // remove hyphens from child terms
+              while ( termName.charAt(0) == '-' ) {
+                termName = termName.substr(1);
+              }
+              terms.push(termName);
+              termCount++;
+            });
+          }
+          else if ($(this).is('input.form-text')) {
+            terms.push(this.value);
+            termCount++;
+          }
+        }
+      });
+
+      if (termCount) {
+        return terms.join(', ');
+      }
+      else {
+        return Drupal.t('No terms');
+      }
+    }
+  });
+}
Index: node_form_rearrange.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_form_rearrange/node_form_rearrange.module,v
retrieving revision 1.6
diff -u -p -r1.6 node_form_rearrange.module
--- node_form_rearrange.module	8 Jan 2010 16:33:16 -0000	1.6
+++ node_form_rearrange.module	2 Mar 2010 00:25:16 -0000
@@ -1,10 +1,10 @@
 <?php
-// $Id:
+// $Id$
 
 /**
  * @file
- * Implements three hooks. This allows for form elements provided by the taxonomy
- * module to be rearranged individually in node add/edit forms.
+ * Implements three hooks. This allows for form elements provided by the
+ * taxonomy module to be rearranged individually in node add/edit forms.
  */
 
 /**
@@ -13,7 +13,8 @@
 function node_form_rearrange_menu() {
   $items = array();
   $items['admin/settings/node-form-rearrange'] = array(
-    'title' => 'Node Form Rearrange Settings',
+    'title' => 'Node Form Rearrange settings',
+    'description' => 'Allows for taxonomy selection fields to be rearranged in the node form individually.',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('node_form_rearrange_settings'),
     'access arguments' => array('administer content types'),
@@ -24,7 +25,6 @@ function node_form_rearrange_menu() {
 
 /**
  * Form builder
- * Implementation of hook_settings().
  */
 function node_form_rearrange_settings() {
   $form = array();
@@ -32,7 +32,7 @@ function node_form_rearrange_settings() 
   $form['node_form_rearrange_content_types'] = array(
     '#type' => 'checkboxes',
     '#description' => 'Check the content types for which you want to use the Form Rearrange Functions',
-    '#title' => t('Rearrange Content Types'),
+    '#title' => t('Rearrange content types'),
     '#options' => $types,
     '#default_value' => variable_get('node_form_rearrange_content_types', array(0)),
     '#required' => TRUE,
@@ -44,28 +44,77 @@ function node_form_rearrange_settings() 
 /**
  * Implementation of hook_form_alter().
  */
-
 function node_form_rearrange_form_alter(&$form, $form_state, $form_id) {
   if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
-  	$types = variable_get('node_form_rearrange_content_types', array(0));
-  	if(isset($types[$form['type']['#value']]) && ($types[$form['type']['#value']] != '0')) {
-      //retrieve all vocabularies for this node's content type
+    $types = variable_get('node_form_rearrange_content_types', array(0));
+    if (isset($types[$form['type']['#value']]) && ($types[$form['type']['#value']] != '0')) {
+      // retrieve all vocabularies for this node's content type
       $vocabularies = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'
   ORDER BY v.weight, v.name", 'v', 'vid'), $form['type']['#value']);
-      //loop through vocabularies, moving their form element out of the taxonomy fieldset
+      // loop through vocabularies, moving their form element out of the taxonomy fieldset
       while ($vocabulary = db_fetch_object($vocabularies)) {
-      //check to see if non-tag vocabularies exist
-      if ($form['taxonomy'][$vocabulary->vid]) {
+
+        $use_vertical_tabs = FALSE;
+
+        // check if current vocabulary should integrate with vertical tabs
+        if (module_exists('vertical_tabs')) {
+          $vertical_tabs_forms = variable_get('vertical_tabs_forms', NULL);
+          if ($vertical_tabs_forms[$form_id]["vocab_$vocabulary->vid"]) {
+            $use_vertical_tabs = TRUE;
+          }
+        }
+
+        /* awkward workaround for content-type settings form.
+         * vertical_tabs.module builds a sample node form to discover
+         * eligible fieldsets, so we must account for this.
+         * @see vertical_tabs_form_node_type_form_alter()
+         * @see vertical_tabs_add_node_type_options()
+         */
+        if ( arg(2) == 'node-type' ) {
+          $use_vertical_tabs = TRUE;
+        }
+
+        // taxonomy fields need to be inside fieldsets for vertical tabs
+        if ($use_vertical_tabs) {
+          // create fieldset for vocab
+          $form["vocab_$vocabulary->vid"] = array(
+            '#type'  => 'fieldset',
+            '#title' => $vocabulary->name,
+            '#group' => 'additional_settings',
+            '#attached' => array(
+              'js' => array(
+                'vertical-tabs' => drupal_get_path('module', 'node_form_rearrange') . '/node_form_rearrange.js',
+              ),
+            ),
+          );
+        }
+
+        // check to see if non-tag vocabularies exist
+        if ($form['taxonomy'][$vocabulary->vid]) {
           $field = $form['taxonomy'][$vocabulary->vid];
           unset($form['taxonomy'][$vocabulary->vid]);
-          $form["taxonomy_field_$vocabulary->vid"] = $field;
+
+          if ($use_vertical_tabs) {
+            $form["vocab_$vocabulary->vid"]["taxonomy_field_$vocabulary->vid"] = $field;
+          }
+          else {
+            $form["taxonomy_field_$vocabulary->vid"] = $field;
+          }
         }
-        //check to see if tag vocabularies exist
+
+        // check to see if tag vocabularies exist
         if ($form['taxonomy']['tags'][$vocabulary->vid]) {
           $field = $form['taxonomy']['tags'][$vocabulary->vid];
           unset($form['taxonomy']['tags'][$vocabulary->vid]);
-          $form["taxonomy_field_tags_$vocabulary->vid"] = $field;
+
+          if ($use_vertical_tabs) {
+            $form["vocab_$vocabulary->vid"]["taxonomy_field_tags_$vocabulary->vid"] = $field;
+          }
+          else {
+            $form["taxonomy_field_tags_$vocabulary->vid"] = $field;
+          }
         }
+
         // Direct copy from content.module, for setting the weight of fields based on arrangement in admin/content/node-type/[content type]/fields
         $type = content_types($form['type']['#value']);
         foreach ($type['extra'] as $key => $value) {
@@ -74,7 +123,7 @@ function node_form_rearrange_form_alter(
           }
         }
       }
-      //Removing now empty taxonomy fieldset
+      // Removing now empty taxonomy fieldset
       if (isset($form['taxonomy'])) {
         unset($form['taxonomy']);
       }
@@ -90,10 +139,10 @@ function node_form_rearrange_nodeapi(&$n
   switch ($op) {
     case 'presave':
       $types = variable_get('node_form_rearrange_content_types', array(0));
-      if(isset($types[$node->type]) && ($types[$node->type] != '0')) {
+      if (isset($types[$node->type]) && ($types[$node->type] != '0')) {
         $vocabularies = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'
   ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
-        //loop through vocabularies, resetting the original data arrangement (fields in taxonomy fieldset) so the taxonomy is saved
+        // loop through vocabularies, resetting the original data arrangement (fields in taxonomy fieldset) so the taxonomy is saved
         while ($vocabulary = db_fetch_object($vocabularies)) {
           $fieldname = 'taxonomy_field_'. $vocabulary->vid;
           if (isset($node->$fieldname) && $node->$fieldname) {
@@ -117,16 +166,16 @@ function node_form_rearrange_nodeapi(&$n
 
 function node_form_rearrange_content_extra_fields($type_name) {
   $types = variable_get('node_form_rearrange_content_types', array(0));
-  if(isset($types[$type_name]) && ($types[$type_name] != '0')) {
+  if (isset($types[$type_name]) && ($types[$type_name] != '0')) {
     $extra = array();
     $vocabularies = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'
   ORDER BY v.weight, v.name", 'v', 'vid'), $type_name);
-    //add rows for each vocabulary
+    // add rows for each vocabulary
     while ($vocabulary = db_fetch_object($vocabularies)) {
       if ($vocabulary->tags) {
         $extra["taxonomy_field_tags_$vocabulary->vid"] = array(
         'label' => $vocabulary->name,
-        'description' => t('Individual field for %vocabularyname vocabulary, disables Taxonomy group ', array('%vocabularyname' => $vocabulary->name)),
+        'description' => t('Individual field for %vocabularyname vocabulary, disables Taxonomy group', array('%vocabularyname' => $vocabulary->name)),
         'weight' => 0);
       }
       else {
