--- site_map.module	Mon Dec 19 17:27:18 2005
+++ site_map.module	Thu Apr 13 17:17:17 2006
@@ -47,6 +47,13 @@ function site_map_settings() {
 
   $output .= form_select(t('Categories to include in the site map'), 'site_map_show_vocabularies', $value, $options, NULL, 0, TRUE);
 
+  $menu = menu_get_menu();
+  $value = variable_get('site_map_show_menus', array());
+  foreach ($menu['items'][0]['children'] as $mid) {
+    $menu_options[$mid] = $menu['items'][$mid]['title'];
+  }
+  $output .= form_select(t('Menus to include in the site map'), 'site_map_show_menus', $value, $menu_options, NULL, 0, TRUE);
+
   return $output;
 }
 
@@ -78,6 +85,9 @@ function _site_map_page() {
  * This function can be called from blocks or pages as desired.
  */
 function _site_map_render() {
+  if (variable_get('site_map_show_nav_menus', 1)) {
+    $output = '<div class="menu">'. _site_map_menu_tree() .'</div>' ;
+  }
   $vids = variable_get('site_map_show_vocabularies', array('0'));
   $result = db_query('SELECT vid,name,description FROM {vocabulary} WHERE vid IN (%s) ORDER BY weight ASC, name', implode(',', $vids));
   while ($t = db_fetch_object($result)) {
@@ -85,11 +95,12 @@ function _site_map_render() {
     // taxonomy_get_tree() honors access controls
     //
     $tree = taxonomy_get_tree($t->vid);
-
-    $output .= _site_map_taxonomy_tree($tree, variable_get('site_map_show_count', 1), $t->name, $t->description);
+    if ($tree) {
+      $output .= _site_map_taxonomy_tree($tree, variable_get('site_map_show_count', 1), $t->name, $t->description);
+    }
   }
 
-  return $output;
+  return '<div class="site_map">'.$output.'</div>';
 }
 
 /**
@@ -164,7 +175,34 @@ function _site_map_taxonomy_tree(&$tree,
 
   $output .= "</div>\n";
 
-  return '<div class="site_map">'.$output.'</div>';
+  return $output;
+}
+
+function _site_map_menu_tree() {
+  $menus = variable_get('site_map_show_menus', array());
+  $menu = menu_get_menu();
+  foreach ($menus as $mid) {
+    $output .='<div class="name">'.$menu['visible'][$mid]['title'].'</div>';
+    $output .= '<blockquote>'.theme('site_map_menu_tree', $mid, $menu).'</blockquote>';
+  } 
+  return $output;
+}
+
+function theme_site_map_menu_tree($pid = 1, $menu = NULL) {
+// based on functions theme_menu_tree and menu_tree
+  $menu_items = '';
+
+  if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) {
+    foreach ($menu['visible'][$pid]['children'] as $mid) {
+      $type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL;
+      $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL;
+      $menu_tree .= theme('menu_item', $mid, theme('site_map_menu_tree', $mid, $menu), count($children) == 0);
+    }
+  }
+  if ($menu_tree) {
+    $output .= "\n<ul class=\"menu\">\n". $menu_tree ."\n</ul>\n";
+  }
+  return $output;
 }
 
-?>
+?>
\ No newline at end of file
