Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.86
diff -u -p -r1.86 menu.inc
--- includes/menu.inc	8 Oct 2005 12:38:20 -0000	1.86
+++ includes/menu.inc	13 Oct 2005 10:57:15 -0000
@@ -636,51 +636,81 @@ function menu_item_link($mid) {
  * @ingroup themeable
  */
 function theme_menu_local_tasks() {
+  $local_tasks = menu_get_local_tasks();
+  $pid = menu_get_active_nontask_item();
   $output = '';
 
-  if ($primary = menu_primary_local_tasks()) {
-    $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
-  }
-  if ($secondary = menu_secondary_local_tasks()) {
-    $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
-  }
+  $output .= menu_local_tasks($local_tasks, $pid, 'primary', 0, 0);
+  $output .= menu_local_tasks($local_tasks, $pid, 'secondary', 1, 2);
 
   return $output;
 }
 
 /**
- * Returns the rendered HTML of the primary local tasks.
+ * Returns a rendered menu suitable for horizontal display.
+ * Used to generate primary and secondary links.
+ *
+ * @param $pid
+ *   The menu ID to render. Children of this menu item will be rendered, 
+ *   but the item itself will be omitted.
+ *   Defaults to NULL, in which case it will use the menu_primary_menu setting.
+ * @param $start_level
+ *   The number of levels under the pid you want to render.
+ *   If you want to render the secondary items, set this to 2 and this 
+ *   will skip the first (primary) level and give you level 2.
+ *
+ * @ingroup themeable
  */
-function menu_primary_local_tasks() {
-  $local_tasks = menu_get_local_tasks();
-  $pid = menu_get_active_nontask_item();
-  $output = '';
+function theme_menu_links($pid = NULL, $start_level = 1) {
+  $menu = menu_get_menu();
 
-  if (count($local_tasks[$pid]['children'])) {
-    foreach ($local_tasks[$pid]['children'] as $mid) {
-      $output .= theme('menu_local_task', $mid, menu_in_active_trail($mid), TRUE);
-    }
+  if (!$pid) {
+    $pid = variable_get('menu_primary_menu', 1);
   }
 
+  $output = menu_local_tasks($menu['visible'], $pid, 'primary', $start_level - 1, 1);
+
   return $output;
 }
 
 /**
- * Returns the rendered HTML of the secondary local tasks.
+ * Generate a the HTML for an ul representing a menu.
+ *
+ * @param $menu
+ *   An array containing the menu items to process. Passing in this array 
+ *   allows this function to generically operate on local_tasks and visible.
+ *
+ * @param $pid
+ *   The parent menu ID from which to search for children.
+ *
+ * @param $class
+ *   The ul will have class="$class" included. Useful for specifying the 
+ *   styles used to display the list.
+ *
+ * @param $depth
+ *   Follow the active trail down this many levels before starting to render.
+ *   Used to generate a primary/secondary menu from different levels of a tree.
+ *
+ * @param $min_children
+ *   Only render the menu if it has at least this many elements. This would 
+ *   usually be set to 1, but make it 2 if you want to hide a menu with only 
+ *   a single option (used to hide single-element secondary local tasks).
  */
-function menu_secondary_local_tasks() {
-  $local_tasks = menu_get_local_tasks();
-  $pid = menu_get_active_nontask_item();
+function menu_local_tasks($menu = NULL, $pid = 1, $class = '', $depth = 0, $min_children = 1) {
+  if (!$menu) {
+    $menu = menu_get_menu();
+    $menu = $menu['visible'];
+  }
   $output = '';
 
-  if (count($local_tasks[$pid]['children'])) {
-    foreach ($local_tasks[$pid]['children'] as $mid) {
-      if (menu_in_active_trail($mid) && count($local_tasks[$mid]['children']) > 1) {
-        foreach ($local_tasks[$mid]['children'] as $cid) {
-          $output .= theme('menu_local_task', $cid, menu_in_active_trail($cid), FALSE);
-        }
-      }
+  $mid = menu_follow_active_trail($menu, $pid, $depth);
+
+  if ($mid && count($menu[$mid]['children']) >= $min_children) {
+    $output .= '<ul' .  (!empty($class) ? " class=\"$class\"" : '') . ">\n";
+    foreach ($menu[$mid]['children'] as $cid) {
+      $output .= theme('menu_local_task', $cid, menu_in_active_trail($cid), FALSE);
     }
+    $output .= "</ul>\n";
   }
 
   return $output;
@@ -693,12 +723,10 @@ function menu_secondary_local_tasks() {
  *   The menu ID to render.
  * @param $active
  *   Whether this tab or a subtab is the active menu item.
- * @param $primary
- *   Whether this tab is a primary tab or a subtab.
  *
  * @ingroup themeable
  */
-function theme_menu_local_task($mid, $active, $primary) {
+function theme_menu_local_task($mid, $active) {
   if ($active) {
     return '<li class="active">'. menu_item_link($mid) ."</li>\n";
   }
@@ -708,6 +736,42 @@ function theme_menu_local_task($mid, $ac
 }
 
 /**
+ * Descend along the active trail through a menu tree for a number of levels.
+ * Returns the ID of the menu that deep.
+ *
+ * @param $menu
+ *   An array containing the menu items to process. Passing in this array 
+ *   allows this function to generically operate on local_tasks and visible.
+ *
+ * @param $pid
+ *   The parent menu ID from which to search.
+ *
+ * @param $levels
+ *   How many levels deep we should go.
+ */
+function menu_follow_active_trail($menu, $pid, $levels = 1) {
+
+  for ($this_level = 0; $this_level < $levels && $pid ; $this_level++) {
+    $found_active = 0;
+    foreach ($menu[$pid]['children'] as $mid) {
+      if (menu_in_active_trail($mid)) {
+        if (count($menu[$mid]['children'])) {
+          $pid = $mid;
+          $found_active = 1;
+        }
+      }
+    }
+    // Break if the active trail ends before we dig deep enough.
+    // This can happen if the tree is not deep enough or if the
+    // current node is not a child of the menu we're traversing.
+    if (!$found_active) {
+      $pid = NULL;
+    }
+  }
+
+  return $pid;
+}
+/**
  * @} End of "defgroup menu".
  */
 
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.261
diff -u -p -r1.261 theme.inc
--- includes/theme.inc	7 Oct 2005 06:09:13 -0000	1.261
+++ includes/theme.inc	13 Oct 2005 10:57:16 -0000
@@ -212,8 +212,6 @@ function path_to_theme() {
  */
 function theme_get_settings($key = NULL) {
   $defaults = array(
-    'primary_links'                 =>  array(),
-    'secondary_links'               =>  array(),
     'mission'                       =>  '',
     'default_logo'                  =>  1,
     'logo_path'                     =>  '',
@@ -225,8 +223,6 @@ function theme_get_settings($key = NULL)
     'toggle_search'                 =>  1,
     'toggle_slogan'                 =>  0,
     'toggle_mission'                =>  1,
-    'toggle_primary_links'          =>  1,
-    'toggle_secondary_links'        =>  1,
     'toggle_node_user_picture'      =>  0,
     'toggle_comment_user_picture'   =>  0,
   );
@@ -306,40 +302,6 @@ function theme_get_setting($setting_name
         $settings['favicon'] = $settings['favicon_path'];
       }
     }
-
-    foreach (array('primary', 'secondary') as $type) {
-      // Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.
-      $value = $settings[$type . '_links'];
-
-      // Clear out existing (internal) values
-      $settings[$type .'_links'] = array();
-
-      // Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
-      $count = variable_get($type . '_link_count', 5);
-      $count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
-
-      if ($settings['toggle_' . $type . '_links']) {
-        for ($i =0; $i < $count; $i++) {
-          unset($attributes);
-          if (!empty($value['text'][$i])) {
-            if (!empty($value['description'][$i])) {
-              $attributes['title'] = $value['description'][$i];
-            }
-            $text = $value['text'][$i];
-            $link = $value['link'][$i];
-            if (substr($link, 0, 7) == 'http://') {
-              $settings[$type .'_links'][] = '<a href="'. check_url($link) .'"'. drupal_attributes($attributes) .'>'. check_plain($text) .'</a>';
-            }
-            else {
-              $settings[$type .'_links'][] = l($text, $link, $attributes);
-            }
-          }
-        }
-        if ($settings[$type .'_links'] == array()) {
-          $settings[$type .'_links'] = array(l(t('edit %type links', array('%type' => $type)),'admin/themes/settings'));
-        }
-      }
-    }
   }
 
   return isset($settings[$setting_name]) ? $settings[$setting_name] : NULL;
Index: modules/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu.module,v
retrieving revision 1.38
diff -u -p -r1.38 menu.module
--- modules/menu.module	11 Oct 2005 19:44:34 -0000	1.38
+++ modules/menu.module	13 Oct 2005 10:57:16 -0000
@@ -47,6 +47,11 @@ function menu_menu($may_cache) {
       'callback' => 'menu_reset',
       'access' => user_access('administer menu'),
       'type' => MENU_LOCAL_TASK);
+
+    $items[] = array('path' => 'admin/settings/menu',
+      'title' => t('menus'),
+      'callback' => 'menu_configure',
+      'access' => user_access('administer menu'));
   }
 
   return $items;
@@ -65,9 +70,35 @@ function menu_help($section) {
       return t('<p>Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.</p>', array('%blocks' => l(t('blocks'), 'admin/block')));
     case 'admin/menu/item/add':
       return t('<p>Enter the title, path, position and the weight for your new menu item.</p>');
+    case 'admin/settings/menu':
+      return t('<p>Customize the menu settings.</p>');
   }
 }
 
+
+/**
+ * Menu callback; presents menu configuration options.
+ */
+function menu_configure() {
+  $menu = menu_get_menu();
+  
+  $options[0] = t('No primary links');
+  foreach ($menu['items'][0]['children'] as $mid) {
+    $options[$mid] = $menu['items'][$mid]['title'];
+  }
+
+  $form['settings_links'] = array('#type' => 'fieldset', '#title' => t('Primary links settings'));
+  $form['settings_links']['menu_primary_menu'] = array(
+    '#type' => 'select',
+    '#title' => t('primary links menu'),
+    '#default_value' => variable_get('menu_primary_menu', 1),
+    '#options' => $options,
+    '#description' => t('Primary links are a navigation system which typically (depending on your theme) appears at the top-right of the window. You may control which links appear in this area by choosing a menu from which the primary links will be generated and then placing your preferred links into the menu using the <a href="%menu">menu administration</a>.', array('%menu' => url('admin/menu')))
+  );
+
+  return system_settings_form('menu_configure', $form);
+}
+
 /**
  * Implementation of hook_block().
  */
Index: modules/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system.module,v
retrieving revision 1.241
diff -u -p -r1.241 system.module
--- modules/system.module	13 Oct 2005 10:02:31 -0000	1.241
+++ modules/system.module	13 Oct 2005 10:57:17 -0000
@@ -1018,11 +1018,6 @@ function system_theme_settings($key = ''
 
   // System wide only settings.
   if (!$key) {
-    // Menu settings
-
-    $form['primary_links'] = system_navigation_links_form('primary', 'Primary');
-    $form['secondary_links'] = system_navigation_links_form('secondary', 'Secondary');
-
     // Toggle node display.
     $node_types = module_invoke('node', 'get_types');
     if ($node_types) {
@@ -1041,8 +1036,6 @@ function system_theme_settings($key = ''
     'toggle_name'                 => t('Site name'),
     'toggle_slogan'               => t('Site slogan'),
     'toggle_mission'              => t('Mission statement'),
-    'toggle_primary_links'        => t('Primary links'),
-    'toggle_secondary_links'      => t('Secondary links'),
     'toggle_node_user_picture'    => t('User pictures in posts'),
     'toggle_comment_user_picture' => t('User pictures in comments'),
     'toggle_search'               => t('Search box'),
@@ -1092,62 +1085,6 @@ function system_theme_settings($key = ''
 
 }
 
-function system_navigation_links_form($type, $utype) {
-  $settings = theme_get_settings('');
-  $value = $settings[$type . '_links'];
-
-  if (!is_array($value)) {
-    $value = array();
-  }
-  // Increment the link count, if the user has requested more links.
-  if (variable_get($type . '_links_more', false)) {
-    variable_del($type . '_links_more');
-    variable_set($type . '_link_count', variable_get($type . '_link_count', 5) + 5);
-  }
-
-  // Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
-  $count = variable_get($type . '_link_count', 5);
-  $count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
-
-  if (variable_get($type . '_link_count', 5) != $count) {
-    variable_set($type . '_link_count', $count);
-  }
-  $form = array(
-    '#type' => 'item', '#title' => t('_TYPE_ link settings', array('_TYPE_' => $utype)), '#theme' => 'system_navigation_links_form',
-    '#description' => t('You can specify your _TYPE_ links here, one link per line.<br /> The link text field is the text you want to link.<br /> The url field is the location the link points to.<br /> The description field is an optional description of where the link points.', array('_TYPE_' => $type))
-  );
-
-  $form['#tree'] = TRUE;
-
-  for ($i = 0; $i < $count; $i++) {
-    foreach (array('text', 'link', 'description') as $field) {
-      $form[$field][$i] = array('#type' => 'textfield', '#default_value' => $value[$field][$i], '#size' => 15, '#maxlength' => 90);
-    }
-  }
-
-  $form[$type . '_links_more'] = array(
-    '#type' => 'checkbox', '#title' => t('I need more _TYPE_ links.', array('_TYPE_' => $type)), '#default_value' => FALSE,
-    '#description' => t('Checking this box will give you 5 additional _TYPE_ links.', array('_TYPE_' => $type))
-  );
-  return $form;
-}
-
-function theme_system_navigation_links_form(&$form) {
-  $header = array(t('link text'), t('url'), t('description'));
-  foreach (element_children($form['text']) as $key) {
-    $row = array();
-    $row[] = form_render($form['text'][$key]);
-    $row[] = form_render($form['link'][$key]);
-    $row[] = form_render($form['description'][$key]);
-    $rows[] = $row;
-
-  }
-  $output = theme('table', $header, $rows);
-  $output .= form_render($form);
-  return $output;
-}
-
-
 function search_box() {
   $form['#action'] = url('search');
   $form['keys'] = array('#type' => 'textfield', '#size'=> 15, '#value' => '', '#attributes' => array('alt' => t('Enter the terms you wish to search for.'), 'class' => 'form-text'));
Index: themes/bluemarine/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/bluemarine/page.tpl.php,v
retrieving revision 1.11
diff -u -p -r1.11 page.tpl.php
--- themes/bluemarine/page.tpl.php	7 Oct 2005 06:51:43 -0000	1.11
+++ themes/bluemarine/page.tpl.php	13 Oct 2005 10:57:17 -0000
@@ -18,8 +18,8 @@
       <?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
     </td>
     <td id="menu">
-      <?php if ($secondary_links) { ?><div id="secondary"><?php print theme('links', $secondary_links) ?></div><?php } ?>
-      <?php if ($primary_links) { ?><div id="primary"><?php print theme('links', $primary_links) ?></div><?php } ?>
+      <?php print $primary_navigation ?>
+      <?php print $secondary_navigation ?>
       <?php print $search_box ?>
     </td>
   </tr>
Index: themes/bluemarine/style.css
===================================================================
RCS file: /cvs/drupal/drupal/themes/bluemarine/style.css,v
retrieving revision 1.11
diff -u -p -r1.11 style.css
--- themes/bluemarine/style.css	2 Sep 2005 19:18:14 -0000	1.11
+++ themes/bluemarine/style.css	13 Oct 2005 10:57:17 -0000
@@ -92,7 +92,7 @@ table {
 #menu {
   padding: 0.5em 0.5em 0 0.5em;
   text-align: right;
-  vertical-align: middle;
+  vertical-align: top;
 }
 #primary {
   font-size: 1.0em;
Index: themes/chameleon/chameleon.theme
===================================================================
RCS file: /cvs/drupal/drupal/themes/chameleon/chameleon.theme,v
retrieving revision 1.33
diff -u -p -r1.33 chameleon.theme
--- themes/chameleon/chameleon.theme	16 Aug 2005 18:06:18 -0000	1.33
+++ themes/chameleon/chameleon.theme	13 Oct 2005 10:57:17 -0000
@@ -11,9 +11,7 @@ function chameleon_features() {
        'logo',
        'toggle_favicon',
        'toggle_name',
-       'toggle_slogan',
-       'toggle_primary_links',
-       'toggle_secondary_links');
+       'toggle_slogan');
 }
 
 function chameleon_regions() {
@@ -55,8 +53,8 @@ function chameleon_page($content) {
 
   $output .= "</div>\n";
 
-  $primary_links = theme('links', theme_get_setting('primary_links'));
-  $secondary_links = theme('links', theme_get_setting('secondary_links'));
+  $primary_links = theme('menu_links', NULL, 1);
+  $secondary_links = theme('menu_links', NULL, 2);
   if ($primary_links || $secondary_links) {
     $output .= ' <div class="navlinks">';
     if ($primary_links) {
Index: themes/engines/phptemplate/phptemplate.engine
===================================================================
RCS file: /cvs/drupal/drupal/themes/engines/phptemplate/phptemplate.engine,v
retrieving revision 1.18
diff -u -p -r1.18 phptemplate.engine
--- themes/engines/phptemplate/phptemplate.engine	7 Oct 2005 06:11:06 -0000	1.18
+++ themes/engines/phptemplate/phptemplate.engine	13 Oct 2005 10:57:17 -0000
@@ -126,9 +126,7 @@ function phptemplate_features() {
     'toggle_mission',
     'toggle_name',
     'toggle_node_user_picture',
-    'toggle_primary_links',
     'toggle_search',
-    'toggle_secondary_links',
     'toggle_slogan'
   );
 }
@@ -196,11 +194,11 @@ function phptemplate_page($content) {
     'messages'            => theme('status_messages'),
     'mission'             => $mission,
     'onload_attributes'   => theme('onload_attribute'),
-    'primary_links'       => theme_get_setting('primary_links'),
+    'primary_navigation'  => theme('menu_links', NULL, 1),
+    'secondary_navigation'=> theme('menu_links', NULL, 2),
     'site_name'           => (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''),
     'site_slogan'         => (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : ''),
     'search_box'          => (theme_get_setting('toggle_search') ? search_box() : ''),
-    'secondary_links'     => theme_get_setting('secondary_links'),
     'sidebar_left'        => $sidebar_left,
     'sidebar_right'       => $sidebar_right,
     'styles'              => theme_get_styles(),
Index: themes/pushbutton/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/pushbutton/page.tpl.php,v
retrieving revision 1.6
diff -u -p -r1.6 page.tpl.php
--- themes/pushbutton/page.tpl.php	7 Oct 2005 06:11:12 -0000	1.6
+++ themes/pushbutton/page.tpl.php	13 Oct 2005 10:57:17 -0000
@@ -34,7 +34,7 @@
     </td>
 
     <td class="primary-links" width="70%" align="center" valign="middle">
-      <?php print theme('links', $primary_links) ?>
+      <?php print $primary_navigation ?>
     </td>
   </tr>
 </table>
@@ -42,7 +42,7 @@
 <table id="secondary-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%">
   <tr>
     <td class="secondary-links" width="75%"  align="center" valign="middle">
-      <?php print theme('links', $secondary_links) ?>
+      <?php print $secondary_navigation ?>
     </td>
     <td  width="25%"  align="center" valign="middle">
       <?php print $search_box ?>
@@ -101,21 +101,9 @@
 
 <table id="footer-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%">
   <tr>
-    <td align="center" valign="middle">
-    <?php if (is_array($primary_links)) : ?>
-      <div class="primary-links">
-        <?php foreach ($primary_links as $link): ?>
-          <?php print $link?> |
-        <?php endforeach; ?>
-      </div>
-    <?php endif; ?>
-    <?php if (is_array($secondary_links)) : ?>
-      <div class="secondary-links">
-        <?php foreach ($secondary_links as $link): ?>
-          <?php print $link?> |
-        <?php endforeach; ?>
-      </div>
-    <?php endif; ?>
+    <td class="secondary-links" width="70%" align="center" valign="middle">
+      <?php print $primary_navigation ?>
+      <?php print $secondary_navigation ?>
     </td>
   </tr>
 </table>
Index: themes/pushbutton/style.css
===================================================================
RCS file: /cvs/drupal/drupal/themes/pushbutton/style.css,v
retrieving revision 1.12
diff -u -p -r1.12 style.css
--- themes/pushbutton/style.css	2 Sep 2005 19:18:14 -0000	1.12
+++ themes/pushbutton/style.css	13 Oct 2005 10:57:17 -0000
@@ -98,15 +98,21 @@ td#home a:hover img {
   width: 144px;
   height: 63px;
 }
+ul.primary li a {
+  border-style: solid;
+}
 .primary-links, .primary-links a:link, .primary-links a:visited {
   color: #369;
 }
-.primary-links a:hover {
+.primary-links a:hover, .primary-links li a.active {
   color: #000;
 }
+#primary-menu ul.primary   {
+  font-size: 0.79em;
+  border-bottom: 0px;
+}
 #primary-menu .primary-links   {
   background: transparent url(header-b.jpg) left top no-repeat;
-  font-size: 0.79em;
 }
 #primary-menu .primary-links h1, #primary-menu .primary-links h2, #primary-menu .primary-links h3 {
   font-size: 2.3em;
@@ -117,15 +123,15 @@ td#home a:hover img {
   border-top: 3px solid #69c;
   border-bottom: 3px solid #69c;
 }
-.secondary-links, .secondary-links a:link, .secondary-links a:visited  {
-  color: #e4e9eb;
+.secondary-links, .secondary-links a:link, .secondary-links a:visited {
+  color: #369;
 }
-.secondary-links a:hover {
-  color: #fff;
-  text-decoration: underline;
+.secondary-links a:hover, .secondary-links li a.active {
+  color: #000;
 }
-#secondary-menu .secondary-links {
-  font-size: 0.85em;
+#secondary-menu ul.primary {
+  font-size: 0.79em;
+  border-bottom: 0px;
 }
 .tabs {
   margin: 15px 0 15px 0;
@@ -319,16 +325,9 @@ table#footer-menu {
   padding: 5px;
   font-size: 0.75em;
 }
-#footer-menu .primary-links, #footer-menu a:link, #footer-menu a:visited  {
-  color: #e4e9eb;
-}
-#footer-menu a:hover  {
-  color: #fff;
-  text-decoration: underline;
-}
-#footer-menu .primary-links h1, #footer-menu .primary-links h2, #footer-menu .primary-links h3 {
-  font-size: 1.3em;
-  color: #e4e9eb;
+#footer-menu ul.primary {
+  font-size: 0.79em;
+  border-bottom: 0px;
 }
 /*
 ** Common declarations for child classes of node, comment, block, box, etc.
