From 167c59e4daabed6cd018cbe62dfc47c3f469886b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 28 Nov 2004 13:55:17 +0000 Subject: [PATCH] - Beautified the contents of the table. - Removed some dead code. --- modules/statistics.module | 37 ++++++++-------------------- modules/statistics/statistics.module | 37 ++++++++-------------------- 2 files changed, 20 insertions(+), 54 deletions(-) diff --git a/modules/statistics.module b/modules/statistics.module index 719c029326a..8c07e0a6538 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -144,6 +144,13 @@ function statistics_menu($may_cache) { return $items; } +function _statistics_format_item($title, $link) { + $link = ($link ? $link : '/'); + $output = ($title ? "$title
" : ''); + $output .= l($link, $link); + return $output; +} + function statistics_access_log($aid) { $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid); if ($access = db_fetch_object($result)) { @@ -203,7 +210,7 @@ function statistics_user_tracker() { while ($log = db_fetch_object($result)) { $rows[] = array( array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), - $log->title ."
". l($log->path, $log->path), + _statistics_format_item($log->title, $log->path), l(t('details'), "admin/logs/access/$log->aid")); } @@ -236,7 +243,7 @@ function statistics_recent_hits($type = 'all', $id = 0) { while ($log = db_fetch_object($result)) { $rows[] = array( array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), - $log->title .'
'. l($log->path, $log->path), + _statistics_format_item($log->title, $log->path), format_name($log), l(t('details'), "admin/logs/access/$log->aid")); } @@ -263,7 +270,7 @@ function statistics_top_pages() { $result = pager_query($sql, 30, 0, $sql_cnt); while ($page = db_fetch_object($result)) { - $rows[] = array($page->hits, $page->title .'
'. l($page->path, $page->path)); + $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path)); } if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) { $rows[] = array(array('data' => $pager, 'colspan' => '2')); @@ -462,30 +469,6 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) { } } -function statistics_summary($dbfield, $dbrows) { - /* valid dbfields: totalcount, daycount, timestamp */ - - $output = ''; - $result = db_query_range('SELECT n.nid, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC', $dbfield, 0, $dbrows); - while ($nid = db_fetch_array($result)) { - $content = node_load(array('nid' => $nid['nid'])); - - // Filter and prepare node teaser - if (node_hook($content, 'view')) { - node_invoke($content, 'view', TRUE, FALSE); - } - else { - $content = node_prepare($content, TRUE); - } - - $output .= ''. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .''. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .''; - $output .= '
'. $content->teaser .'
'; - $output .= '[ '. theme('links', $content->links) .' ]

'; - } - - return $output; -} - /** * It is possible to adjust the width of columns generated by the * statistics module. Currently this has to be done manually, by diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 719c029326a..8c07e0a6538 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -144,6 +144,13 @@ function statistics_menu($may_cache) { return $items; } +function _statistics_format_item($title, $link) { + $link = ($link ? $link : '/'); + $output = ($title ? "$title
" : ''); + $output .= l($link, $link); + return $output; +} + function statistics_access_log($aid) { $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid); if ($access = db_fetch_object($result)) { @@ -203,7 +210,7 @@ function statistics_user_tracker() { while ($log = db_fetch_object($result)) { $rows[] = array( array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), - $log->title ."
". l($log->path, $log->path), + _statistics_format_item($log->title, $log->path), l(t('details'), "admin/logs/access/$log->aid")); } @@ -236,7 +243,7 @@ function statistics_recent_hits($type = 'all', $id = 0) { while ($log = db_fetch_object($result)) { $rows[] = array( array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), - $log->title .'
'. l($log->path, $log->path), + _statistics_format_item($log->title, $log->path), format_name($log), l(t('details'), "admin/logs/access/$log->aid")); } @@ -263,7 +270,7 @@ function statistics_top_pages() { $result = pager_query($sql, 30, 0, $sql_cnt); while ($page = db_fetch_object($result)) { - $rows[] = array($page->hits, $page->title .'
'. l($page->path, $page->path)); + $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path)); } if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) { $rows[] = array(array('data' => $pager, 'colspan' => '2')); @@ -462,30 +469,6 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) { } } -function statistics_summary($dbfield, $dbrows) { - /* valid dbfields: totalcount, daycount, timestamp */ - - $output = ''; - $result = db_query_range('SELECT n.nid, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC', $dbfield, 0, $dbrows); - while ($nid = db_fetch_array($result)) { - $content = node_load(array('nid' => $nid['nid'])); - - // Filter and prepare node teaser - if (node_hook($content, 'view')) { - node_invoke($content, 'view', TRUE, FALSE); - } - else { - $content = node_prepare($content, TRUE); - } - - $output .= ''. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .''. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .''; - $output .= '
'. $content->teaser .'
'; - $output .= '[ '. theme('links', $content->links) .' ]

'; - } - - return $output; -} - /** * It is possible to adjust the width of columns generated by the * statistics module. Currently this has to be done manually, by