Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/CHANGELOG.txt,v
retrieving revision 1.133
diff -u -p -r1.133 CHANGELOG.txt
--- CHANGELOG.txt	29 Jul 2009 15:18:21 -0000	1.133
+++ CHANGELOG.txt	29 Jul 2009 15:49:29 -0000
@@ -6,6 +6,7 @@ Admin Menu x.x-x.x, xxxx-xx-xx
 
 Admin Menu 7.x-3.x, xxxx-xx-xx
 ------------------------------
+#527908 by sun: Changed theme_admin_menu_links() to use $element['#children'].
 #519782 by sun: Updated for hook_footer() replaced by hook_page_alter().
 #527908 by markus_petrux, sun: Changed admin menu into a renderable array.
 #420812 by sun, smk-ka: Added support for hook_js().
Index: admin_menu.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.info,v
retrieving revision 1.10
diff -u -p -r1.10 admin_menu.info
--- admin_menu.info	11 Jul 2009 20:57:34 -0000	1.10
+++ admin_menu.info	29 Jul 2009 15:41:30 -0000
@@ -2,7 +2,12 @@
 name = Administration menu
 description = Provides a dropdown menu to most administrative tasks and other common destinations (to users with the proper permissions).
 package = Administration
+
+; Purposively added for feature development.
+version = 7.x-3.x-dev
 core = 7.x
+project = admin_menu
+
 files[] = admin_menu.module
 files[] = admin_menu.inc
 files[] = admin_menu.install
Index: admin_menu.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.module,v
retrieving revision 1.90
diff -u -p -r1.90 admin_menu.module
--- admin_menu.module	29 Jul 2009 15:18:21 -0000	1.90
+++ admin_menu.module	29 Jul 2009 15:43:19 -0000
@@ -428,7 +428,7 @@ function admin_menu_output() {
     $content['menu']['#theme'] = 'admin_menu_links';
     // Ensure the menu tree is rendered between the icon and user links.
     $content['menu']['#weight'] = 0;
-    // Do not sort the menu tree, since it already is sorted.
+    // Do not sort the menu tree, since it is sorted already.
     $content['menu']['#sorted'] = TRUE;
 
     // Add menu additions.
@@ -479,6 +479,7 @@ function theme_admin_menu_links(&$elemen
   }
 
   $output = '';
+  $depth_child = $depth + 1;
   foreach (element_children($elements, TRUE) as $path) {
     // Early-return nothing if user does not have access.
     if (isset($elements[$path]['#access']) && !$elements[$path]['#access']) {
@@ -489,18 +490,25 @@ function theme_admin_menu_links(&$elemen
       '#options' => array(),
     );
     // Render children to determine whether this link is expandable.
-    $children = theme('admin_menu_links', $elements[$path], $depth + 1);
-    if (!empty($children)) {
-      $elements[$path]['#attributes']['class'][] = 'expandable';
-      // If there are children, we add the parent key as class by default.
-      // $elements[$path]['#attributes']['class'][] = $path;
+    if (isset($elements[$path]['#type']) || isset($elements[$path]['#theme'])) {
+      $elements[$path]['#admin_menu_depth'] = $depth_child;
+      $elements[$path]['#children'] = drupal_render($elements[$path]);
     }
-    if (isset($elements[$path]['#attributes']['class'])) {
-      $elements[$path]['#attributes']['class'] = implode(' ', $elements[$path]['#attributes']['class']);
+    else {
+      // Inherit #sorted flag from parent item.
+      if (isset($elements['#sorted'])) {
+        $elements[$path]['#sorted'] = TRUE;
+      }
+      $elements[$path]['#children'] = theme('admin_menu_links', $elements[$path], $depth_child);
+      if (!empty($elements[$path]['#children'])) {
+        $elements[$path]['#attributes']['class'][] = 'expandable';
+      }
+      if (isset($elements[$path]['#attributes']['class'])) {
+        $elements[$path]['#attributes']['class'] = implode(' ', $elements[$path]['#attributes']['class']);
+      }
     }
 
-    $output .= '<li' . drupal_attributes($elements[$path]['#attributes']) . '>';
-
+    $link = '';
     if (isset($elements[$path]['#href'])) {
       // Strip destination query string from href attribute and apply a CSS class
       // for our JavaScript behavior instead.
@@ -525,7 +533,7 @@ function theme_admin_menu_links(&$elemen
         $elements[$path]['#options']['attributes']['class'] .= ' admin-menu-destination';
       }
 
-      $output .= l($elements[$path]['#title'], $elements[$path]['#href'], $elements[$path]['#options']);
+      $link .= l($elements[$path]['#title'], $elements[$path]['#href'], $elements[$path]['#options']);
     }
     elseif (isset($elements[$path]['#title'])) {
       if (!empty($elements[$path]['#options']['html'])) {
@@ -535,22 +543,21 @@ function theme_admin_menu_links(&$elemen
         $title = check_plain($elements[$path]['#title']);
       }
       if (!empty($elements[$path]['#options']['attributes'])) {
-        $output .= '<span' . drupal_attributes($elements[$path]['#options']['attributes']) . '>' . $title . '</span>';
+        $link .= '<span' . drupal_attributes($elements[$path]['#options']['attributes']) . '>' . $title . '</span>';
       }
       else {
-        $output .= $title;
+        $link .= $title;
       }
     }
 
-    $output .= $children;
+    $output .= '<li' . drupal_attributes($elements[$path]['#attributes']) . '>';
+    $output .= $link . $elements[$path]['#children'];
     $output .= '</li>';
   }
   // @todo #attributes probably required for UL, but already used for LI.
-  // @todo Use $element['#theme'] + $element['#children'] here instead.
-  if ($output) {
-    if ($depth > 0) {
-      $output = "\n<ul>" . $output . '</ul>';
-    }
+  // @todo Use $element['#children'] here instead.
+  if ($output && $depth > 0) {
+    $output = "\n<ul>" . $output . '</ul>';
   }
   return $output;
 }
