? patch_drupal7.patch
Index: archive.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/archive/archive.admin.inc,v
retrieving revision 1.6
diff -u -p -r1.6 archive.admin.inc
--- archive.admin.inc	4 Jan 2008 12:25:33 -0000	1.6
+++ archive.admin.inc	15 Jun 2010 16:48:28 -0000
@@ -4,8 +4,8 @@
 /**
  * Form building callback for the archive settings page.
  */
-function archive_admin_settings() {  
-  $types = node_get_types();
+function archive_admin_settings() {
+  $types = node_type_get_types();
   $final_types = array();
   foreach ($types as $key => $value) {
     $final_types[$key] = $value->name;
@@ -18,6 +18,6 @@ function archive_admin_settings() {  
     '#options'       => $final_types,
     '#description'   => t('Posts of these types will be displayed in the archive.')
   );
-  
+
   return system_settings_form($form);
 }
Index: archive.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/archive/archive.info,v
retrieving revision 1.9
diff -u -p -r1.9 archive.info
--- archive.info	4 Jan 2008 12:21:36 -0000	1.9
+++ archive.info	15 Jun 2010 16:48:28 -0000
@@ -1,5 +1,8 @@
 ; $Id: archive.info,v 1.9 2008/01/04 12:21:36 susurrus Exp $
 name = Archive
 description = Allows visitors to view content filtered by date or node type.
-core = 6.x
-package = Content display
\ No newline at end of file
+core = 7.x
+package = "Content display"
+files[] = "archive.module"
+files[] = "archive.admin.inc"
+files[] = "archive.pages.inc"
Index: archive.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/archive/archive.module,v
retrieving revision 1.36.2.4
diff -u -p -r1.36.2.4 archive.module
--- archive.module	19 Aug 2008 23:00:53 -0000	1.36.2.4
+++ archive.module	15 Jun 2010 16:48:28 -0000
@@ -2,34 +2,41 @@
 // $Id: archive.module,v 1.36.2.4 2008/08/19 23:00:53 susurrus Exp $
 
 /**
+ * @file
+ * Implements a block and page showing an archive of all site content.
+ */
+
+/**
  * Implementation of hook_help().
  */
 function archive_help($path, $arg) {
-	switch ($path) {
-		case 'admin/help#archive':
-			$output = '<p>'. t('The archive module allows your users to browse your content by its type and date of publication. The archive module interface, available at the path <a href="@archive">archive</a>, presents simple controls for selecting a year, month or day. All available posts published within this range are displayed beneath the control. Administrators may select the content types to be displayed. The archive module adds an <em>Archives</em> menu item to the default <em>Navigation</em> menu (the item is disabled by default), and displays the current month and year within an optional block.', array('@archive' => url('archive'))) .'</p>';
-			$output .= '<p>'. t('You can') .'</p>';
-			$output .= '<ul><li>'. t('view your <a href="@archive">archive page</a>.', array('@archive' => url('archive'))) .'</li>';
-			$output .= '<li>'. t('enable, position and configure the <em>Current calendar month with archive links</em> block at the <a href="@blocks">blocks administration page</a>.', array('@blocks' => url('admin/build/block'))) .'</li>';
-			$output .= '<li>'. t('enable or disable the <em>Archives</em> menu item on the <a href="@menu-administration">navigation menu administration page</a>.', array('@menu-administration' => url('admin/build/menu-customize/navigation'))) .'</li></ul>';
-			$output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-page">Archive module</a>.', array('@handbook-page' => 'http://drupal.org/handbook/modules/archive/')) .'</p>';
-			return $output;
-	}
+  switch ($path) {
+    case 'admin/help#archive':
+      $output = '<p>'. t('The archive module allows your users to browse your content by its type and date of publication. The archive module interface, available at the path !archive_link, presents simple controls for selecting a year, month or day. All available posts published within this range are displayed beneath the control. Administrators may select the content types to be displayed. The archive module adds an <em>Archives</em> menu item to the default <em>Navigation</em> menu (the item is disabled by default), and displays the current month and year within an optional block.', array('!archive_link' => l(t('archive'), 'archive'))) .'</p>';
+      $output .= '<p>'. t('You can') .'</p>';
+      $output .= theme('item_list', array('items' => array(
+        t('view your !archive_link.', array('!archive_link' => l(t('Archive'), 'archive'))),
+        t('enable, position and configure the <em>Current calendar month with archive links</em> block at the !blocks.', array('!blocks' => l(t('blocks administration page'), 'admin/build/block'))),
+        t('enable or disable the <em>Archives</em> menu item on the !menu-administration.', array('!menu-administration' => l(t('navigation menu administration page'), 'admin/build/menu-customize/navigation')))
+      )));
+      $output .= '<p>'. t('For more information, see the online handbook entry for !handbook-page.', array('!handbook-page' => l(t('Archive module'), 'http://drupal.org/handbook/modules/archive'))) .'</p>';
+      return $output;
+  }
 }
 
 /**
  * Implementation of hook_menu().
  */
 function archive_menu() {
-	$items = array();
-	$items['archive'] = array(
+  $items = array();
+  $items['archive'] = array(
     'title'            => 'Archives',
     'access arguments' => array('access content'),
     'page callback'    => 'archive_page',
     'file'             => 'archive.pages.inc',
     'type'             => MENU_SUGGESTED_ITEM
-	);
-	$items['admin/settings/archive'] = array(
+  );
+  $items['admin/config/user-interface/archive'] = array(
     'title'            => 'Archives',
     'description'      => 'Select the content types listed in the archives.',
     'page callback'    => 'drupal_get_form',
@@ -37,16 +44,16 @@ function archive_menu() {
     'access arguments' => array('access administration pages'),
     'file'             => 'archive.admin.inc',
     'type'             => MENU_NORMAL_ITEM
-	);
+  );
 
-	return $items;
+  return $items;
 }
 
 /**
  * Implementation of hook_uninstall().
  */
 function archive_uninstall() {
-	variable_del('archive_type_filters');
+  variable_del('archive_type_filters');
 }
 
 
@@ -54,32 +61,16 @@ function archive_uninstall() {
  * Implementation of hook_theme().
  */
 function archive_theme() {
-	return array(
-    'archive_block_calendar' => array(
-      'arguments' => array('timestamp' => 0)
-	),
-    'archive_page_title' => array(
-      'arguments' => array('type' => '', 'year' => NULL, 'month' => NULL, 'day' => NULL)
-	),
-    'archive_navigation' => array(
-      'arguments' => array('type' => '', 'date' => NULL)
-	),
-    'archive_navigation_days' => array(
-      'arguments' => array('type' => '', 'date' => NULL)
-	),
-    'archive_navigation_months' => array(
-      'arguments' => array('type' => '', 'date' => NULL)
-	),
-    'archive_navigation_node_types' => array(
-      'arguments' => array('type' => '', 'date' => NULL)
-	),
-    'archive_navigation_years' => array(
-      'arguments' => array('type' => '', 'date' => NULL)
-	),
-    'archive_separator' => array(
-      'arguments' => array('date_created' => 0, 'separators' => array())
-	),
-	);
+  return array(
+    'archive_block_calendar' => array('variables' => array('timestamp' => 0)),
+    'archive_page_title' => array('variables' => array('type' => '', 'year' => NULL, 'month' => NULL, 'day' => NULL)),
+    'archive_navigation' => array('variables' => array('type' => '', 'date' => NULL)),
+    'archive_navigation_days' => array('variables' => array('type' => '', 'date' => NULL)),
+    'archive_navigation_months' => array('variables' => array('type' => '', 'date' => NULL)),
+    'archive_navigation_node_types' => array('variables' => array('type' => '', 'date' => NULL)),
+    'archive_navigation_years' => array('variables' => array('type' => '', 'date' => NULL)),
+    'archive_separator' => array('variables' => array('date_created' => 0, 'separators' => array())),
+  );
 }
 
 /**
@@ -89,118 +80,121 @@ function archive_theme() {
  *   Take the archive logic out to allow better theme-overloading
  *   of this function.
  */
-function theme_archive_block_calendar($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];
-
-	// Get the number of days for the previous month for adding those dates
-	// to the block calendar. Store the month/year for the previous month
-	// so that we can find and link to archive pages in those extra days.
-	// We don't need to get days for the next month as we'll never need to fit
-	// the entire month into the block.
-	$prev_month = $month==1?12:$month-1;
-	$prev_year = $month==1?$year-1:$year;
-	$num_days_prev = cal_days_in_month(CAL_GREGORIAN, $month-1, $year);
-	$next_month = $month==12?1:$month+1;
-	$next_year = $month==12?$year+1:$year;
-
-	$date = _archive_date('all', $year, $month);
-	$month_title = '';
-	if (isset($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;
-	}
-
-	// Build the week starting with
-	$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_headers = array();
-	for ($i = $first_day_of_week; $i < $first_day_of_week + 7; $i++) {
-		$day_headers[] = $week[$i%7];
-	}
-
-	// Grab the first day of the month using the user's timezone
-	list($start_year, $start_month) = explode(' ', format_date($timestamp, 'custom', 'Y m'));
-	$start = gmmktime( 0, 0, 0, (int)$start_month, 1, (int)$start_year);
-	$weekday = gmdate('w', $start) - $first_day_of_week;
-	$days_row = array();
-
-	// 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('attributes' => array('title' => format_plural($date->days[$i], '1 post', '@count posts'))));
-			}
-			else if ($i <= $num_days) {
-				$days_row[] = $i;
-			}
-			// Add days for the next month.
-			else {
-				$curr_cal_date = $i - $num_days;
-				if (isset($date->next_month_days[$curr_cal_date])) {
-					$data = l($curr_cal_date,
-					_archive_url('all', $next_year, $next_month, $curr_cal_date),
-					array('attributes' => array('title' => format_plural($date->next_month_days[$curr_cal_date], '1 post', '@count posts'))));
-				}
-				else {
-					$data = $curr_cal_date;
-				}
-				$days_row[] = array(
+function theme_archive_block_calendar($variables) {
+  $the_date = explode(' ', format_date($variables['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];
+
+  // Get the number of days for the previous month for adding those dates
+  // to the block calendar. Store the month/year for the previous month
+  // so that we can find and link to archive pages in those extra days.
+  // We don't need to get days for the next month as we'll never need to fit
+  // the entire month into the block.
+  $prev_month = $month==1?12:$month-1;
+  $prev_year = $month==1?$year-1:$year;
+  $num_days_prev = cal_days_in_month(CAL_GREGORIAN, $month-1, $year);
+  $next_month = $month==12?1:$month+1;
+  $next_year = $month==12?$year+1:$year;
+
+  $date = _archive_date('all', $year, $month);
+  $month_title = '';
+  if (isset($date->months[$month])) {
+    $month_title = l($title, _archive_url('all', $year, $month), array('title' => format_plural($date->months[format_date($variables['timestamp'], 'custom', 'n')], '1 post', '@count posts')));
+  }
+  else {
+    $month_title = $title;
+  }
+
+  // Build the week starting with
+  $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_headers = array();
+  for ($i = $first_day_of_week; $i < $first_day_of_week + 7; $i++) {
+    $day_headers[] = $week[$i%7];
+  }
+
+  // Grab the first day of the month using the user's timezone
+  list($start_year, $start_month) = explode(' ', format_date($variables['timestamp'], 'custom', 'Y m'));
+  $start = gmmktime( 0, 0, 0, (int)$start_month, 1, (int)$start_year);
+  $weekday = gmdate('w', $start) - $first_day_of_week;
+  $days_row = array();
+
+  // 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('attributes' => array('title' => format_plural($date->days[$i], '1 post', '@count posts'))));
+      }
+      elseif ($i <= $num_days) {
+        $days_row[] = $i;
+      }
+      // Add days for the next month.
+      else {
+        $curr_cal_date = $i - $num_days;
+        if (isset($date->next_month_days[$curr_cal_date])) {
+          $data = l($curr_cal_date,
+          _archive_url('all', $next_year, $next_month, $curr_cal_date),
+          array('attributes' => array('title' => format_plural($date->next_month_days[$curr_cal_date], '1 post', '@count posts'))));
+        }
+        else {
+          $data = $curr_cal_date;
+        }
+        $days_row[] = array(
           'data' => $data,
           'class' => 'out-of-month'
         );
-			}
+      }
 
-			// Add the week table row we just created if we've finished it
-			if (($i+$weekday)%7 == 0) {
-				$rows[] = $days_row;
-				$days_row = array();
-			}
-		}
-		// Add days for previous month also.
-		else {
-			$curr_cal_date = $num_days_prev + $i;
-			if (isset($date->prev_month_days[$curr_cal_date])) {
-				$data = l($curr_cal_date,
-				_archive_url('all', $prev_year, $prev_month, $curr_cal_date),
-				array('attributes' => array('title' => format_plural($date->prev_month_days[$curr_cal_date], '1 post', '@count posts'))));
-			}
-			else {
-				$data = $curr_cal_date;
-			}
-			$days_row[] = array(
+      // Add the week table row we just created if we've finished it
+      if (($i+$weekday)%7 == 0) {
+        $rows[] = $days_row;
+        $days_row = array();
+      }
+    }
+    // Add days for previous month also.
+    else {
+      $curr_cal_date = $num_days_prev + $i;
+      if (isset($date->prev_month_days[$curr_cal_date])) {
+        $data = l($curr_cal_date,
+        _archive_url('all', $prev_year, $prev_month, $curr_cal_date),
+        array('attributes' => array('title' => format_plural($date->prev_month_days[$curr_cal_date], '1 post', '@count posts'))));
+      }
+      else {
+        $data = $curr_cal_date;
+      }
+      $days_row[] = array(
         'data' => $data,
         'class' => 'out-of-month'
       );
-		}
-	}
-	return theme('table', $day_headers, $rows, array(), $month_title);
+    }
+  }
+  return theme('table', array('header' => $day_headers, 'rows' => $rows, 'caption' => $month_title));
 }
 
 
 /**
- * Implementation of hook_block().
- */
-function archive_block($op = 'list', $delta = 0) {
-	if ($op == 'list') {
-		$blocks[0] = array('info' => t('Current calendar month with archive links'));
-		return $blocks;
-	}
-	else if ($op == 'view') {
-		drupal_add_css(drupal_get_path('module', 'archive') . '/archive.css');
-		$block = array(
-      'subject' => t('Archives'),
-      'content' => theme('archive_block_calendar', time()),
-		);
-		return $block;
-	}
+ * Implements hook_block().
+ */
+function archive_block_info() {
+  $blocks = array();
+  $blocks['month_archive']['info'] = t('Current calendar month with archive links');
+  return $blocks;
+}
+
+/*
+ * Implements hook_block_view().
+ */
+function archive_block_view($delta = NULL) {
+  drupal_add_css(drupal_get_path('module', 'archive') . '/archive.css');
+  $block = array(
+    'subject' => t('Archives'),
+    'content' => theme('archive_block_calendar', array('timestamp' => time())),
+  );
+  return $block;
 }
 
 /**
@@ -218,24 +212,24 @@ function archive_block($op = 'list', $de
  *   A string with the generated archive URL.
  */
 function _archive_url($type, $y = 0, $m = 0, $d = 0) {
-	$url = 'archive';
-	if (_archive_validate_type($type)) {
-		$url .= '/'. $type;
-	}
-	else {
-		$url .= '/all';
-	}
-
-	if (_archive_validate_date($y, $m, $d)) {
-		$url .= '/'. $y .'/'. $m .'/'. $d;
-	}
-	else if (_archive_validate_date($y, $m)) {
-		$url .= '/'. $y .'/'. $m;
-	}
-	else if (_archive_validate_date($y)) {
-		$url .= '/'. $y;
-	}
-	return $url;
+  $url = 'archive';
+  if (_archive_validate_type($type)) {
+    $url .= '/'. $type;
+  }
+  else {
+    $url .= '/all';
+  }
+
+  if (_archive_validate_date($y, $m, $d)) {
+    $url .= '/'. $y .'/'. $m .'/'. $d;
+  }
+  elseif (_archive_validate_date($y, $m)) {
+    $url .= '/'. $y .'/'. $m;
+  }
+  elseif (_archive_validate_date($y)) {
+    $url .= '/'. $y;
+  }
+  return $url;
 }
 
 /**
@@ -251,37 +245,37 @@ function _archive_url($type, $y = 0, $m 
  *   A date object with GMT date values and a timezone value.
  */
 function _archive_date($type, $year = 0, $month = 0, $day = 0) {
-	$date = new stdClass();
-	$date->tz = _archive_get_timezone();
+  $date = new stdClass();
+  $date->tz = _archive_get_timezone();
 
-	$date->year  = 0;
-	$date->month = 0;
-	$date->day   = 0;
-
-	if (_archive_validate_date($year, $month, $day)) {
-		$date->year = $year;
-		$date->month = $month;
-		$date->day = $day;
-	}
-	else if (_archive_validate_date($year, $month)) {
-		$date->year = $year;
-		$date->month = $month;
-	}
-	else if (_archive_validate_date($year)) {
-		$date->year = $year;
-	}
-
-	$post_counts = _archive_post_count($type, $date);
-	$date->years  = $post_counts['years'];
-	ksort($date->years);
-	$date->months = $post_counts['months'];
-	ksort($date->months);
-	$date->days   = $post_counts['days'];
-	ksort($date->days);
-	$date->next_month_days = $post_counts['next_month_days'];
-	$date->prev_month_days = $post_counts['prev_month_days'];
+  $date->year  = 0;
+  $date->month = 0;
+  $date->day   = 0;
+
+  if (_archive_validate_date($year, $month, $day)) {
+    $date->year = $year;
+    $date->month = $month;
+    $date->day = $day;
+  }
+  elseif (_archive_validate_date($year, $month)) {
+    $date->year = $year;
+    $date->month = $month;
+  }
+  elseif (_archive_validate_date($year)) {
+    $date->year = $year;
+  }
+
+  $post_counts = _archive_post_count($type, $date);
+  $date->years  = $post_counts['years'];
+  ksort($date->years);
+  $date->months = $post_counts['months'];
+  ksort($date->months);
+  $date->days   = $post_counts['days'];
+  ksort($date->days);
+  $date->next_month_days = $post_counts['next_month_days'];
+  $date->prev_month_days = $post_counts['prev_month_days'];
 
-	return $date;
+  return $date;
 }
 
 /**
@@ -291,37 +285,36 @@ function _archive_date($type, $year = 0,
  *   Timezone offset to use in time operations.
  */
 function _archive_get_timezone() {
-	global $user;
-	if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
-		return $user->timezone;
-	}
-	else {
-		return variable_get('date_default_timezone', 0);
-	}
-}
-
-function _archive_types_sql_string($type) {
-	// Validate type and specify node types to include
-	$final_types = '';
-	if (_archive_validate_type($type) && $type != 'all') {
-		$final_types = $type;
-	}
-	else {
-		$types = variable_get('archive_type_filters', array());
-		// If no checkboxes selected
-		if (!array_key_exists('0', $types)) {
-			foreach ($types as $key => $value) {
-				if (!$value) {
-					unset($types[$key]);
-				}
-			}
-			$final_types = implode("', '", array_keys($types));
-		}
-	}
-	if (strlen($final_types) > 0) {
-		$final_types = "AND n.type IN ('". $final_types ."') ";
-	}
-	return $final_types;
+  global $user;
+  if (variable_get('configurable_timezones', 1) && $user->uid && drupal_strlen($user->timezone)) {
+    return $user->timezone;
+  }
+  else {
+    return variable_get('date_default_timezone', 0);
+  }
+}
+
+function _archive_types_sql_array($type) {
+  // Validate type and specify node types to include
+  $final_types = array();
+
+  if (_archive_validate_type($type) && $type != 'all') {
+    $final_types[] = $type;
+  }
+  else {
+    $types = variable_get('archive_type_filters', array());
+    // If no checkboxes selected
+    if (!array_key_exists('0', $types)) {
+      foreach ($types as $key => $value) {
+        if (!$value) {
+          unset($types[$key]);
+        }
+      }
+    }
+    $final_types = $types;
+  }
+
+  return $final_types;
 }
 
 /**
@@ -337,23 +330,23 @@ function _archive_types_sql_string($type
  *   TRUE or FALSE.
  */
 function _archive_validate_date($year, $month = NULL, $day = NULL) {
-	$valid = FALSE;
-	if ($year && $year <= format_date(time(), 'custom', 'Y')) {
-		if (!is_null($month)) {
-			if (!is_null($day)) {
-				if ($last = gmdate('t', gmmktime(0, 0, 0, $month, 1, $year))) {
-					$valid = (0 < $day && $day <= $last);
-				}
-			}
-			else if (0 < $month && $month <= 12) {
-				$valid = TRUE;
-			}
-		}
-		else {
-			$valid = TRUE;
-		}
-	}
-	return $valid;
+  $valid = FALSE;
+  if ($year && $year <= format_date(time(), 'custom', 'Y')) {
+    if (!is_null($month)) {
+      if (!is_null($day)) {
+        if ($last = gmdate('t', gmmktime(0, 0, 0, $month, 1, $year))) {
+          $valid = (0 < $day && $day <= $last);
+        }
+      }
+      elseif (0 < $month && $month <= 12) {
+        $valid = TRUE;
+      }
+    }
+    else {
+      $valid = TRUE;
+    }
+  }
+  return $valid;
 }
 
 /**
@@ -365,14 +358,15 @@ function _archive_validate_date($year, $
  *   TRUE or FALSE.
  */
 function _archive_validate_type($type) {
-	$types = variable_get('archive_type_filters', array());
-	return in_array($type, $types);
+  $types = variable_get('archive_type_filters', array());
+  return in_array($type, $types);
 }
 
 /**
- * Returns the range of dates with nodes. Returns an array with keys
- * of 'years', 'months', and 'days' which map their respective timeframe
- * to the number of posts in that timeframe.
+ * Returns the range of dates with nodes.
+ *
+ * Returns an array with keys of 'years', 'months', and 'days' which map
+ * their respective timeframe to the number of posts in that timeframe.
  *
  * @param $type
  *   The object that is being filtered.
@@ -382,52 +376,57 @@ function _archive_validate_type($type) {
  *   An array of the (first year with posts, last year with posts).
  */
 function _archive_post_count($type, $date) {
-	$final_types = _archive_types_sql_string($type);
-	$node_query = db_query(db_rewrite_sql('SELECT n.uid, n.created FROM {node} n WHERE n.status = 1 '. $final_types));
+  $final_types = _archive_types_sql_array($type);
+  $node_query = db_select('node', 'n');
+  $node_query->fields('n', array('uid', 'created'));
+  $node_query->condition('n.status', 1);
+  $node_query->condition('n.type', $final_types, 'IN');
+  $node_query->addTag('node_access');
+  $result = $node_query->execute();
 
-	$with_posts = array(
+  $with_posts = array(
     'years' => array(),
     'months' => array(),
     'days' => array(),
     'next_month_days' => array(),
     'prev_month_days' => array()
-	);
+  );
 
-	$next_month = $date->month==12?1:$date->month+1;
-	$next_year = $date->month==12?$date->year+1:$date->year;
-	$prev_month = $date->month==1?12:$date->month-1;
-	$prev_year = $date->month==1?$date->year-1:$date->year;
-
-	while ($o = db_fetch_object($node_query)) {
-		list($year, $month, $day) = explode(' ', format_date($o->created, 'custom', 'Y n j'));
-
-		// Check for current month.
-		$with_posts['years'][$year] = array_key_exists($year, $with_posts['years'])?$with_posts['years'][$year]+1:1;
-		if ($date->year && $year == $date->year) {
-			$with_posts['months'][$month] = array_key_exists($month, $with_posts['months'])?$with_posts['months'][$month]+1:1;
-			if ($date->month && $month == $date->month) {
-				$with_posts['days'][$day] = array_key_exists($day, $with_posts['days'])?$with_posts['days'][$day]+1:1;
-			}
-		}
-
-		// Check for previous month.
-		if ($year == $next_year && $month == $next_month) {
-			if (isset($with_posts['next_month_days'][$day])) {
-				$with_posts['next_month_days'][$day]++;
-			}
-			else {
-				$with_posts['next_month_days'][$day] = 1;
-			}
-		}
-		// Check for next month.
-		if ($year == $prev_year && $month == $prev_month) {
-			if (isset($with_posts['prev_month_days'][$day])) {
-				$with_posts['prev_month_days'][$day]++;
-			}
-			else {
-				$with_posts['prev_month_days'][$day] = 1;
-			}
-		}
-	}
-	return $with_posts;
+  $next_month = $date->month==12?1:$date->month+1;
+  $next_year = $date->month==12?$date->year+1:$date->year;
+  $prev_month = $date->month==1?12:$date->month-1;
+  $prev_year = $date->month==1?$date->year-1:$date->year;
+
+  foreach ($result as $o) {
+    list($year, $month, $day) = explode(' ', format_date($o->created, 'custom', 'Y n j'));
+
+    // Check for current month.
+    $with_posts['years'][$year] = array_key_exists($year, $with_posts['years'])?$with_posts['years'][$year]+1:1;
+    if ($date->year && $year == $date->year) {
+      $with_posts['months'][$month] = array_key_exists($month, $with_posts['months'])?$with_posts['months'][$month]+1:1;
+      if ($date->month && $month == $date->month) {
+        $with_posts['days'][$day] = array_key_exists($day, $with_posts['days'])?$with_posts['days'][$day]+1:1;
+      }
+    }
+
+    // Check for previous month.
+    if ($year == $next_year && $month == $next_month) {
+      if (isset($with_posts['next_month_days'][$day])) {
+        $with_posts['next_month_days'][$day]++;
+      }
+      else {
+        $with_posts['next_month_days'][$day] = 1;
+      }
+    }
+    // Check for next month.
+    if ($year == $prev_year && $month == $prev_month) {
+      if (isset($with_posts['prev_month_days'][$day])) {
+        $with_posts['prev_month_days'][$day]++;
+      }
+      else {
+        $with_posts['prev_month_days'][$day] = 1;
+      }
+    }
+  }
+  return $with_posts;
 }
Index: archive.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/archive/archive.pages.inc,v
retrieving revision 1.18.2.4
diff -u -p -r1.18.2.4 archive.pages.inc
--- archive.pages.inc	19 Aug 2008 22:18:25 -0000	1.18.2.4
+++ archive.pages.inc	15 Jun 2010 16:48:28 -0000
@@ -2,19 +2,24 @@
 // $Id: archive.pages.inc,v 1.18.2.4 2008/08/19 22:18:25 susurrus Exp $
 
 /**
+ * @file
+ * Pages for the archive module.
+ */
+
+/**
  * Fetch nodes for the selected date, or current date if none selected.
  *
  * @param $year
  *   Number of year.
  * @param $month
- *   Number of month.   
+ *   Number of month.
  * @param $day
  *   Number of day.
  * @return
  *   A string with the themed page.
  */
 function archive_page($type = 'all', $year = 0, $month = 0, $day = 0) {
-  
+
   // Make sure all values are secure.
   $day = (int) $day;
   $year = (int) $year;
@@ -26,25 +31,26 @@ function archive_page($type = 'all', $ye
   if (!_archive_validate_type($type)) {
     $type = 'all';
   }
-  
-  drupal_set_title(theme('archive_page_title', $type, $year, $month, $day));
-  
-  // Check that there're nodes we can display.
-  $nodes = db_result(db_query(db_rewrite_sql("SELECT COUNT(1) FROM {node} n WHERE n.status = 1 AND n.type IN ('". implode("', '", variable_get('archive_type_filters', array())) ."')")));
-  if (!$nodes && $type == 'all' && $year == 0 && $month == 0 && $day == 0) {
-    return t('No content found.');
-  }
-  
-  drupal_add_css(drupal_get_path('module', 'archive') .'/archive.css');
+
+  drupal_set_title(theme('archive_page_title', array('type' => $type, 'year' => $year, 'month' => $month, 'day' => $day)));
+
   $date = _archive_date($type, $year, $month, $day);
-  $output = theme('archive_navigation', $type, $date);
-  $nodes = variable_get('default_nodes_main', 10);
   $query = _archive_query($type, $date);
-  $result = pager_query(db_rewrite_sql(array_shift($query)), $nodes, 0, null, $query);
+  $nodes = variable_get('default_nodes_main', 10);
+  $result = $query->extend('PagerDefault')->limit($nodes)->execute();
+  $nodes = $query->countQuery()->execute()->fetchField();
+
+  drupal_add_css(drupal_get_path('module', 'archive') .'/archive.css');
+  $output = theme('archive_navigation', array('type' => $type, 'date' => $date));
+
+  if (!$nodes && $type == 'all') {
+    $output .= t('No content found.');
+    return $output;
+  }
 
-  $found_rows = false;
+  $found_rows = FALSE;
   $node_date = 0;
-  while ($o = db_fetch_object($result)) {
+  foreach ($result as $o) {
     $node = node_load($o->nid);
     $node_created = $node->created + $date->tz;
     // Determine which separators are needed
@@ -52,45 +58,46 @@ function archive_page($type = 'all', $ye
                         'month' => 0,
                         'day'   => 0);
     if (!$year) {
-      $created_year = date('Y', $node_created);
-      $last_year = date('Y', $node_date);
+      $created_year = format_date($node_created, 'custom', 'Y');
+      $last_year = format_date($node_date, 'custom', 'Y');
       if ($created_year != $last_year) {
         $separators['year'] = 1;
       }
     }
     // Print month separaters
     if (!$month) {
-      $created_month = date('n', $node_created);
-      $last_month = date('n', $node_date);
+      $created_month = format_date($node_created, 'custom', 'n');
+      $last_month = format_date($node_date, 'custom', 'n');
       if ($created_month != $last_month) {
         $separators['month'] = 1;
       }
     }
     // Print day separaters
     if (!$day) {
-      $created_day = date('j', $node_created);
-      $last_day = date('j', $node_date);
+      $created_day = format_date($node_created, 'custom', 'j');
+      $last_day = format_date($node_date, 'custom', 'j');
       if ($created_day != $last_day) {
         $separators['day'] = 1;
       }
     }
-    $output .= theme('archive_separator', $node_created, $separators);
-    $output .= node_view($node, true);
-    $found_rows = true;
+    $output .= theme('archive_separator', array('date_created' => $node_created, 'separators' => $separators));
+    $output .= drupal_render(node_view($node, 'teaser'));
+
+    $found_rows = TRUE;
     $node_date = $node->created + $date->tz;
   }
   if ($found_rows) {
-    $output .= theme('pager', null, $nodes);
+    $output .= theme('pager');
   }
   // Handle URLs that are incorrectly typed and try to parse info out of them
   else {
     if ($date->days[$date->day]) {
       drupal_goto(_archive_url($type, $date->year, $date->month, $date->day));
     }
-    else if ($date->months[$date->month]) {
+    elseif ($date->months[$date->month]) {
       drupal_goto(_archive_url($type, $date->year, $date->month));
     }
-    else if ($date->years[$date->year]) {
+    elseif ($date->years[$date->year]) {
       drupal_goto(_archive_url($type, $date->year));
     }
     else {
@@ -112,34 +119,41 @@ function archive_page($type = 'all', $ye
 function _archive_query($type, $date) {
   // Confine the display interval to only one day
   if ($date->day) {
-    $start = gmmktime(0, 0, 0, $date->month, $date->day, $date->year);
-    $end   = gmmktime(0, 0, 0, $date->month, $date->day + 1, $date->year);
+    $start = mktime(0, 0, 0, $date->month, $date->day, $date->year);
+    $end   = mktime(0, 0, 0, $date->month, $date->day + 1, $date->year);
   }
   // Confine the display interval to one month
-  else if ($date->month) {
-    $start = gmmktime(0, 0, 0, $date->month, 1, $date->year);
-    $end   = gmmktime(0, 0, 0, $date->month + 1, 1, $date->year);
+  elseif ($date->month) {
+    $start = mktime(0, 0, 0, $date->month, 1, $date->year);
+    $end   = mktime(0, 0, 0, $date->month + 1, 1, $date->year);
   }
   // Confine the display interval to one year
-  else if ($date->year) {
-    $start = gmmktime(0, 0, 0, 1, 1, $date->year);
-    $end   = gmmktime(0, 0, 0, 1, 1, $date->year + 1);
+  elseif ($date->year) {
+    $start = mktime(0, 0, 0, 1, 1, $date->year);
+    $end   = mktime(0, 0, 0, 1, 1, $date->year + 1);
   }
   else {
     $start = 0;
     $end = 0;
   }
-  
+
   // Grab limits on node types if exist
-  $final_types = _archive_types_sql_string($type);
-  
+  $final_types = _archive_types_sql_array($type);
+
   // Allow viewing all nodes, not just nodes by year
+  $query = db_select('node', 'n');
+  $query->fields('n', array('nid', 'type'));
+  $query->condition('n.status', 1);
+  $query->orderBy('n.created', 'DESC');
+  $query->condition('n.type', $final_types, 'IN');
+  $query->addTag('node_access');
+
   if ($start && $end) {
-    return array('SELECT n.nid, n.type FROM {node} n WHERE n.status = 1 '. $final_types .'AND n.created >= %d AND n.created < %d ORDER BY n.created DESC', $start - $date->tz, $end - $date->tz);
-  }
-  else {
-    return array('SELECT n.nid, n.type FROM {node} n WHERE n.status = 1 '. $final_types .'ORDER BY n.created DESC');
+    $query->condition('n.created', $start - $date->tz, '>=');
+    $query->condition('n.created', $end - $date->tz, '<=');
   }
+
+  return $query;
 }
 
 /**
@@ -151,98 +165,110 @@ function _archive_query($type, $date) {
  *   An array of node-types to number of posts of that type.
  */
 function _archive_node_types($date) {
-  
+
   $types = variable_get('archive_type_filters', array());
-  
+
   // Confine the display interval to only one day
   if ($date->day) {
-    $start = gmmktime(0, 0, 0, $date->month, $date->day, $date->year);
-    $end   = gmmktime(0, 0, 0, $date->month, $date->day + 1, $date->year);
+    $start = mktime(0, 0, 0, $date->month, $date->day, $date->year);
+    $end   = mktime(0, 0, 0, $date->month, $date->day + 1, $date->year);
   }
   // Confine the display interval to one month
-  else if ($date->month) {
-    $start = gmmktime(0, 0, 0, $date->month, 1, $date->year);
-    $end   = gmmktime(0, 0, 0, $date->month + 1, 1, $date->year);
+  elseif ($date->month) {
+    $start = mktime(0, 0, 0, $date->month, 1, $date->year);
+    $end   = mktime(0, 0, 0, $date->month + 1, 1, $date->year);
   }
   // Confine the display interval to one year
-  else if ($date->year) {
-    $start = gmmktime(0, 0, 0, 1, 1, $date->year);
-    $end   = gmmktime(0, 0, 0, 1, 1, $date->year + 1);
+  elseif ($date->year) {
+    $start = mktime(0, 0, 0, 1, 1, $date->year);
+    $end   = mktime(0, 0, 0, 1, 1, $date->year + 1);
   }
   else {
     $start = 0;
     $end = 0;
   }
+
+  // Setup the query.
+  $query = db_select('node', 'n');
+  $query->innerJoin('node_type', 't', 't.type = n.type');
+  $query->fields('t', array('type', 'name'));
+  $query->addExpression('COUNT(n.nid)', 'node_count');
+  $query->condition('n.status', 1);
+  $query->condition('t.type', $types, 'IN');
+  $query->groupBy('n.type');
+  $query->orderBy('n.created', 'ASC');
+  $query->addTag('node_acces');
+
   if ($start && $end) {
-    $result = db_query(db_rewrite_sql("SELECT t.type, t.name, COUNT(n.nid) AS node_count FROM {node} n INNER JOIN {node_type} t ON t.type = n.type WHERE n.status = 1 AND t.type IN ('". join($types, "', '") ."') AND n.created BETWEEN %d AND %d GROUP BY n.type ORDER BY n.created"), $start - $date->tz, $end - $date->tz);
-  }
-  else {
-    $result = db_query(db_rewrite_sql("SELECT t.type, t.name, COUNT(n.nid) AS node_count FROM {node} n INNER JOIN {node_type} t ON t.type = n.type WHERE n.status = 1 AND t.type IN ('". join($types, "', '") ."') GROUP BY n.type ORDER BY n.created"));
+    $query->condition('n.created', array($start - $date->tz, $end - $date->tz), 'BETWEEN');
   }
-  
+  $result = $query->execute();
+
+
   $n_types = array();
-  while ($row = db_fetch_array($result)) {
-    $n_types[$row['type']] = array('count' => $row['node_count'],
-                                   'name'  => $row['name']);
+  foreach ($result as $row) {
+    $n_types[$row->type] = array('count' => $row->node_count,
+                                 'name'  => $row->name);
   }
-  
+
   ksort($n_types);
   return $n_types;
 }
 
 /**
- * Theme function for the title of the archive page. Changes according to content
- * being viewed
+ * Theme function for the title of the archive page.
  *
- * @param string $type
- * @param integer $year
- * @param integer $month
- * @param integer $day
- * @return string
+ * @param $variables
+ *   An associative array containing:
+ *   - type: The node type for the archive page.
+ *   - year: The year of the archivepage.
+ *   - month: The month of the archive page.
+ *   - day: The day of the archive page.
+ *
+ * @ingroup themeable
  */
-function theme_archive_page_title($type, $year, $month, $day) {
-  
+function theme_archive_page_title($variables) {
   $title = t('Archive');
   $month_names = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
-  if ($day) {
-    $title .= ' - '. t($month_names[$month]) .' '. $day .', '. $year;
+  if ($variables['day']) {
+    $title .= ' - '. t($month_names[$variables['month']]) .' '. $variables['day'] .', '. $variables['year'];
   }
-  else if ($month) {
-    $title .= ' - '. t($month_names[$month]) .' '. $year;
+  elseif ($variables['month']) {
+    $title .= ' - '. t($month_names[$variables['month']]) .' '. $variables['year'];
   }
-  else if ($year) {
-    $title .= ' - '. $year;
+  elseif ($variables['year']) {
+    $title .= ' - '. $variables['year'];
   }
-  
-  if ($type != 'all') {
-    $type_name = db_result(db_query("SELECT name FROM {node_type} WHERE type = '%s'", $type));
-  	
-    $title .= ' - '. ($type_name ? t($type_name) : $type);
+
+  if ($variables['type'] != 'all') {
+    $type_name = db_query("SELECT name FROM {node_type} WHERE type = '%s'", $variables['type'])->fetchField();
+
+    $title .= ' - '. ($type_name ? t($type_name) : $variables['type']);
   }
-  
+
   return $title;
 }
 
 /**
  * Theme the archive navigation with years, months and dates by default.
- * 
+ *
  * @ingroup themeable
  */
-function theme_archive_navigation($type, $date) {
+function theme_archive_navigation($variables) {
   $output  = "<div id=\"archive-container\"><dl><dt>". t('Date') ."</dt><dd>\n";
-  $output .= theme('archive_navigation_years', $type, $date);
-  if (_archive_validate_date($date->year)) {
-    $output .= theme('archive_navigation_months', $type, $date);
+  $output .= theme('archive_navigation_years', array('type' => $variables['type'], 'date' => $variables['date']));
+  if (_archive_validate_date($variables['date']->year)) {
+    $output .= theme('archive_navigation_months', array('type' => $variables['type'], 'date' => $variables['date']));
   }
-  if (_archive_validate_date($date->year, $date->month)) {
-    $output .= theme('archive_navigation_days', $type, $date);
+  if (_archive_validate_date($variables['date']->year, $variables['date']->month)) {
+    $output .= theme('archive_navigation_days', array('type' => $variables['type'], 'date' => $variables['date']));
   }
   $output .= "</dd>";
-  
+
   // Only display node type filter if more than one node type represented
-  if (sizeof(_archive_node_types($date)) > 1) {
+  if (sizeof(_archive_node_types($variables['date'])) > 1) {
     $output .= "<dt>". t('Type') ."</dt><dd>\n";
-    $output .= theme('archive_navigation_node_types', $type, $date);
+    $output .= theme('archive_navigation_node_types', array('type' => $variables['type'], 'date' => $variables['date']));
     $output .= "</dd>";
   }
   $output .= "</dl></div>\n";
@@ -251,24 +277,24 @@ function theme_archive_navigation($type,
 
 /**
  * Theme the list of years for the archive navigation.
- * 
+ *
  * @ingroup themeable
  */
-function theme_archive_navigation_years($type, $date) {  
+function theme_archive_navigation_years($variables) {
   $output = "<ul id=\"archive-years\">\n";
-  
+
   $all_count = 0;
-  foreach ($date->years as $year_count) {
+  foreach ($variables['date']->years as $year_count) {
     $all_count += $year_count;
   }
-  
-  $output .= '<li'. ($date->year?'':' class="selected"') .'>'. l(t('All'), _archive_url($type), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
-  foreach ($date->years as $year => $year_count) {
+
+  $output .= '<li'. ($variables['date']->year?'':' class="selected"') .'>'. l(t('All'), _archive_url($variables['type']), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
+  foreach ($variables['date']->years as $year => $year_count) {
     $class = '';
-    if ($year == $date->year) {
+    if ($year == $variables['date']->year) {
       $class = ' class="selected"';
     }
-    $output .= '<li'. $class .'>'. l($year, _archive_url($type, $year), array('attributes' => array('title' => format_plural($year_count, '1 post', '@count posts')))) ."</li>\n";
+    $output .= '<li'. $class .'>'. l($year, _archive_url($variables['type'], $year), array('attributes' => array('title' => format_plural($year_count, '1 post', '@count posts')))) ."</li>\n";
   }
   $output .= "</ul>\n";
 
@@ -277,31 +303,31 @@ function theme_archive_navigation_years(
 
 /**
  * Theme the list of months for the archive navigation.
- * 
+ *
  * @ingroup themeable
  */
-function theme_archive_navigation_months($type, $date) {
+function theme_archive_navigation_months($variables) {
   $output = "<ul id=\"archive-months\">\n";
-  
+
   $all_count = 0;
-  foreach ($date->months as $month) {
+  foreach ($variables['date']->months as $month) {
     $all_count += $month;
   }
-  
-  $output .= '<li'. ($date->month?'':' class="selected"') .'>'. l(t('All'), _archive_url($type, $date->year), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
-  $curr_month = date('n', time());
-  $curr_year = date('Y', time());
+
+  $output .= '<li'. ($variables['date']->month?'':' class="selected"') .'>'. l(t('All'), _archive_url($variables['type'], $variables['date']->year), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
+  $curr_month = format_date(time(), 'custom', 'n');
+  $curr_year = format_date(time(), 'custom', 'Y');
   foreach (range(1, 12) as $month) {
-    $posts = !empty($date->months[$month]) ? $date->months[$month] : 0;
+    $posts = !empty($variables['date']->months[$month]) ? $variables['date']->months[$month] : 0;
     $class = '';
-    if ($month == $date->month) {
+    if ($month == $variables['date']->month) {
       $class = ' class="selected"';
     }
-    else if ($curr_year == $date->year && $month > $curr_month) {
+    elseif ($curr_year == $variables['date']->year && $month > $curr_month) {
       $class = ' class="future"';
     }
     $month_names = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
-    $output .= "<li$class>". ($posts > 0 ? l(t($month_names[$month]), _archive_url($type, $date->year, $month), array('attributes' => array('title' => format_plural($posts, "1 post", "@count posts")))) : t($month_names[$month])) ."</li>\n";
+    $output .= "<li$class>". ($posts > 0 ? l(t($month_names[$month]), _archive_url($variables['type'], $variables['date']->year, $month), array('attributes' => array('title' => format_plural($posts, "1 post", "@count posts")))) : t($month_names[$month])) ."</li>\n";
   }
   $output .= "</ul>\n";
   return $output;
@@ -309,33 +335,33 @@ function theme_archive_navigation_months
 
 /**
  * Theme the list of days for the archive navigation.
- * 
+ *
  * @ingroup themeable
  */
-function theme_archive_navigation_days($type, $date) {
+function theme_archive_navigation_days($variables) {
   $output = "<ul id=\"archive-days\">\n";
-  
+
   $all_count = 0;
-  foreach ($date->days as $day) {
+  foreach ($variables['date']->days as $day) {
     $all_count += $day;
   }
-  
-  $output .= '<li'. ($date->day?'':' class="selected"') .'>'. l(t('All'), _archive_url($type, $date->year, $date->month), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
-  $curr_month = date('n', time());
-  $curr_year = date('Y', time());
-  $curr_day = date('j', time());
-  
-  $day_stop = gmdate('t', gmmktime(0, 0, 0, $date->month, 1, $date->year));
+
+  $output .= '<li'. ($variables['date']->day?'':' class="selected"') .'>'. l(t('All'), _archive_url($variables['type'], $variables['date']->year, $variables['date']->month), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
+  $curr_month = format_date(time(), 'custom', 'n');
+  $curr_year = format_date(time(), 'custom', 'Y');
+  $curr_day = format_date(time(), 'custom', 'j');
+
+  $day_stop = gmdate('t', gmmktime(0, 0, 0, $variables['date']->month, 1, $variables['date']->year));
   for ($day = 1; $day <= $day_stop; $day++) {
-    $posts = array_key_exists($day, $date->days) ? $date->days[$day] : 0;
+    $posts = array_key_exists($day, $variables['date']->days) ? $variables['date']->days[$day] : 0;
     $class = '';
-    if ($day == $date->day) {
+    if ($day == $variables['date']->day) {
       $class = ' class="selected"';
     }
-    else if ($curr_year == $date->year && $curr_month == $date->month && $day > $curr_day) {
+    elseif ($curr_year == $variables['date']->year && $curr_month == $variables['date']->month && $day > $curr_day) {
       $class = ' class="future"';
     }
-    $output .= "<li$class>". ($posts ? l($day, _archive_url($type, $date->year, $date->month, $day), array('attributes' => array("title" => format_plural($posts, "1 post", "@count posts")))) : $day) ."</li>\n";
+    $output .= "<li$class>". ($posts ? l($day, _archive_url($variables['type'], $variables['date']->year, $variables['date']->month, $day), array('attributes' => array("title" => format_plural($posts, "1 post", "@count posts")))) : $day) ."</li>\n";
   }
   $output .= "</ul>\n";
   return $output;
@@ -343,28 +369,27 @@ function theme_archive_navigation_days($
 
 /**
  * Theme the list of node types for the archives.
- * 
+ *
  * @ingroup themeable
  */
-function theme_archive_navigation_node_types($type, $date) {
-  
+function theme_archive_navigation_node_types($variables) {
   $output = "<ul id=\"archive-node_types\">\n";
-  $types_count = _archive_node_types($date);
-  
+  $types_count = _archive_node_types($variables['date']);
+
   $all_count = 0;
   foreach ($types_count as $t) {
     $all_count += $t['count'];
   }
-  
-  $output .= '<li'. ($type && $type != 'all'?'':' class="selected"') .'>'. l(t('All'), _archive_url('all', $date->year, $date->month, $date->day), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
+
+  $output .= '<li'. ($variables['type'] && $variables['type'] != 'all'?'':' class="selected"') .'>'. l(t('All'), _archive_url('all', $variables['date']->year, $variables['date']->month, $variables['date']->day), array('attributes' => array('title' => format_plural($all_count, '1 post', '@count posts')))) ."</li>\n";
   foreach ($types_count as $ft_key => $ft_value) {
     if (!$ft_value['count']) {
       continue;
     }
-    $class = ($ft_key == $type ? ' class="selected"' : '');
+    $class = ($ft_key == $variables['type'] ? ' class="selected"' : '');
     $name = $ft_value['name'];
     if ($types_count[$ft_key]['count'] > 0) {
-      $output .= "<li$class>". l($name, _archive_url($ft_key, $date->year, $date->month, $date->day), array('attributes' => array("title" => format_plural($types_count[$ft_key]['count'], "1 post", "@count posts")))) ."</li>\n";
+      $output .= "<li$class>". l($name, _archive_url($ft_key, $variables['date']->year, $variables['date']->month, $variables['date']->day), array('attributes' => array("title" => format_plural($types_count[$ft_key]['count'], "1 post", "@count posts")))) ."</li>\n";
     }
     else {
       $output .= "<li$class>$name</li>\n";
@@ -376,7 +401,7 @@ function theme_archive_navigation_node_t
 
 /**
  * Theme the date separators between nodes of different year/month/day.
- * 
+ *
  * @param $date_created
  *   A UNIX timestamp.
  * @param $separators
@@ -387,17 +412,17 @@ function theme_archive_navigation_node_t
  *
  * @ingroup themeable
  */
-function theme_archive_separator($date_created, $separators) {
+function theme_archive_separator($variables) {
   $date_sep = '';
-  if ($separators['year'] && $separators['month'] && $separators['day']) {
-    $date_sep = format_date($date_created, 'custom', 'F jS, Y');
+  if ($variables['separators']['year'] && $variables['separators']['month'] && $variables['separators']['day']) {
+    $date_sep = format_date($variables['date_created'], 'custom', 'F jS, Y');
   }
-  else if ($separators['month'] && $separators['day']) {
-    $date_sep = format_date($date_created, 'custom', 'F jS');
+  elseif ($variables['separators']['month'] && $variables['separators']['day']) {
+    $date_sep = format_date($variables['date_created'], 'custom', 'F jS');
   }
-  else if ($separators['day']) {
-    $date_sep = format_date($date_created, 'custom', 'F jS');
+  elseif ($variables['separators']['day']) {
+    $date_sep = format_date($variables['date_created'], 'custom', 'F jS');
   }
-  
+
   return '<h3>'. $date_sep .'</h3>';
 }
