You are here

function theme_popup_onload_statistics_table in Popup On Load 8

Same name and namespace in other branches
  1. 7 popup_onload_statistics/popup_onload_statistics.theme.inc \theme_popup_onload_statistics_table()

Theme popup statistics table.

1 theme call to theme_popup_onload_statistics_table()
popup_onload_statistics_admin_form in modules/popup_onload_statistics/popup_onload_statistics.admin.inc
Callback for the admin report table.

File

modules/popup_onload_statistics/popup_onload_statistics.theme.inc, line 11
Popup stats theme file.

Code

function theme_popup_onload_statistics_table($vars) {
  $output = '';
  $stats_table = array(
    'header' => array(
      t('Popup'),
      t('Impressions'),
      t('Clicks'),
      t('CTR (Click-Through Rate)'),
    ),
    'rows' => array(),
  );
  foreach ($vars['stats'] as $row) {
    if (!isset($row['view'])) {
      $row['view'] = 0;
    }
    if (!isset($row['click'])) {
      $row['click'] = 0;
    }
    $rate = $row['view'] != 0 ? $row['click'] / $row['view'] : 0;
    $stats_table['rows'][] = array(
      l($row['name'], 'admin/structure/popup_onload/manage/' . $row['popup_id'], array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
      isset($row['view']) ? $row['view'] : 0,
      isset($row['click']) ? $row['click'] : 0,
      sprintf('%.2f%%', $rate * 100),
    );
  }
  $output .= theme('table', $stats_table);
  return $output;
}