? tablesort.first_sort_2.patch
? sites/d7head.localhost
Index: includes/tablesort.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/tablesort.inc,v
retrieving revision 1.58
diff -u -p -r1.58 tablesort.inc
--- includes/tablesort.inc	5 Dec 2009 20:17:02 -0000	1.58
+++ includes/tablesort.inc	18 Jul 2010 10:23:22 -0000
@@ -174,13 +174,15 @@ function tablesort_header($cell, $header
       $image = theme('tablesort_indicator', array('style' => $ts['sort']));
     }
     else {
-      // If the user clicks a different header, we want to sort ascending initially.
-      $ts['sort'] = 'asc';
+      // This determines the sort order if the column gets clicked by the 
+      // user. It is "asc" by default, but if $cell['descending'] is TRUE,
+      // then it will be "desc".
+      $ts['sort'] = isset($cell['descending']) && $cell['descending'] ? 'desc' : 'asc';
       $image = '';
     }
     $cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 'query' => array_merge($ts['query'], array('sort' => $ts['sort'], 'order' => $cell['data'])), 'html' => TRUE));
 
-    unset($cell['field'], $cell['sort']);
+    unset($cell['field'], $cell['sort'], $cell['descending']);
   }
   return $cell;
 }
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.601
diff -u -p -r1.601 theme.inc
--- includes/theme.inc	8 Jul 2010 03:41:26 -0000	1.601
+++ includes/theme.inc	18 Jul 2010 10:23:23 -0000
@@ -1548,7 +1548,13 @@ function theme_breadcrumb($variables) {
  *     - "data": The localized title of the table column.
  *     - "field": The database field represented in the table column (required
  *       if user is to be able to sort on this column).
- *     - "sort": A default sort order for this column ("asc" or "desc").
+ *     - "descending": TRUE or FALSE; Set to TRUE if the column should sort 
+ *       descending when its header is clicked for the first time. This 
+ *       attribute can be applied to multiple columns in a table. The default
+ *       is TRUE.
+ *     - "sort": "asc" or "desc"; Determines the column and order of the table's
+ *       sort when it is rendered for the first time. This attribute should only
+ *       be assigned to one column in a table.
  *     - Any HTML attributes, such as "colspan", to apply to the column header
  *       cell.
  *   - rows: An array of table rows. Every row is an array of cells, or an
Index: modules/statistics/statistics.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.admin.inc,v
retrieving revision 1.40
diff -u -p -r1.40 statistics.admin.inc
--- modules/statistics/statistics.admin.inc	26 Jun 2010 21:32:20 -0000	1.40
+++ modules/statistics/statistics.admin.inc	18 Jul 2010 10:23:23 -0000
@@ -11,7 +11,7 @@
  */
 function statistics_recent_hits() {
   $header = array(
-    array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'),
+    array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'descending' => TRUE, 'sort' => 'desc'),
     array('data' => t('Page'), 'field' => 'a.path'),
     array('data' => t('User'), 'field' => 'u.name'),
     array('data' => t('Operations'))
@@ -50,10 +50,10 @@ function statistics_recent_hits() {
  */
 function statistics_top_pages() {
   $header = array(
-    array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
+    array('data' => t('Hits'), 'field' => 'hits', 'descending' => TRUE, 'sort' => 'desc'),
     array('data' => t('Page'), 'field' => 'path'),
-    array('data' => t('Average page generation time'), 'field' => 'average_time'),
-    array('data' => t('Total page generation time'), 'field' => 'total_time')
+    array('data' => t('Average page generation time'), 'field' => 'average_time', 'descending' => TRUE),
+    array('data' => t('Total page generation time'), 'field' => 'total_time', 'descending' => TRUE)
   );
 
   $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
@@ -96,9 +96,9 @@ function statistics_top_pages() {
 function statistics_top_visitors() {
 
   $header = array(
-    array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
+    array('data' => t('Hits'), 'field' => 'hits', 'descending' => TRUE, 'sort' => 'desc'),
     array('data' => t('Visitor'), 'field' => 'u.name'),
-    array('data' => t('Total page generation time'), 'field' => 'total'),
+    array('data' => t('Total page generation time'), 'field' => 'total', 'descending' => TRUE),
     array('data' => user_access('block IP addresses') ? t('Operations') : '', 'colspan' => 2),
   );
   $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
@@ -150,7 +150,7 @@ function statistics_top_referrers() {
   drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
 
   $header = array(
-    array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
+    array('data' => t('Hits'), 'field' => 'hits', 'first sort' => 'desc', 'sort' => 'desc'),
     array('data' => t('Url'), 'field' => 'url'),
     array('data' => t('Last visit'), 'field' => 'last'),
   );
Index: modules/statistics/statistics.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.pages.inc,v
retrieving revision 1.23
diff -u -p -r1.23 statistics.pages.inc
--- modules/statistics/statistics.pages.inc	9 Jan 2010 21:54:01 -0000	1.23
+++ modules/statistics/statistics.pages.inc	18 Jul 2010 10:23:23 -0000
@@ -10,7 +10,7 @@ function statistics_node_tracker() {
   if ($node = node_load(arg(1))) {
 
     $header = array(
-        array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'),
+        array('data' => t('Time'), 'field' => 'a.timestamp', 'descending' => TRUE, 'sort' => 'desc'),
         array('data' => t('Referrer'), 'field' => 'a.url'),
         array('data' => t('User'), 'field' => 'u.name'),
         array('data' => t('Operations')));
@@ -57,7 +57,7 @@ function statistics_user_tracker() {
   if ($account = user_load(arg(1))) {
 
     $header = array(
-        array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
+        array('data' => t('Timestamp'), 'field' => 'timestamp', 'descending' => TRUE, 'sort' => 'desc'),
         array('data' => t('Page'), 'field' => 'path'),
         array('data' => t('Operations')));
     $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
