# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: nodereview/nodereview.module
--- modules/nodereview/nodereview.module Base (1.5.2.3)
+++ nodereview/nodereview.module Locally Modified (Based On 1.5.2.3)
@@ -361,7 +361,7 @@
   );
 
   // We'll store field information in its own table
-  $result = db_query("SELECT aid, tag, weight FROM {nodereview_axes} WHERE node_type='%s' ORDER BY weight", $type);
+  $result = db_query("SELECT aid, tag, weight FROM {nodereview_axes} WHERE node_type='%s' ORDER BY weight, tag", $type);
   //$result = db_query("SELECT aid, tag, weight FROM {nodereview_axes} ORDER BY weight");
 
   $axes = array();
@@ -447,7 +447,7 @@
   static $axes = array();
 
   if (! isset($axes[$node_type])) {
-    $result = db_query("SELECT na.aid, na.tag FROM {nodereview_axes} na WHERE na.node_type='%s'", $node_type);
+    $result = db_query("SELECT na.aid, na.tag FROM {nodereview_axes} na WHERE na.node_type='%s' ORDER BY weight, tag", $node_type);
     while ($record = db_fetch_object($result)) {
       $axes[$node_type][$record->aid] = $record->tag;
     }
Index: nodereview/nodereview_node_nodereview.inc
--- nodereview/nodereview_node_nodereview.inc Base (1.6)
+++ nodereview/nodereview_node_nodereview.inc Locally Modified (Based On 1.6)
@@ -251,9 +251,6 @@
 function nodereview_view($node, $teaser = FALSE, $page = FALSE) {
   //$node = node_prepare($node, $teaser);
 
-  $aids = array_keys($node->reviews);
-  $num_aids = sizeof($aids);
-
   // Previews are just plain ugly, because the $node object is not really a node
   // but a mutated $_POST.  It has to be handled completely differently.
   if ($node->in_preview) {
@@ -278,8 +275,8 @@
     $node = node_prepare($node, $teaser);
 
     // Do a markup check on the fields
-    for ($i=0; $i < $num_aids; $i++) {
-      $node->reviews[$aids[$i]]->review = check_markup($node->reviews[$aids[$i]]->review);
+    foreach ($node->reviews as $review) {
+      $review->review = check_markup($review->review);
     }
 
     if ($teaser) {
@@ -300,6 +297,41 @@
   }
 }
 
+function nodereview_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+  switch ($op) {
+    case 'view':
+      // if not teaser view
+      if (!$a3) {
+        $node->content['axes_tallies'] = array(
+          '#value'  => _nodereview_tally($node->nid, $node->type),
+          '#weight' => -10,
+        );
+      }
+      break;
+  }
+}
+
+function _nodereview_tally($nid, $type) {
+  $votes_obj = votingapi_get_voting_results('node', $nid);
+  if ($votes_obj) {
+    $avg = array();
+    foreach ($votes_obj as $vote) {
+      if ($vote->function == 'average') $avg[$vote->tag] = $vote->value;
+    }
+
+    $axes = nodereview_list_axes($type);
+    $header[] = t('aspect');
+    $row[] = array('class' => 'row_title', 'header' => true, 'data' => t('average'));
+    foreach ($axes as $axis) {
+      $header[] = $axis;
+      $row[] = (NODEREVIEW_FIVESTAR_ENABLE) ?
+        theme('fivestar_static', $avg[$axis], variable_get('nodereview_fivestar_stars', 5)):
+        $avg[$axis]/10 . '/10';
+    }
+    return $output = theme('table', $header, array($row), array('class'=>'axes_tallies'));
+  }
+}
+
 /* ----- Theme functions ----- */
 
 function theme_nodereview_review_body($review, $node) {
Index: nodereview/nodereview_views.inc
--- nodereview/nodereview_views.inc Base (1.5)
+++ nodereview/nodereview_views.inc Locally Modified (Based On 1.5)
@@ -80,7 +80,7 @@
 function nodereview_views_default_views() {
   $view = new stdClass();
   $view->name = 'review_list';
-  $view->description = 'A list of teasers for reviews of a given node';
+  $view->description = t('A list of teasers for reviews of a given node');
   $view->access = array (
     0 => '1',
     1 => '2',
@@ -92,7 +92,7 @@
   $view->page_header_format = '1';
   $view->page_footer = '';
   $view->page_footer_format = '1';
-  $view->page_empty = 'No reviews have been submitted.  Maybe you should be the first?';
+  $view->page_empty = t('No reviews have been submitted.  Maybe you should be the first?');
   $view->page_empty_format = '1';
   $view->page_type = 'teaser';
   $view->url = 'node/$arg/reviews';
@@ -151,3 +151,7 @@
   
   return $views;
 }
+
+function nodereview_views_pre_view(&$view, &$items) {
+  return _nodereview_tally($view->args[0], node_load($view->args[0])->type);
+}
