statistics_recent_hits
- Versions
- 4.6
statistics_recent_hits($type= 'all',$id= 0)- 4.7 – 7
statistics_recent_hits()
Menu callback; presents the "recent hits" page.
Code
modules/statistics/statistics.admin.inc, line 11
<?php
function statistics_recent_hits() {
$header = array(
array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'),
array('data' => t('Page'), 'field' => 'a.path'),
array('data' => t('User'), 'field' => 'u.name'),
array('data' => t('Operations'))
);
$query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
$query->join('users', 'u', 'a.uid = u.uid');
$query
->fields('a', array('aid', 'timestamp', 'path', 'title', 'uid'))
->fields('u', array('name'))
->limit(30)
->orderByHeader($header);
$result = $query->execute();
$rows = array();
foreach ($result as $log) {
$rows[] = array(
array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
_statistics_format_item($log->title, $log->path),
theme('username', array('account' => $log)),
l(t('details'), "admin/reports/access/$log->aid"));
}
if (empty($rows)) {
$rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
}
$build['statistics_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
$build['statistics_pager'] = array('#theme' => 'pager');
return $build;
}
?>Login or register to post comments 