### Eclipse Workspace Patch 1.0
#P Archive
Index: archive.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/archive/archive.module,v
retrieving revision 1.8.2.16
diff -u -r1.8.2.16 archive.module
--- archive.module	29 Dec 2007 17:23:18 -0000	1.8.2.16
+++ archive.module	3 Jan 2008 08:27:40 -0000
@@ -300,41 +300,28 @@
 
 /**
  * Returns a single month as a calendar grid
- * TODO: take the archive logic out to allow better theme-overloading of this
- *       Pass days with post numbers to this function and have this function
- *       only create the calendar
  * 
  */
-
-function theme_archive_block_calendar($timestamp) {
+function theme_archive_block_calendar($day_posts, $month_post_count, $timestamp) {
   $the_date = explode(' ', format_date($timestamp, 'custom', 'F Y n t'));
-  $title = $the_date[0] .' '. $the_date[1];
   $year = $the_date[1];
   $month = $the_date[2];
   $num_days = (int)$the_date[3];
   
-  $date = _archive_date('all', $year, $month);
-  
-  $month_title = '';
-  if ($date->months[$month]) {
-    $month_title = l($title, _archive_url('all', $year, $month), array('title' => format_plural($date->months[format_date($timestamp, 'custom', 'n')], '1 post', '@count posts')));
-  }
-  else {
-    $month_title = $title;
+  // Fashion us up a nice title
+  $title = $the_date[0] .' '. $the_date[1];
+  if ($month_post_count) {
+    $title = l($title, _archive_url('all', $year, $month), array('title' => format_plural($month_post_count, '1 post', '@count posts')));
   }
   
-  $rows[] = array(
-    array('data' => $month_title, 'colspan' => 7, 'style' => 'text-align:center'),
-  );
-  
-  // Build the week starting with 
+  // Build the week starting with the first day
   $first_day_of_week = variable_get('date_first_day', 0);
   $week = array(t('Sun'), t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'));
   $day_titles = array();
   for ($i = $first_day_of_week; $i < $first_day_of_week + 7; $i++) {
     $day_titles[] = $week[$i%7];
   }
-  $rows[] = $day_titles;
+
   // this is inefficient but necessary to determine the start of the month:
   // We use gmdate the first time so that we don't apply the user's timezone twice
   list($start_year, $start_month) = explode(' ', format_date($timestamp, 'custom', 'Y m'));
@@ -344,8 +331,8 @@
   // From http://www.theadminzone.com/forums/showthread.php?t=17490
   for ($i = 1-$weekday;$i <= ceil(($weekday+$num_days)/7)*7;$i++) {
     if ($i > 0) {
-      if (array_key_exists($i, $date->days)) {
-        $days_row[] = l($i, _archive_url('all', $year, $month, $i), array('title' => format_plural($date->days[$i], '1 post', '@count posts')));
+      if (array_key_exists($i, $day_posts)) {
+        $days_row[] = l($i, _archive_url('all', $year, $month, $i), array('title' => format_plural($day_posts[$i], '1 post', '@count posts')));
       }
       else if ($i <= $num_days) {
         $days_row[] = $i;
@@ -364,7 +351,7 @@
       $days_row[] = '';
     }
   }
-  return theme('table', array(), $rows);
+  return theme('table', $day_titles, $rows, array(), $title);
 }
 
 /**
@@ -377,9 +364,15 @@
     return $blocks;
   }
   else if ($op == 'view') {
+    
+    list($year, $month) = explode(' ', format_date(time(), 'custom', 'Y n'));
+    $date = _archive_date('all', $year, $month);
+    
+    $month_post_count = is_null($date->months[$month])?0:$date->months[$month];
+
     $block = array(
       'subject' => t('Archives'),
-      'content' => theme('archive_block_calendar', time()),
+      'content' => theme('archive_block_calendar', $date->days, $month_post_count, time()),
     );
     return $block;
   }
Index: TODO.txt
===================================================================
RCS file: TODO.txt
diff -N TODO.txt
--- TODO.txt	7 Sep 2007 18:45:01 -0000	1.3.2.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
-Separate theme functions from logic
-Explore reformatting day numbers into calendar-like layout
\ No newline at end of file
