Same name and namespace in other branches
  1. 4.7.x modules/statistics.module \statistics_top_pages()
  2. 5.x modules/statistics/statistics.module \statistics_top_pages()
  3. 6.x modules/statistics/statistics.admin.inc \statistics_top_pages()
  4. 7.x modules/statistics/statistics.admin.inc \statistics_top_pages()

Menu callback; presents the "Top pages" page.

1 string reference to 'statistics_top_pages'
statistics_menu in modules/statistics.module
Implementation of hook_menu().

File

modules/statistics.module, line 253
Logs access statistics for your site.

Code

function statistics_top_pages() {
  $sql = "SELECT COUNT(path) AS hits, path, title FROM {accesslog} GROUP BY path, title";
  $sql_cnt = "SELECT COUNT(DISTINCT(path)) FROM {accesslog}";
  $header = array(
    array(
      'data' => t('Hits'),
      'field' => 'hits',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Page'),
      'field' => 'path',
    ),
  );
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, 30, 0, $sql_cnt);
  while ($page = db_fetch_object($result)) {
    $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',
      ),
    );
  }
  drupal_set_title(t('Top pages in the past %interval', array(
    '%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)),
  )));
  print theme('page', theme('table', $header, $rows));
}