? drbm.tmproj
? mw.patch
? modules/node/node-admin-display-overview-form.tpl.php
? modules/node/node.build_mode.inc
? sites/all/modules
? sites/default/files
Index: index.php
===================================================================
RCS file: /cvs/drupal/drupal/index.php,v
retrieving revision 1.96
diff -u -F^f -p -r1.96 index.php
--- index.php	20 Sep 2008 20:22:23 -0000	1.96
+++ index.php	26 Dec 2008 04:17:08 -0000
@@ -35,6 +35,10 @@ if (is_int($return)) {
       break;
   }
 }
+elseif (is_array($return)) {
+  // The preferred return value of a menu callback is an array.
+  print theme('page', drupal_render($return));
+}
 elseif (isset($return)) {
   // Print any value (including an empty string) except NULL or undefined:
   print theme('page', $return);
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.456
diff -u -F^f -p -r1.456 theme.inc
--- includes/theme.inc	16 Dec 2008 22:05:50 -0000	1.456
+++ includes/theme.inc	26 Dec 2008 04:17:09 -0000
@@ -588,7 +588,6 @@ function list_themes($refresh = FALSE) {
 function theme() {
   $args = func_get_args();
   $hook = array_shift($args);
-
   static $hooks = NULL;
   if (!isset($hooks)) {
     init_theme();
@@ -1977,8 +1976,13 @@ function template_preprocess_page(&$vari
  * @see node.tpl.php
  */
 function template_preprocess_node(&$variables) {
+  // For convenience, alias several variables to as top level elements.
+  $variables['node'] = &$variables['elements']['node'];
+  $variables['page'] = &$variables['elements']['page'];
+  $variables['teaser'] = &$variables['elements']['teaser'];
+  
   $node = $variables['node'];
-
+  
   $variables['date']      = format_date($node->created);
   $variables['name']      = theme('username', $node);
   $variables['node_url']  = url('node/' . $node->nid);
@@ -1993,6 +1997,9 @@ function template_preprocess_node(&$vari
   
   // Render all remaining node links.
   $variables['links']     = !empty($node->content['links']) ? drupal_render($node->content['links']) : '';
+  
+  // Render any comments.
+  $variables['comments']     = !empty($node->content['comments']) ? drupal_render($node->content['comments']) : '';
 
   // Render the rest of the node into $content.
   if (!empty($node->content['teaser'])) {
Index: modules/comment/comment.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.css,v
retrieving revision 1.4
diff -u -F^f -p -r1.4 comment.css
--- modules/comment/comment.css	24 Jul 2007 21:33:53 -0000	1.4
+++ modules/comment/comment.css	26 Dec 2008 04:17:09 -0000
@@ -1,5 +1,8 @@
 /* $Id: comment.css,v 1.4 2007/07/24 21:33:53 goba Exp $ */
 
+#comments {
+  margin-top: 15px;
+}
 .indented {
   margin-left: 25px; /* LTR */
 }
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.673
diff -u -F^f -p -r1.673 comment.module
--- modules/comment/comment.module	20 Dec 2008 18:24:35 -0000	1.673
+++ modules/comment/comment.module	26 Dec 2008 04:17:10 -0000
@@ -493,6 +493,13 @@ function comment_nodeapi_view($node, $te
       '#type' => 'node_links',
       '#value' => $links,
     );
+    
+    // Append the list of comments to $node->content.
+    if ($node->comment) {
+      $node->content['comments'] = array(
+        '#markup' => comment_render($node),
+      );
+    }
   }
 }
 
@@ -662,6 +669,14 @@ function comment_nodeapi_update_index($n
 }
 
 /**
+ * Implementation of hook_update_index().
+ */
+function comment_update_index() {
+  // Store the maximum possible comments per thread (used for ranking by reply count)
+  variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
+}
+
+/**
  * Implementation of hook_nodeapi_search_result().
  */
 function comment_nodeapi_search_result($node) {
@@ -740,7 +755,8 @@ function comment_node_url() {
  */
 function comment_save($edit) {
   global $user;
-  if (user_access('post comments') && (user_access('administer comments') || node_comment_mode($edit['nid']) == COMMENT_NODE_READ_WRITE)) {
+  $node = node_load($edit['nid']);
+  if (user_access('post comments') && (user_access('administer comments') || comment_node_mode($node) == COMMENT_NODE_READ_WRITE)) {
     if (!form_get_errors()) {
       $edit += array(
         'mail' => '',
@@ -902,7 +918,8 @@ function comment_links($comment, $return
     );
   }
 
-  if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
+  $node = node_load($comment->nid);
+  if (comment_node_mode($node) == COMMENT_NODE_READ_WRITE) {
     if (user_access('administer comments') && user_access('post comments')) {
       $links['comment_delete'] = array(
         'title' => t('delete'),
@@ -1117,7 +1134,7 @@ function comment_render($node, $cid = 0)
 
     // If enabled, show new comment form if it's not already being displayed.
     $reply = arg(0) == 'comment' && arg(1) == 'reply';
-    if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW) && !$reply) {
+    if (user_access('post comments') && comment_node_mode($node) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW) && !$reply) {
       $output .= comment_form_box(array('nid' => $nid), t('Post new comment'));
     }
     $output = theme('comment_wrapper', $output, $node);
@@ -2158,3 +2175,10 @@ function comment_ranking() {
     ),
   );
 }
+
+/**
+ * Retrieve the comment mode for the given node (none, read, or read/write).
+ */
+function comment_node_mode($node) {
+  return $node->comment;
+}
Index: modules/comment/comment.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v
retrieving revision 1.10
diff -u -F^f -p -r1.10 comment.pages.inc
--- modules/comment/comment.pages.inc	3 Dec 2008 16:32:21 -0000	1.10
+++ modules/comment/comment.pages.inc	26 Dec 2008 04:17:10 -0000
@@ -96,7 +96,7 @@ function comment_reply($node, $pid = NUL
       }
 
       // Should we show the reply box?
-      if (node_comment_mode($node->nid) != COMMENT_NODE_READ_WRITE) {
+      if (comment_node_mode($node) != COMMENT_NODE_READ_WRITE) {
         drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
         drupal_goto("node/$node->nid");
       }
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1004
diff -u -F^f -p -r1.1004 node.module
--- modules/node/node.module	20 Dec 2008 18:24:38 -0000	1.1004
+++ modules/node/node.module	26 Dec 2008 04:17:10 -0000
@@ -96,7 +96,7 @@ function node_help($path, $arg) {
 function node_theme() {
   return array(
     'node' => array(
-      'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
+      'arguments' => array('elements' => NULL),
       'template' => 'node',
     ),
     'node_list' => array(
@@ -1123,7 +1123,7 @@ function node_delete($nid) {
 }
 
 /**
- * Generate a display of the given node.
+ * Generate an array for rendering the given node.
  *
  * @param $node
  *   A node array or node object.
@@ -1131,18 +1131,24 @@ function node_delete($nid) {
  *   Whether to display the teaser only or the full form.
  * @param $page
  *   Whether the node is being displayed by itself as a page.
- * @param $links
- *   Whether or not to display node links. Links are omitted for node previews.
  *
  * @return
- *   An HTML representation of the themed node.
+ *   An array as expected by drupal_render().
  */
 function node_view($node, $teaser = FALSE, $page = FALSE) {
   $node = (object)$node;
 
   $node = node_build_content($node, $teaser, $page);
+  
+  $render = $node->content;
+  $render += array(
+    '#theme' => 'node',
+    'node' => $node,
+    'page' => $page,
+    'teaser' => $teaser,
+  );
 
-  return theme('node', $node, $teaser, $page);
+  return $render;
 }
 
 /**
@@ -1212,23 +1218,17 @@ function node_build_content($node, $teas
 }
 
 /**
- * Generate a page displaying a single node, along with its comments.
+ * Generate an array which displays a single node.
  */
-function node_show($node, $cid, $message = FALSE) {
+function node_show($node, $message = FALSE) {
   if ($message) {
     drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
   }
 
-  $output = node_view($node, FALSE, TRUE);
-
-  if (function_exists('comment_render') && $node->comment) {
-    $output .= comment_render($node, $cid);
-  }
-
   // Update the history table, stating that this user viewed this node.
   node_tag_new($node->nid);
 
-  return $output;
+  return node_view($node, FALSE, TRUE);
 }
 
 /**
@@ -1514,14 +1514,6 @@ function theme_node_search_admin($form) 
 }
 
 /**
- * Retrieve the comment mode for the given node ID (none, read, or read/write).
- */
-function node_comment_mode($nid) {
-  $node = node_load($nid);
-  return $node->comment;
-}
-
-/**
  * Implementation of hook_link().
  */
 function node_link($type, $node = NULL, $teaser = FALSE) {
@@ -1720,7 +1712,7 @@ function node_menu() {
     'title' => 'Revisions',
     'load arguments' => array(3),
     'page callback' => 'node_show',
-    'page arguments' => array(1, NULL, TRUE),
+    'page arguments' => array(1, TRUE),
     'access callback' => '_node_revision_access',
     'access arguments' => array(1),
     'type' => MENU_CALLBACK,
@@ -1894,14 +1886,20 @@ function node_page_default() {
   $nids = pager_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10))->fetchCol();
   if (!empty($nids)) {
     $nodes = node_load_multiple($nids);
-    $output = '';
+    $render = array();
+    $weight = 0;
     foreach ($nodes as $node) {
-      $output .= node_view($node, TRUE);
+      $render["node_$node->nid"] = node_view($node, TRUE);
+      $render["node_$node->nid"]['#weight'] = $weight;
+      $weight++;
     }
 
     $feed_url = url('rss.xml', array('absolute' => TRUE));
     drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') . ' ' . t('RSS'));
-    $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
+    $render['pager'] = array(
+      '#markup' => theme('pager', NULL, variable_get('default_nodes_main', 10)),
+      '#weight' => $weight,
+    );
   }
   else {
     $default_message = '<h1 class="title">' . t('Welcome to your new Drupal website!') . '</h1>';
@@ -1914,19 +1912,21 @@ function node_page_default() {
     $default_message .= '</ol>';
     $default_message .= '<p>' . t('For more information, please refer to the <a href="@help">help section</a>, or the <a href="@handbook">online Drupal handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a>, or view the wide range of <a href="@support">other support options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/handbooks', '@forum' => 'http://drupal.org/forum', '@support' => 'http://drupal.org/support')) . '</p>';
 
-    $output = '<div id="first-time">' . $default_message . '</div>';
+    $render = array(
+      '#markup' => '<div id="first-time">' . $default_message . '</div>',
+    );
   }
   drupal_set_title('');
 
-  return $output;
+  return $render;
 }
 
 /**
  * Menu callback; view a single node.
  */
-function node_page_view($node, $cid = NULL) {
+function node_page_view($node) {
   drupal_set_title($node->title);
-  return node_show($node, $cid);
+  return node_show($node);
 }
 
 /**
@@ -1935,8 +1935,6 @@ function node_page_view($node, $cid = NU
 function node_update_index() {
   $limit = (int)variable_get('search_cron_limit', 100);
 
-  // Store the maximum possible comments per thread (used for ranking by reply count)
-  variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
   variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
 
   $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
Index: modules/node/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.tpl.php,v
retrieving revision 1.5
diff -u -F^f -p -r1.5 node.tpl.php
--- modules/node/node.tpl.php	13 Oct 2008 12:31:42 -0000	1.5
+++ modules/node/node.tpl.php	26 Dec 2008 04:17:10 -0000
@@ -8,6 +8,7 @@
  * Available variables:
  * - $title: the (sanitized) title of the node.
  * - $content: Node body or teaser depending on $teaser flag.
+ * - $comments: the themed list of comments (if any).
  * - $picture: The authors picture of the node output from
  *   theme_user_picture().
  * - $date: Formatted creation date (use $created to reformat with
@@ -70,4 +71,7 @@
   </div>
 
   <?php print $links; ?>
+  
+  <?php print $comments; ?>
+  
 </div>
\ No newline at end of file
Index: modules/poll/poll.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.pages.inc,v
retrieving revision 1.10
diff -u -F^f -p -r1.10 poll.pages.inc
--- modules/poll/poll.pages.inc	5 Dec 2008 12:50:28 -0000	1.10
+++ modules/poll/poll.pages.inc	26 Dec 2008 04:17:10 -0000
@@ -53,5 +53,5 @@ function poll_votes($node) {
 function poll_results($node) {
   drupal_set_title($node->title);
   $node->show_results = TRUE;
-  return node_show($node, 0);
+  return node_show($node);
 }
Index: modules/poll/poll.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.test,v
retrieving revision 1.14
diff -u -F^f -p -r1.14 poll.test
--- modules/poll/poll.test	18 Dec 2008 14:38:37 -0000	1.14
+++ modules/poll/poll.test	26 Dec 2008 04:17:10 -0000
@@ -19,7 +19,7 @@ class PollTestCase extends DrupalWebTest
 
     // Get the form first to initialize the state of the internal browser
     $this->drupalGet('node/add/poll');
-
+    
     // Prepare a form with two choices
     list($edit, $index) = $this->_pollGenerateEdit($title, $choices);
 
Index: themes/bluemarine/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/bluemarine/node.tpl.php,v
retrieving revision 1.7
diff -u -F^f -p -r1.7 node.tpl.php
--- themes/bluemarine/node.tpl.php	7 Aug 2007 08:39:36 -0000	1.7
+++ themes/bluemarine/node.tpl.php	26 Dec 2008 04:17:10 -0000
@@ -10,4 +10,5 @@
     <div class="taxonomy"><?php print $terms?></div>
     <div class="content"><?php print $content?></div>
     <?php if ($links) { ?><div class="links">&raquo; <?php print $links?></div><?php }; ?>
+    <?php print $comments; ?>
   </div>
Index: themes/chameleon/chameleon.theme
===================================================================
RCS file: /cvs/drupal/drupal/themes/chameleon/chameleon.theme,v
retrieving revision 1.82
diff -u -F^f -p -r1.82 chameleon.theme
--- themes/chameleon/chameleon.theme	16 Dec 2008 22:05:51 -0000	1.82
+++ themes/chameleon/chameleon.theme	26 Dec 2008 04:17:10 -0000
@@ -153,6 +153,10 @@ function chameleon_node($node, $teaser =
   }
 
   $output .= "</div>\n";
+  
+  if ($node->content['comments']) {
+    $output .= drupal_render($node->content['comments']);
+  }
 
   return $output;
 }
Index: themes/garland/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/node.tpl.php,v
retrieving revision 1.5
diff -u -F^f -p -r1.5 node.tpl.php
--- themes/garland/node.tpl.php	11 Oct 2007 09:51:29 -0000	1.5
+++ themes/garland/node.tpl.php	26 Dec 2008 04:17:10 -0000
@@ -27,6 +27,9 @@
     <?php if ($links): ?>
       <div class="links"><?php print $links; ?></div>
     <?php endif; ?>
+    
+    <?php print $comments; ?>
+    
   </div>
 
 </div>
Index: themes/pushbutton/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/pushbutton/node.tpl.php,v
retrieving revision 1.4
diff -u -F^f -p -r1.4 node.tpl.php
--- themes/pushbutton/node.tpl.php	7 Aug 2007 08:39:36 -0000	1.4
+++ themes/pushbutton/node.tpl.php	26 Dec 2008 04:17:10 -0000
@@ -11,5 +11,8 @@
     <div class="content"><?php print $content ?></div>
     <?php if ($links): ?>
     <div class="links">&raquo; <?php print $links ?></div>
+    
+    <?php print $comments; ?>
+      
     <?php endif; ?>
 </div>
