From e9ffe24f8eaaf8440152f6201b76109e98e20b12 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 30 Apr 2007 11:26:06 +0000 Subject: [PATCH] - Patch #139979 by asimmonds: Display consistent message for unavailable statistics. --- modules/statistics/statistics.module | 33 +++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 6660e2d901c..61c0896261c 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -209,12 +209,14 @@ function statistics_node_tracker() { l(t('details'), "admin/logs/access/$log->aid")); } - drupal_set_title(check_plain($node->title)); - if (!empty($rows)) { - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); } + + drupal_set_title(check_plain($node->title)); + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; } else { drupal_not_found(); @@ -230,6 +232,7 @@ function statistics_user_tracker() { array('data' => t('Operations'))); $result = pager_query('SELECT aid, timestamp, path, title FROM {accesslog} WHERE uid = %d'. tablesort_sql($header), 30, 0, NULL, $account->uid); + $rows = array(); while ($log = db_fetch_object($result)) { $rows[] = array( array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), @@ -237,6 +240,10 @@ function statistics_user_tracker() { l(t('details'), "admin/logs/access/$log->aid")); } + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3)); + } + drupal_set_title(check_plain($account->name)); $output = theme('table', $header, $rows); $output .= theme('pager', NULL, 30, 0); @@ -270,6 +277,10 @@ function statistics_recent_hits() { l(t('details'), "admin/logs/access/$log->aid")); } + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); + } + $output = theme('table', $header, $rows); $output .= theme('pager', NULL, 30, 0); return $output; @@ -296,6 +307,10 @@ function statistics_top_pages() { $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path), t('%time ms', array('%time' => round($page->average_time))), format_interval(round($page->total_time / 1000))); } + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); + } + drupal_set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); $output = theme('table', $header, $rows); $output .= theme('pager', NULL, 30, 0); @@ -325,6 +340,10 @@ function statistics_top_visitors() { $rows[] = array($account->hits, ($account->uid ? theme('username', $account) : $account->hostname), format_interval(round($account->total / 1000)), $ban_link); } + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); + } + drupal_set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); $output = theme('table', $header, $rows); $output .= theme('pager', NULL, 30, 0); @@ -353,6 +372,10 @@ function statistics_top_referrers() { $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(time() - $referrer->last)))); } + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3)); + } + $output = theme('table', $header, $rows); $output .= theme('pager', NULL, 30, 0); return $output;