- Patch by Jeremy: usability improvements for the statistics.module's GUI.

4.5.x
Dries Buytaert 2004-08-05 20:30:16 +00:00
parent b47e4e16d3
commit f971b768f6
2 changed files with 132 additions and 140 deletions

View File

@ -46,27 +46,27 @@ function statistics_help($section) {
<li><em>administer statistics module</em> - enable for user roles that get to configure the statistics module.</li><li><em>administer statistics</em> - enable for user roles that get to view the referrer statistics.</li>
</ul>
<p>If '<em>administer statistics</em>' and '<em>access statistics</em>' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).</p>",
array('%modules' => url('admin/modules'), '%permissions' => url('admin/user/configure/permission'), '%referer' => url('admin/logs/access/referrers'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/settings/statistics'), '%block' => url('admin/block')));
array('%modules' => url('admin/modules'), '%permissions' => url('admin/user/configure/permission'), '%referer' => url('admin/logs/hits/referrers'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/settings/statistics'), '%block' => url('admin/block')));
case 'admin/modules#description':
return t('Logs access statistics for your site.');
case 'admin/settings/statistics':
return t('Settings for the statistical information that Drupal will keep about the site. See <a href="%statistics">site statistics</a> for the actual information.', array('%statistics' => url('admin/logs/topnodes')));
case 'admin/logs/topnodes':
case 'admin/logs/hits/posts':
return t('This page gives you an at-a-glance look at your most popular content.');
case 'admin/logs/access/titles':
case 'admin/logs/hits/pages':
return t('This page shows access statistics for each page of your website.');
case 'admin/logs/access/users':
case 'admin/logs/hits/users':
return t('This page shows access statistics for each user of your website.');
case 'admin/logs/access/hostnames':
case 'admin/logs/hits/hostnames':
return t('This page shows access statistics for each hostname visiting your website.');
case 'admin/logs/access/referrers':
case 'admin/logs/referrers':
return t('This page shows your site-wide referrer statistics. You can optionally view just the "external referrers" or the "internal referrers". Referrers are web pages, both local and on other sites, that point to your web site.');
case 'admin/logs/access/referrers/internal':
case 'admin/logs/referrers/internal':
return t('This page shows you only "internal referrers". These are links pointing to your web site from within your web site.');
case 'admin/logs/access/referrers/external':
case 'admin/logs/referrers/external':
return t('This page shows you only "external referrers". These are links pointing to your web site from outside your web site.');
case strstr($section, 'admin/logs/access'):
return t("This page shows you who is accessing your web site. You can see the hostnames and referrers. In particular, it is easy to inspect a user's navigation history/trail by clicking on <em>track user</em>.");
case strstr($section, 'admin/logs/hits'):
return t("This page shows you who is accessing your web site. You can see the hostnames and referrers. For example, it is easy to inspect a user's navigation history/trail by clicking on <em>track user</em>.");
}
}
@ -127,7 +127,7 @@ function statistics_link($type, $node = 0, $main = 0) {
$statistics = statistics_get($node->nid);
if ($statistics) {
if (user_access('administer statistics')) {
$links[] = l(format_plural($statistics['totalcount'], '1 read', '%count reads'), 'admin/logs/access/title/'. urlencode($node->title));
$links[] = l(format_plural($statistics['totalcount'], '1 read', '%count reads'), 'admin/logs/hits/page/'. urlencode($node->title));
}
else {
$links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
@ -156,54 +156,31 @@ function statistics_menu() {
'type' => MENU_SUGGESTED_ITEM);
$access = user_access('administer statistics module') || user_access('administer statistics');
$items[] = array('path' => 'admin/logs/topnodes', 'title' => t('top nodes'),
'callback' => 'statistics_admin_topnodes', 'access' => $access,
'weight' => 1);
$items[] = array('path' => 'admin/logs/access', 'title' => t('access'),
$items[] = array('path' => 'admin/logs/hits', 'title' => t('hits'),
'callback' => 'statistics_admin_displaylog', 'access' => $access,
'weight' => 3);
$items[] = array('path' => 'admin/logs/access/titles', 'title' => t('titles'),
$items[] = array('path' => 'admin/logs/hits/posts', 'title' => t('posts'),
'callback' => 'statistics_admin_content', 'access' => $access,
'weight' => 1);
$items[] = array('path' => 'admin/logs/hits/pages', 'title' => t('pages'),
'callback' => 'statistics_top_titles', 'access' => $access,
'weight' => 1);
$items[] = array('path' => 'admin/logs/access/users', 'title' => t('users'),
$items[] = array('path' => 'admin/logs/hits/users', 'title' => t('users'),
'callback' => 'statistics_top_users', 'access' => $access,
'weight' => 2);
$items[] = array('path' => 'admin/logs/access/hostnames',
$items[] = array('path' => 'admin/logs/hits/hostnames',
'title' => t('hostnames'), 'callback' => 'statistics_top_hostnames',
'access' => $access, 'weight' => 3);
$items[] = array('path' => 'admin/logs/access/referrers',
$items[] = array('path' => 'admin/logs/referrers',
'title' => t('referrers'), 'callback' => 'statistics_top_referrers',
'access' => $access, 'weight' => 4);
$items[] = array('path' => 'admin/logs/access/referrers/internal',
$items[] = array('path' => 'admin/logs/referrers/internal',
'title' => t('internal'), 'access' => $access);
$items[] = array('path' => 'admin/logs/access/referrers/external',
$items[] = array('path' => 'admin/logs/referrers/external',
'title' => t('external'), 'access' => $access);
return $items;
}
function statistics_admin_topnodes_table() {
$header = array(
array('data' => t('title'), 'field' => 'n.title'),
array('data' => t('today'), 'field' => 's.daycount', 'sort' => 'desc'),
array('data' => t('all time'), 'field' => 's.totalcount'),
array('data' => t('last hit'), 'field' => 's.timestamp'),
array('data' => t('operations'))
);
$sql = 'SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid';
$sql .= tablesort_sql($header);
$result = pager_query($sql, 20); // WHERE s.%s <> '0'
while ($nid = db_fetch_array($result)) {
$rows[] = array(l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]"));
}
if ($pager = theme('pager', NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 5));
}
return theme('table', $header, $rows);
}
/**
* Menu callback; presents the "Access logs" page.
*
@ -231,7 +208,7 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
$sql = 'SELECT title, path, url, hostname, uid, MAX(timestamp) AS timestamp FROM {accesslog} WHERE uid <> 0 GROUP BY uid, title, path, url, hostname';
}
break;
case 'title':
case 'page':
// retrieve recent access logs for title $id
$page_title = t('Recent access logs for "%title"', array('%title' => $id));
$sql = 'SELECT title, path, url, hostname, uid, timestamp FROM {accesslog} WHERE title = \''. check_query($id) ."'";
@ -250,7 +227,7 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
$header = array(
array('data' => t('timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
array('data' => t('title'), 'field' => 'title'),
array('data' => t('post'), 'field' => 'title'),
array('data' => t('user'), 'field' => 'uid'),
array('data' => t('hostname'), 'field' => 'hostname'),
array('data' => t('referrer'), 'field' => 'url'),
@ -275,7 +252,7 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
$url = message_na();
$user = user_load(array('uid' => $log->uid));
$rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), $title, format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->title ? l(t('track title'), 'admin/logs/access/title/'. urlencode($log->title)) : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : ''));
$rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), $title, format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($user->uid ? l(t('track user'), "admin/logs/hits/user/$user->uid") : ''), ($log->title ? l(t('track title'), 'admin/logs/hits/page/'. urlencode($log->title)) : ''), ($log->hostname ? l(t('track host'), "admin/logs/hits/host/$log->hostname") : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
@ -287,27 +264,27 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
}
/**
* Menu callback; presents the "Top titles" page.
* Menu callback; presents the "Top pages" page.
*/
function statistics_top_titles() {
$sql = "SELECT title, path, MAX(timestamp) AS last_view, COUNT(title) AS count FROM {accesslog} WHERE title <> '' GROUP BY title";
$sql = "SELECT title, path, MAX(timestamp) AS last_hit, COUNT(title) AS hits FROM {accesslog} WHERE title <> '' GROUP BY title";
$sql_cnt = "SELECT COUNT(DISTINCT(title)) FROM {accesslog} WHERE title <> ''";
$describe = t('Top titles in the past %interval');
$describe = t('Top pages in the past %interval');
$page_title = strtr($describe, array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))));
$header = array(
array('data' => t('title'), 'field' => 'title'),
array('data' => t('post'), 'field' => 'title'),
array('data' => t('last path'), 'field' => 'path'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit'),
array('data' => t('operations'))
);
$sql .= tablesort_sql($header);
$result = pager_query($sql, 50, 0, $sql_cnt);
while ($title = db_fetch_object($result)) {
$rows[] = array(l(_statistics_column_width($title->title, '_title', 56), urlencode($title->path)), _statistics_column_width($title->path, '_title', 56), format_date($title->last_view, 'small'), $title->count, ($title->title ? l(t('track title'), 'admin/logs/access/title/'. urlencode($title->title)) : ''));
$rows[] = array(l(_statistics_column_width($title->title, '_title', 56), urlencode($title->path)), _statistics_column_width($title->path, '_title', 56), $title->hits, format_date($title->last_hit, 'small'), ($title->title ? l(t('track title'), 'admin/logs/hits/page/'. urlencode($title->title)) : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -321,7 +298,7 @@ function statistics_top_titles() {
* Menu callback; presents the "Top users" page.
*/
function statistics_top_users() {
$sql = "SELECT uid, hostname, MAX(timestamp) AS last_view, COUNT(uid) AS count FROM {accesslog} GROUP BY uid";
$sql = "SELECT uid, hostname, MAX(timestamp) AS last_hit, COUNT(uid) AS hits FROM {accesslog} GROUP BY uid";
$sql_cnt = "SELECT COUNT(DISTINCT(uid)) FROM {accesslog}";
$describe = t('Top users in the past %interval');
@ -330,8 +307,8 @@ function statistics_top_users() {
$header = array(
array('data' => t('user'), 'field' => 'user'),
array('data' => t('last hostname'), 'field' => 'hostname'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit'),
array('data' => t('operations'), 'colspan' => 2)
);
$sql .= tablesort_sql($header);
@ -339,7 +316,7 @@ function statistics_top_users() {
while ($u = db_fetch_object($result)) {
$user = user_load(array('uid' => $u->uid));
$rows[] = array(format_name($user), $u->hostname, format_date($u->last_view, 'small'), $u->count, ($u->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($u->hostname ? l(t('track host'), "admin/logs/access/host/$u->hostname") : ''));
$rows[] = array(format_name($user), $u->hostname, $u->hits, format_date($u->last_hit, 'small'), ($u->uid ? l(t('track user'), "admin/logs/hits/user/$user->uid") : ''), ($u->hostname ? l(t('track host'), "admin/logs/hits/host/$u->hostname") : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -353,7 +330,7 @@ function statistics_top_users() {
* Menu callback; presents the "Top hostnames" page.
*/
function statistics_top_hostnames() {
$sql = "SELECT hostname, uid, MAX(timestamp) AS last_view, COUNT(hostname) AS count FROM {accesslog} GROUP BY hostname";
$sql = "SELECT hostname, uid, MAX(timestamp) AS last_hit, COUNT(hostname) AS hits FROM {accesslog} GROUP BY hostname";
$sql_cnt = "SELECT COUNT(DISTINCT(hostname)) FROM {accesslog}";
$describe = t('Top hostnames in the past %interval');
@ -362,8 +339,8 @@ function statistics_top_hostnames() {
$header = array(
array('data' => t('hostname'), 'field' => 'hostname'),
array('data' => t('last user'), 'field' => 'user'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit'),
array('data' => t('operations'), 'colspan' => 2)
);
$sql .= tablesort_sql($header);
@ -371,7 +348,7 @@ function statistics_top_hostnames() {
while ($hostname = db_fetch_object($result)) {
$user = user_load(array('uid' => $hostname->uid));
$rows[] = array($hostname->hostname, format_name($user), format_date($hostname->last_view, 'small'), $hostname->count, ($hostname->hostname ? l(t('track host'), "admin/logs/access/host/$hostname->hostname") : ''), ($hostname->uid ? l(t('track user'), "admin/logs/access/$hostname->uid") :''));
$rows[] = array($hostname->hostname, format_name($user), $hostname->hits, format_date($hostname->last_hit, 'small'), ($hostname->hostname ? l(t('track host'), "admin/logs/hits/host/$hostname->hostname") : ''), ($hostname->uid ? l(t('track user'), "admin/logs/hits/user/$hostname->uid") :''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -391,18 +368,18 @@ function statistics_top_hostnames() {
*/
function statistics_top_referrers($view = 'all') {
if ($view == 'all') {
$query = "SELECT url, MAX(timestamp) AS last_view, COUNT(url) AS count FROM {accesslog} WHERE url <> '' GROUP BY url";
$query = "SELECT url, MAX(timestamp) AS last_hit, COUNT(url) AS hits FROM {accesslog} WHERE url <> '' GROUP BY url";
$query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> ''";
$describe = t('Top referrers in the past %interval');
}
elseif ($view == 'internal') {
$query = "SELECT url, MAX(timestamp) AS last_view, COUNT(url) AS count FROM {accesslog} WHERE url LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' GROUP BY url";
$query = "SELECT url, MAX(timestamp) AS last_hit, COUNT(url) AS hits FROM {accesslog} WHERE url LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' GROUP BY url";
$query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%'";
$describe = t('Top internal referrers in the past %interval');
}
else {
/* default to external */
$query = "SELECT url, MAX(timestamp) AS last_view, COUNT(url) AS count FROM {accesslog} WHERE url NOT LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' AND url <> '' GROUP BY url";
$query = "SELECT url, MAX(timestamp) AS last_hit, COUNT(url) AS hits FROM {accesslog} WHERE url NOT LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' AND url <> '' GROUP BY url";
$query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url NOT LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%'";
$describe = t('Top external referrers in the past %interval');
}
@ -411,15 +388,15 @@ function statistics_top_referrers($view = 'all') {
$header = array(
array('data' => t('URL'), 'field' => 'url'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc')
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit')
);
$query .= tablesort_sql($header);
$result = pager_query($query, 50, 0, $query_cnt);
while ($referrer = db_fetch_object($result)) {
$rows[] = array('<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url, '_refer', 75) .'</a>', format_date($referrer->last_view, 'small'), $referrer->count);
$rows[] = array('<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url, '_refer', 75) .'</a>', $referrer->hits, format_date($referrer->last_hit, 'small'));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -433,8 +410,27 @@ function statistics_top_referrers($view = 'all') {
/**
* Menu callback; presents the "Most Popular Content" page.
*/
function statistics_admin_topnodes() {
print theme('page', statistics_admin_topnodes_table());
function statistics_admin_content() {
$header = array(
array('data' => t('post'), 'field' => 'n.title'),
array('data' => t('today'), 'field' => 's.daycount', 'sort' => 'desc'),
array('data' => t('all time'), 'field' => 's.totalcount'),
array('data' => t('last hit'), 'field' => 's.timestamp'),
array('data' => t('operations'))
);
$sql = 'SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid';
$sql .= tablesort_sql($header);
$result = pager_query($sql, 20); // WHERE s.%s <> '0'
while ($nid = db_fetch_object($result)) {
$rows[] = array(l($nid->title, 'node/'. $nid->nid, array('title' => t('View this posting.'))), $nid->daycount, $nid->totalcount, format_date($nid->timestamp, 'small'), l('track title', 'admin/logs/hits/page/'. urlencode($nid->title)));
}
if ($pager = theme('pager', NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 5));
}
$output = theme('table', $header, $rows);
print theme('page', $output, t('Top posts'));
}
/**

View File

@ -46,27 +46,27 @@ function statistics_help($section) {
<li><em>administer statistics module</em> - enable for user roles that get to configure the statistics module.</li><li><em>administer statistics</em> - enable for user roles that get to view the referrer statistics.</li>
</ul>
<p>If '<em>administer statistics</em>' and '<em>access statistics</em>' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).</p>",
array('%modules' => url('admin/modules'), '%permissions' => url('admin/user/configure/permission'), '%referer' => url('admin/logs/access/referrers'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/settings/statistics'), '%block' => url('admin/block')));
array('%modules' => url('admin/modules'), '%permissions' => url('admin/user/configure/permission'), '%referer' => url('admin/logs/hits/referrers'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/settings/statistics'), '%block' => url('admin/block')));
case 'admin/modules#description':
return t('Logs access statistics for your site.');
case 'admin/settings/statistics':
return t('Settings for the statistical information that Drupal will keep about the site. See <a href="%statistics">site statistics</a> for the actual information.', array('%statistics' => url('admin/logs/topnodes')));
case 'admin/logs/topnodes':
case 'admin/logs/hits/posts':
return t('This page gives you an at-a-glance look at your most popular content.');
case 'admin/logs/access/titles':
case 'admin/logs/hits/pages':
return t('This page shows access statistics for each page of your website.');
case 'admin/logs/access/users':
case 'admin/logs/hits/users':
return t('This page shows access statistics for each user of your website.');
case 'admin/logs/access/hostnames':
case 'admin/logs/hits/hostnames':
return t('This page shows access statistics for each hostname visiting your website.');
case 'admin/logs/access/referrers':
case 'admin/logs/referrers':
return t('This page shows your site-wide referrer statistics. You can optionally view just the "external referrers" or the "internal referrers". Referrers are web pages, both local and on other sites, that point to your web site.');
case 'admin/logs/access/referrers/internal':
case 'admin/logs/referrers/internal':
return t('This page shows you only "internal referrers". These are links pointing to your web site from within your web site.');
case 'admin/logs/access/referrers/external':
case 'admin/logs/referrers/external':
return t('This page shows you only "external referrers". These are links pointing to your web site from outside your web site.');
case strstr($section, 'admin/logs/access'):
return t("This page shows you who is accessing your web site. You can see the hostnames and referrers. In particular, it is easy to inspect a user's navigation history/trail by clicking on <em>track user</em>.");
case strstr($section, 'admin/logs/hits'):
return t("This page shows you who is accessing your web site. You can see the hostnames and referrers. For example, it is easy to inspect a user's navigation history/trail by clicking on <em>track user</em>.");
}
}
@ -127,7 +127,7 @@ function statistics_link($type, $node = 0, $main = 0) {
$statistics = statistics_get($node->nid);
if ($statistics) {
if (user_access('administer statistics')) {
$links[] = l(format_plural($statistics['totalcount'], '1 read', '%count reads'), 'admin/logs/access/title/'. urlencode($node->title));
$links[] = l(format_plural($statistics['totalcount'], '1 read', '%count reads'), 'admin/logs/hits/page/'. urlencode($node->title));
}
else {
$links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
@ -156,54 +156,31 @@ function statistics_menu() {
'type' => MENU_SUGGESTED_ITEM);
$access = user_access('administer statistics module') || user_access('administer statistics');
$items[] = array('path' => 'admin/logs/topnodes', 'title' => t('top nodes'),
'callback' => 'statistics_admin_topnodes', 'access' => $access,
'weight' => 1);
$items[] = array('path' => 'admin/logs/access', 'title' => t('access'),
$items[] = array('path' => 'admin/logs/hits', 'title' => t('hits'),
'callback' => 'statistics_admin_displaylog', 'access' => $access,
'weight' => 3);
$items[] = array('path' => 'admin/logs/access/titles', 'title' => t('titles'),
$items[] = array('path' => 'admin/logs/hits/posts', 'title' => t('posts'),
'callback' => 'statistics_admin_content', 'access' => $access,
'weight' => 1);
$items[] = array('path' => 'admin/logs/hits/pages', 'title' => t('pages'),
'callback' => 'statistics_top_titles', 'access' => $access,
'weight' => 1);
$items[] = array('path' => 'admin/logs/access/users', 'title' => t('users'),
$items[] = array('path' => 'admin/logs/hits/users', 'title' => t('users'),
'callback' => 'statistics_top_users', 'access' => $access,
'weight' => 2);
$items[] = array('path' => 'admin/logs/access/hostnames',
$items[] = array('path' => 'admin/logs/hits/hostnames',
'title' => t('hostnames'), 'callback' => 'statistics_top_hostnames',
'access' => $access, 'weight' => 3);
$items[] = array('path' => 'admin/logs/access/referrers',
$items[] = array('path' => 'admin/logs/referrers',
'title' => t('referrers'), 'callback' => 'statistics_top_referrers',
'access' => $access, 'weight' => 4);
$items[] = array('path' => 'admin/logs/access/referrers/internal',
$items[] = array('path' => 'admin/logs/referrers/internal',
'title' => t('internal'), 'access' => $access);
$items[] = array('path' => 'admin/logs/access/referrers/external',
$items[] = array('path' => 'admin/logs/referrers/external',
'title' => t('external'), 'access' => $access);
return $items;
}
function statistics_admin_topnodes_table() {
$header = array(
array('data' => t('title'), 'field' => 'n.title'),
array('data' => t('today'), 'field' => 's.daycount', 'sort' => 'desc'),
array('data' => t('all time'), 'field' => 's.totalcount'),
array('data' => t('last hit'), 'field' => 's.timestamp'),
array('data' => t('operations'))
);
$sql = 'SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid';
$sql .= tablesort_sql($header);
$result = pager_query($sql, 20); // WHERE s.%s <> '0'
while ($nid = db_fetch_array($result)) {
$rows[] = array(l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]"));
}
if ($pager = theme('pager', NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 5));
}
return theme('table', $header, $rows);
}
/**
* Menu callback; presents the "Access logs" page.
*
@ -231,7 +208,7 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
$sql = 'SELECT title, path, url, hostname, uid, MAX(timestamp) AS timestamp FROM {accesslog} WHERE uid <> 0 GROUP BY uid, title, path, url, hostname';
}
break;
case 'title':
case 'page':
// retrieve recent access logs for title $id
$page_title = t('Recent access logs for "%title"', array('%title' => $id));
$sql = 'SELECT title, path, url, hostname, uid, timestamp FROM {accesslog} WHERE title = \''. check_query($id) ."'";
@ -250,7 +227,7 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
$header = array(
array('data' => t('timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
array('data' => t('title'), 'field' => 'title'),
array('data' => t('post'), 'field' => 'title'),
array('data' => t('user'), 'field' => 'uid'),
array('data' => t('hostname'), 'field' => 'hostname'),
array('data' => t('referrer'), 'field' => 'url'),
@ -275,7 +252,7 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
$url = message_na();
$user = user_load(array('uid' => $log->uid));
$rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), $title, format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->title ? l(t('track title'), 'admin/logs/access/title/'. urlencode($log->title)) : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : ''));
$rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), $title, format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($user->uid ? l(t('track user'), "admin/logs/hits/user/$user->uid") : ''), ($log->title ? l(t('track title'), 'admin/logs/hits/page/'. urlencode($log->title)) : ''), ($log->hostname ? l(t('track host'), "admin/logs/hits/host/$log->hostname") : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
@ -287,27 +264,27 @@ function statistics_admin_displaylog($type = 'all', $id = 0) {
}
/**
* Menu callback; presents the "Top titles" page.
* Menu callback; presents the "Top pages" page.
*/
function statistics_top_titles() {
$sql = "SELECT title, path, MAX(timestamp) AS last_view, COUNT(title) AS count FROM {accesslog} WHERE title <> '' GROUP BY title";
$sql = "SELECT title, path, MAX(timestamp) AS last_hit, COUNT(title) AS hits FROM {accesslog} WHERE title <> '' GROUP BY title";
$sql_cnt = "SELECT COUNT(DISTINCT(title)) FROM {accesslog} WHERE title <> ''";
$describe = t('Top titles in the past %interval');
$describe = t('Top pages in the past %interval');
$page_title = strtr($describe, array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))));
$header = array(
array('data' => t('title'), 'field' => 'title'),
array('data' => t('post'), 'field' => 'title'),
array('data' => t('last path'), 'field' => 'path'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit'),
array('data' => t('operations'))
);
$sql .= tablesort_sql($header);
$result = pager_query($sql, 50, 0, $sql_cnt);
while ($title = db_fetch_object($result)) {
$rows[] = array(l(_statistics_column_width($title->title, '_title', 56), urlencode($title->path)), _statistics_column_width($title->path, '_title', 56), format_date($title->last_view, 'small'), $title->count, ($title->title ? l(t('track title'), 'admin/logs/access/title/'. urlencode($title->title)) : ''));
$rows[] = array(l(_statistics_column_width($title->title, '_title', 56), urlencode($title->path)), _statistics_column_width($title->path, '_title', 56), $title->hits, format_date($title->last_hit, 'small'), ($title->title ? l(t('track title'), 'admin/logs/hits/page/'. urlencode($title->title)) : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -321,7 +298,7 @@ function statistics_top_titles() {
* Menu callback; presents the "Top users" page.
*/
function statistics_top_users() {
$sql = "SELECT uid, hostname, MAX(timestamp) AS last_view, COUNT(uid) AS count FROM {accesslog} GROUP BY uid";
$sql = "SELECT uid, hostname, MAX(timestamp) AS last_hit, COUNT(uid) AS hits FROM {accesslog} GROUP BY uid";
$sql_cnt = "SELECT COUNT(DISTINCT(uid)) FROM {accesslog}";
$describe = t('Top users in the past %interval');
@ -330,8 +307,8 @@ function statistics_top_users() {
$header = array(
array('data' => t('user'), 'field' => 'user'),
array('data' => t('last hostname'), 'field' => 'hostname'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit'),
array('data' => t('operations'), 'colspan' => 2)
);
$sql .= tablesort_sql($header);
@ -339,7 +316,7 @@ function statistics_top_users() {
while ($u = db_fetch_object($result)) {
$user = user_load(array('uid' => $u->uid));
$rows[] = array(format_name($user), $u->hostname, format_date($u->last_view, 'small'), $u->count, ($u->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($u->hostname ? l(t('track host'), "admin/logs/access/host/$u->hostname") : ''));
$rows[] = array(format_name($user), $u->hostname, $u->hits, format_date($u->last_hit, 'small'), ($u->uid ? l(t('track user'), "admin/logs/hits/user/$user->uid") : ''), ($u->hostname ? l(t('track host'), "admin/logs/hits/host/$u->hostname") : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -353,7 +330,7 @@ function statistics_top_users() {
* Menu callback; presents the "Top hostnames" page.
*/
function statistics_top_hostnames() {
$sql = "SELECT hostname, uid, MAX(timestamp) AS last_view, COUNT(hostname) AS count FROM {accesslog} GROUP BY hostname";
$sql = "SELECT hostname, uid, MAX(timestamp) AS last_hit, COUNT(hostname) AS hits FROM {accesslog} GROUP BY hostname";
$sql_cnt = "SELECT COUNT(DISTINCT(hostname)) FROM {accesslog}";
$describe = t('Top hostnames in the past %interval');
@ -362,8 +339,8 @@ function statistics_top_hostnames() {
$header = array(
array('data' => t('hostname'), 'field' => 'hostname'),
array('data' => t('last user'), 'field' => 'user'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit'),
array('data' => t('operations'), 'colspan' => 2)
);
$sql .= tablesort_sql($header);
@ -371,7 +348,7 @@ function statistics_top_hostnames() {
while ($hostname = db_fetch_object($result)) {
$user = user_load(array('uid' => $hostname->uid));
$rows[] = array($hostname->hostname, format_name($user), format_date($hostname->last_view, 'small'), $hostname->count, ($hostname->hostname ? l(t('track host'), "admin/logs/access/host/$hostname->hostname") : ''), ($hostname->uid ? l(t('track user'), "admin/logs/access/$hostname->uid") :''));
$rows[] = array($hostname->hostname, format_name($user), $hostname->hits, format_date($hostname->last_hit, 'small'), ($hostname->hostname ? l(t('track host'), "admin/logs/hits/host/$hostname->hostname") : ''), ($hostname->uid ? l(t('track user'), "admin/logs/hits/user/$hostname->uid") :''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -391,18 +368,18 @@ function statistics_top_hostnames() {
*/
function statistics_top_referrers($view = 'all') {
if ($view == 'all') {
$query = "SELECT url, MAX(timestamp) AS last_view, COUNT(url) AS count FROM {accesslog} WHERE url <> '' GROUP BY url";
$query = "SELECT url, MAX(timestamp) AS last_hit, COUNT(url) AS hits FROM {accesslog} WHERE url <> '' GROUP BY url";
$query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> ''";
$describe = t('Top referrers in the past %interval');
}
elseif ($view == 'internal') {
$query = "SELECT url, MAX(timestamp) AS last_view, COUNT(url) AS count FROM {accesslog} WHERE url LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' GROUP BY url";
$query = "SELECT url, MAX(timestamp) AS last_hit, COUNT(url) AS hits FROM {accesslog} WHERE url LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' GROUP BY url";
$query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%'";
$describe = t('Top internal referrers in the past %interval');
}
else {
/* default to external */
$query = "SELECT url, MAX(timestamp) AS last_view, COUNT(url) AS count FROM {accesslog} WHERE url NOT LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' AND url <> '' GROUP BY url";
$query = "SELECT url, MAX(timestamp) AS last_hit, COUNT(url) AS hits FROM {accesslog} WHERE url NOT LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%' AND url <> '' GROUP BY url";
$query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url NOT LIKE '%". check_query($_SERVER['HTTP_HOST']) ."%'";
$describe = t('Top external referrers in the past %interval');
}
@ -411,15 +388,15 @@ function statistics_top_referrers($view = 'all') {
$header = array(
array('data' => t('URL'), 'field' => 'url'),
array('data' => t('last view'), 'field' => 'last_view'),
array('data' => t('hits'), 'field' => 'count', 'sort' => 'desc')
array('data' => t('hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('last hit'), 'field' => 'last_hit')
);
$query .= tablesort_sql($header);
$result = pager_query($query, 50, 0, $query_cnt);
while ($referrer = db_fetch_object($result)) {
$rows[] = array('<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url, '_refer', 75) .'</a>', format_date($referrer->last_view, 'small'), $referrer->count);
$rows[] = array('<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url, '_refer', 75) .'</a>', $referrer->hits, format_date($referrer->last_hit, 'small'));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 3));
@ -433,8 +410,27 @@ function statistics_top_referrers($view = 'all') {
/**
* Menu callback; presents the "Most Popular Content" page.
*/
function statistics_admin_topnodes() {
print theme('page', statistics_admin_topnodes_table());
function statistics_admin_content() {
$header = array(
array('data' => t('post'), 'field' => 'n.title'),
array('data' => t('today'), 'field' => 's.daycount', 'sort' => 'desc'),
array('data' => t('all time'), 'field' => 's.totalcount'),
array('data' => t('last hit'), 'field' => 's.timestamp'),
array('data' => t('operations'))
);
$sql = 'SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid';
$sql .= tablesort_sql($header);
$result = pager_query($sql, 20); // WHERE s.%s <> '0'
while ($nid = db_fetch_object($result)) {
$rows[] = array(l($nid->title, 'node/'. $nid->nid, array('title' => t('View this posting.'))), $nid->daycount, $nid->totalcount, format_date($nid->timestamp, 'small'), l('track title', 'admin/logs/hits/page/'. urlencode($nid->title)));
}
if ($pager = theme('pager', NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 5));
}
$output = theme('table', $header, $rows);
print theme('page', $output, t('Top posts'));
}
/**