You are here

function theme_ad_statistics_display in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 ad.module \theme_ad_statistics_display()
  2. 5 ad.module \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()
1 theme call to theme_ad_statistics_display()
theme_node_ad in ./ad.pages.inc
@file Advertisement nodes pages and forms.

File

./ad.pages.inc, line 152
Advertisement nodes pages and forms.

Code

function theme_ad_statistics_display($statistics) {
  $header = array(
    '',
    t('Impressions'),
    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'),
    '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 (isset($statistics[$key]) && (isset($statistics[$key]['views']) || isset($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%',
        ),
      );
    }
  }
  if (empty($rows) || !$statistics['global']['views'] && !$statistics['global']['clicks']) {
    $statistics = '<p>' . t('There are currently no statistics for this advertisement.') . '</p>';
  }
  else {
    $statistics = theme('table', $header, $rows);
  }
  return theme('box', t('Statistics'), $statistics);
}