### Eclipse Workspace Patch 1.0
#P drupal
Index: sites/all/modules/menutrails/menutrails.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/menutrails/menutrails.module,v
retrieving revision 1.3
diff -u -r1.3 menutrails.module
--- sites/all/modules/menutrails/menutrails.module	27 Jun 2007 23:10:43 -0000	1.3
+++ sites/all/modules/menutrails/menutrails.module	11 Jul 2007 11:14:11 -0000
@@ -90,56 +90,114 @@
 * TODO: See about integrating views (e.g. node qualifies to be in a view, gets a menutrail, similar to how noderefrence lets you limit possibilities)
 */
 
-function menutrails_settings_form() {
-  $options = array('NONE');
-  $options = $options + menu_parent_options($item['mid'], variable_get('menu_parent_items', 0)); 
-  $node_types = node_get_types('names');
-  $node_trails = variable_get('menutrails_node_types', array());
-  $vocabs = taxonomy_get_vocabularies();
-  $term_trails = variable_get('menutrails_terms', array());
-  $form['description'] = array(
-    '#tyoe' => 'markup',
-    '#weight' => '-100',
-    '#value' => t('Use these settings to configure the "menu trails" for your nodes. This determines what menu items are activated when viewing an individual node. For instance, if you have a menu item for "Blog," you may want to have all blog posts fall under that menu.'),
-  );
-    $form['oder'] = array(
-    '#tyoe' => 'markup',
-    '#weight' => '-99',
-    '#value' => t('<p>Menu trials are evaluated in the following order:</p> <ol><li>Node type</li><li>Taxonomy category</li><li>Node-specific menu setting</li></ol><p>In other words, category-based menu trails override node-type, and specific settings made on the node itself override both. Category-based menu trails are evaluated by weight in the order shown here, so settings in lower vocabularies take precidence.</p>'),
-  );
-  $form['menutrails_node_types'] = array(
-      '#tree' => TRUE,
-      '#type' => 'fieldset',
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#title' => t('Menu trails by node type'),
-  );
-  foreach ($node_types as $key => $value) {
-    $form['menutrails_node_types'][$key] = array('#type' => 'select',
-      '#title' => t('Parent item for'). " $value",
-      '#default_value' => $node_trails[$key],
-      '#options' => $options,
-    );
+function menutrails_settings_form($form_values = NULL) {
+  if (!isset($form_values)) {
+    $step = 1;
   }
-  foreach ($vocabs as $vocab) {
-    $form[$vocab->vid]['menutrails_terms'] = array(
-      '#tree' => TRUE,
-      '#type' => 'fieldset',
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#title' => t('Menu trails by category:'). " $vocab->name",
-    );
-    $terms = taxonomy_get_tree($vocab->vid);
-    foreach ($terms as $term) {
-       $form[$vocab->vid]['menutrails_terms'][$term->tid] = array('#type' => 'select',
-        '#title' => t('Parent item for'). " $term->name",
-        '#default_value' => $term_trails[$term->tid],
-        '#options' => $options,
-      );
-    }
+  else {
+    $step = 2;
   }
+
+  switch ($step) {
+    case 1:
+      // Let the user choose which vacabularies to use 
+      // to limit the size of the form in step 2
+      $vocabs = taxonomy_get_vocabularies();
+      $options = array();
+      $defaults = variable_get('menutrails_vocabs_to_use', array());
+
+      foreach ($vocabs as $vocab) {
+	      $options[$vocab->vid] = $vocab->name;
+      }
+
+      $form['vocabs_to_use'] = array(
+		    '#type' => 'select',
+		    '#default_value' =>  $defaults,
+	      '#options' => $options,
+	      '#multiple' => TRUE, 
+	      '#description' => t('Choose the vocabularies you would like to use with Menutrails'),
+	    );
+	  
+		  $form['submit'] = array(
+		    '#type' => 'submit',
+		    '#value' => t('Next'),
+		  );
+
+	    $form['#multistep'] = TRUE;
+      $form['#redirect'] = FALSE;
+	    return $form;
+      break;
+
+    case 2:
+      $options = array('NONE');
+		  $options = $options + menu_parent_options($item['mid'], variable_get('menu_parent_items', 0)); 
+		  $node_types = node_get_types('names');
+		  $node_trails = variable_get('menutrails_node_types', array());
+		  
+		  // Get only the chose vocabs in the first step
+		  $vocabs = array();
+		  foreach ($form_values['vocabs_to_use'] as $vid) {
+		    $vocabs[] = taxonomy_get_vocabulary($vid);
+		  }
+
+		  $term_trails = variable_get('menutrails_terms', array());
+		  $form['description'] = array(
+		    '#tyoe' => 'markup',
+		    '#weight' => '-100',
+		    '#value' => t('Use these settings to configure the "menu trails" for your nodes. This determines what menu items are activated when viewing an individual node. For instance, if you have a menu item for "Blog," you may want to have all blog posts fall under that menu.'),
+		  );
+		  $form['oder'] = array(
+		    '#type' => 'markup',
+		    '#weight' => '-99',
+		    '#value' => t('<p>Menu trials are evaluated in the following order:</p> <ol><li>Node type</li><li>Taxonomy category</li><li>Node-specific menu setting</li></ol><p>In other words, category-based menu trails override node-type, and specific settings made on the node itself override both. Category-based menu trails are evaluated by weight in the order shown here, so settings in lower vocabularies take precidence.</p>'),
+		  );
+		  $form['menutrails_node_types'] = array(
+		    '#tree' => TRUE,
+		    '#type' => 'fieldset',
+		    '#collapsible' => TRUE,
+		    '#collapsed' => TRUE,
+		    '#title' => t('Menu trails by node type'),
+		  );
+		  foreach ($node_types as $key => $value) {
+		    $form['menutrails_node_types'][$key] = array(
+		      '#type' => 'select',
+		      '#title' => t('Parent item for'). " $value",
+		      '#default_value' => $node_trails[$key],
+		      '#options' => $options,
+		    );
+		  }
+		  foreach ($vocabs as $vocab) {
+		    $form[$vocab->vid]['menutrails_terms'] = array(
+		      '#tree' => TRUE,
+		      '#type' => 'fieldset',
+		      '#collapsible' => TRUE,
+		      '#collapsed' => TRUE,
+		      '#title' => t('Menu trails by category:'). " $vocab->name",
+		    );
+		    $terms = taxonomy_get_tree($vocab->vid);
+		    foreach ($terms as $term) {
+		       $form[$vocab->vid]['menutrails_terms'][$term->tid] = array(
+		        '#type' => 'select',
+		        '#title' => t('Parent item for'). " $term->name",
+		        '#default_value' => $term_trails[$term->tid],
+		        '#options' => $options,
+		      );
+		    }
+		  }
+		  
+		  $form['#submit']['menutrails_settings_submit'] = array();
+      $form['#multistep'] = TRUE;
+      $form['#redirect'] = FALSE;
   
-  return system_settings_form($form);
+      return system_settings_form($form);
+      break;
+  }
+}
+
+function menutrails_settings_submit($form_id, $form_values) {
+  variable_set('menutrails_node_types', $form_values['menutrails_node_types']);
+  variable_set('menutrails_terms', $form_values['menutrails_terms']);
+  drupal_set_message('Settings saved successfully');
 }
 
 
