Index: modules/blog/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v
retrieving revision 1.280
diff -u -F^f -r1.280 blog.module
--- modules/blog/blog.module	30 Apr 2007 17:03:23 -0000	1.280
+++ modules/blog/blog.module	16 May 2007 03:36:10 -0000
@@ -48,11 +48,12 @@ function blog_access($op, $node) {
  */
 function blog_user($type, &$edit, &$user) {
   if ($type == 'view' && user_access('edit own blog', $user)) {
-    $items['blog'] = array('title' => t('Blog'),
-      'value' => l(t('View recent blog entries'), "blog/$user->uid", array('title' => t("Read @username's latest blog entries.", array('@username' => $user->name)))),
-      'class' => 'blog',
+    $user->content['summary']['blog'] =  array(
+      '#type' => 'profile_item',
+      '#title' => t('Blog'),
+      '#value' => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read @username's latest blog entries.", array('@username' => $user->name)))),
+      '#attributes' => array('class' => 'blog'),
     );
-    return array(t('History') => $items);
   }
 }
 
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.201
diff -u -F^f -r1.201 profile.module
--- modules/profile/profile.module	14 May 2007 13:43:36 -0000	1.201
+++ modules/profile/profile.module	16 May 2007 03:36:11 -0000
@@ -612,7 +612,7 @@ function profile_view_field($user, $fiel
   }
 }
 
-function profile_view_profile($user) {
+function profile_view_profile(&$user) {
 
   profile_load_profile($user);
 
@@ -628,14 +628,24 @@ function profile_view_profile($user) {
   while ($field = db_fetch_object($result)) {
     if ($value = profile_view_field($user, $field)) {
       $title = ($field->type != 'checkbox') ? check_plain($field->title) : NULL;
-      $item = array('title' => $title,
-        'value' => $value,
-        'class' => $field->name,
-      );
-      $fields[$field->category][$field->name] = $item;
-    }
+
+      // create a single fieldset for each category
+      if (!isset($user->content[$field->category])) {
+        $user->content[$field->category] = array(
+          '#type' => 'profile_category',
+          '#title' => $field->category,
+        );
+      }
+
+      $user->content[$field->category][$field->name] = array(
+        '#type' => 'profile_item',
+        '#title' => $title,
+        '#value' => $value,
+        '#weight' => $field->weight,
+        '#attributes' => array('class' => 'profile-'. $field->name)
+		 );
+		}
   }
-  return $fields;
 }
 
 function _profile_form_explanation($field) {
Index: modules/user/user.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.css,v
retrieving revision 1.4
diff -u -F^f -r1.4 user.css
--- modules/user/user.css	30 Dec 2006 07:45:31 -0000	1.4
+++ modules/user/user.css	16 May 2007 03:36:11 -0000
@@ -36,14 +36,26 @@
   clear: both;
   margin: 1em 0;
 }
+
 .profile .picture {
   float: right;
   margin: 0 1em 1em 0;
 }
+
+.profile h3 {
+  border-bottom: 1px solid #ccc;
+}
+
+.profile dl {
+  margin: 0 0 1.5em 0;
+}
+
 .profile dt {
-  margin: 1em 0 0.2em 0;
+  margin: 0 0 0.2em 0;
   font-weight: bold;
 }
 .profile dd {
-  margin:0;
+  margin:0 0 1em 0;
 }
+
+
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.780
diff -u -F^f -r1.780 user.module
--- modules/user/user.module	14 May 2007 13:43:38 -0000	1.780
+++ modules/user/user.module	16 May 2007 03:36:12 -0000
@@ -33,7 +33,13 @@ function user_theme() {
       'arguments' => array('account' => NULL),
     ),
     'user_profile' => array(
-      'arguments' => array('account' => NULL, 'fields' => NULL),
+      'arguments' => array('account' => NULL),
+    ),
+    'profile_category' => array(
+      'arguments' => array('element' => NULL),
+    ),
+    'profile_item' => array(
+      'arguments' => array('element' => NULL),
     ),
     'user_list' => array(
       'arguments' => array('users' => NULL, 'title' => NULL),
@@ -491,14 +497,23 @@ function user_search($op = 'search', $ke
 /**
  * Implementation of hook_user().
  */
-function user_user($type, &$edit, &$user, $category = NULL) {
+function user_user($type, &$edit, &$account, $category = NULL) {
   if ($type == 'view') {
-    $items['history'] = array('title' => t('Member for'),
-      'value' => format_interval(time() - $user->created),
-      'class' => 'member',
+    $account->content['user_picture'] = array(
+      '#value' => theme('user_picture', $account),
+      '#weight' => -10,
+    );
+    $account->content['summary'] += array(
+      '#type' => 'profile_category',
+      '#attributes' => array('class' => 'user-member'),
+      '#weight' => -5,
+      '#title' => t('History'),
+    );
+    $account->content['summary']['member_for'] =  array(
+      '#type' => 'profile_item',
+      '#title' => t('Member for'),
+      '#value' => format_interval(time() - $account->created)
     );
-
-    return array(t('History') => $items);
   }
   if ($type == 'form' && $category == 'account') {
     return user_edit_form(arg(1), $edit);
@@ -682,32 +697,13 @@ function theme_user_picture($account) {
 /**
  * Theme a user page
  * @param $account the user object
- * @param $fields a multidimensional array for the fields, in the form of array (
- *   'category1' => array(item_array1, item_array2), 'category2' => array(item_array3,
- *    .. etc.). Item arrays are formatted as array(array('title' => 'item title',
- * 'value' => 'item value', 'class' => 'class-name'), ... etc.). Module names are incorporated
- * into the CSS class.
  *
  * @ingroup themeable
  */
-function theme_user_profile($account, $fields) {
+function theme_user_profile($account) {
   $output = '<div class="profile">';
-  $output .= theme('user_picture', $account);
-  foreach ($fields as $category => $items) {
-    if (strlen($category) > 0) {
-      $output .= '<h2 class="title">'. $category .'</h2>';
-    }
-    $output .= '<dl>';
-    foreach ($items as $item) {
-      if (isset($item['title'])) {
-        $output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
-      }
-      $output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
-    }
-    $output .= '</dl>';
-  }
+  $output .= $account->content;
   $output .= '</div>';
-
   return $output;
 }
 
@@ -1653,24 +1649,31 @@ function user_edit_submit($form_values, 
 function user_view($account) {
   global $user;
 
+  // Retrieve all profile fields and store data in profile element
+  $account->profile = user_build_content($account);
+  // Render all profile fields to the $account->content element
+  $account->content = drupal_render($account->profile);
   drupal_set_title(check_plain($account->name));
-  // Retrieve and merge all profile fields:
-  $fields = array();
-  foreach (module_list() as $module) {
-    if ($data = module_invoke($module, 'user', 'view', '', $account)) {
-      foreach ($data as $category => $items) {
-        foreach ($items as $key => $item) {
-          $item['class'] = "$module-". $item['class'];
-          $fields[$category][$key] = $item;
-        }
-      }
-    }
-  }
+  return theme('user_profile', $account);
+}
 
-  drupal_alter('profile', $fields, $account);
+/**
+ * Builds a structured array representing the profile content.
+ *
+ * @param $account
+ *   A user object.
+ *
+ * @return
+ *   An structured array containing the individual elements
+ *   of the profile.
+ */
+function user_build_content($account) {
+  $edit = NULL;
+  user_module_invoke('view', $edit, $account);
+  // Allow modules to modify the fully-built profile.
+  drupal_alter('alter', $edit, $account);
 
-  drupal_set_title(check_plain($account->name));
-  return theme('user_profile', $account, $fields);
+  return $account->content;
 }
 
 /*** Administrative features ***********************************************/
@@ -2796,6 +2799,44 @@ function theme_user_filters($form) {
 }
 
 /**
+ * Format a profile category as a definition list.
+ *
+ * @param $element
+ *   An associative array containing the properties of the element.
+ *   Properties used: attributes, title, value
+ * @return
+ *   A themed HTML string representing the profile category as a definition
+ *   list.
+ */
+function theme_profile_category($element) {
+  $output = '';
+  if ($element['#title'] != '') {
+    $output .= '<h3>'. check_plain($element['#title']) .'</h3>';
+  }
+  $output .= '<dl'. (isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '') .'>';
+  $output .= $element['#children'];
+  $output .= '</dl>';
+  return $output;
+}
+
+/**
+ * Format a profile item as a definition list.
+ *
+ * @param $element
+ *   An associative array containing the properties of the element.
+ *   Properties used: attributes, title, value
+ * @return
+ *   A themed HTML string.
+ */
+function theme_profile_item($element) {
+  if ($element['#title'] != '') {
+    $output = '<dt'. (isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '') .'>'. $element['#title'] .'</dt>';
+    $output .= '<dd'. (isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '') .'>' . $element['#value'] .'</dd>';
+    return $output;
+  }
+}
+
+/**
  * Process result from user administration filter form.
  */
 function user_filter_form_submit($form_values, $form, &$form_state) {
