You are here

function adsense_click_top_pages in Google AdSense integration 5.3

Same name and namespace in other branches
  1. 5 adsense.module \adsense_click_top_pages()
  2. 5.2 adsense.module \adsense_click_top_pages()
  3. 6 contrib/adsense_click/adsense_click.logs.inc \adsense_click_top_pages()
  4. 7 contrib/adsense_click/adsense_click.logs.inc \adsense_click_top_pages()
1 string reference to 'adsense_click_top_pages'
adsense_click_menu in contrib/adsense_click/adsense_click.module
Implementation of hook_menu().

File

contrib/adsense_click/adsense_click.logs.inc, line 43
Contains the functions to display the logs tracked by the adsense_click module.

Code

function adsense_click_top_pages() {
  $header = array(
    array(
      'data' => t('Path'),
      'field' => 'path',
    ),
    array(
      'data' => t('Clicks'),
      'field' => 'count',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Last'),
      'field' => 'last',
    ),
  );
  $sql = 'SELECT path, COUNT(*) AS count, MAX(timestamp) AS last FROM {adsense_clicks} GROUP BY path' . tablesort_sql($header);
  $result = pager_query($sql, 50);
  while ($log = db_fetch_object($result)) {
    $title = db_result(db_query("SELECT title FROM {adsense_clicks} WHERE path = '%s'", $path));
    $rows[] = array(
      array(
        'data' => _adsense_click_format_path($log->path, $title),
      ),
      array(
        'data' => $log->count,
        'align' => 'right',
      ),
      array(
        'data' => format_date($log->last, 'small'),
        'nowrap' => 'nowrap',
      ),
    );
  }
  return theme('table', $header, $rows) . theme('pager', NULL, 50, 0);
}