You are here

function theme_ad_statistics_display in Advertisement 5

Same name and namespace in other branches
  1. 5.2 ad.module \theme_ad_statistics_display()
  2. 6.3 ad.pages.inc \theme_ad_statistics_display()
  3. 6 ad.pages.inc \theme_ad_statistics_display()
  4. 6.2 ad.pages.inc \theme_ad_statistics_display()
  5. 7 ad.pages.inc \theme_ad_statistics_display()
3 theme calls to theme_ad_statistics_display()
ad_admin_statistics in ./ad.module
ad_form in ./ad.module
Drupal _form hook.
theme_node_ad in ./ad.module

File

./ad.module, line 398
An advertising system for Drupal powered websites.

Code

function theme_ad_statistics_display($statistics) {
  $headers = array(
    '',
    t('Views'),
    t('Clicks'),
    t('Click-thru'),
  );
  $rows = array();
  $data = array(
    'this_hour' => t('This hour'),
    'last_hour' => t('Last hour'),
    'today' => t('Today'),
    'yesterday' => t('Yesterday'),
    'this_week' => t('Last seven days'),
    'last_week' => t('Last week'),
    'this_month' => t('This month'),
    'last_month' => t('Last month'),
    'this_year' => t('This year'),
    'last_year' => t('Last year'),
    'global' => t('All time'),
  );
  foreach ($data as $key => $value) {
    if ($statistics[$key]['views'] || $statistics[$key]['clicks'] || $key == 'global') {
      $rows[] = array(
        array(
          'data' => $value,
        ),
        array(
          'data' => (int) $statistics[$key]['views'],
        ),
        array(
          'data' => (int) $statistics[$key]['clicks'],
        ),
        array(
          'data' => $statistics[$key]['views'] ? sprintf('%1.2f', (int) $statistics[$key]['clicks'] / (int) $statistics[$key]['views'] * 100) . '%' : '0.00%',
        ),
      );
    }
  }
  return theme('box', t('Statistics'), theme('table', $headers, $rows));
}