function _simpleads_stat_tab in SimpleAds 7
Callback for Ad Statistics page.
1 string reference to '_simpleads_stat_tab'
- simpleads_menu in ./
simpleads.module - Implements hook_menu().
File
- ./
simpleads.stat.inc, line 11 - SimpleAds Statistics.
Code
function _simpleads_stat_tab($nid) {
$result = " ";
$stats_form = drupal_get_form('_simpleads_after_stats_form');
$form_after_stats = drupal_render($stats_form);
if (is_numeric($nid)) {
$node = node_load($nid);
if ($node) {
$stats = _simpleads_get_statistics('simpleads_clicks', $nid);
$stat_results = array();
foreach ($stats as $key => $val) {
$header[]['data'] = t($key);
$stat_results[]['data'] = $val;
}
$clicks[] = $stat_results;
$stats = _simpleads_get_statistics('simpleads_impressions', $nid);
$stat_results = array();
foreach ($stats as $key => $val) {
$stat_results[]['data'] = $val;
}
$impressions[] = $stat_results;
$term_name = "";
$op_links = l(t('Edit'), 'node/' . $node->nid . '/edit', array(
'query' => array(
'destination' => 'admin/content/simpleads',
),
));
if (isset($node->field_ad_category[$node->language]) && !empty($node->field_ad_category[$node->language][0]['tid'])) {
$term = taxonomy_term_load($node->field_ad_category[$node->language][0]['tid']);
$term_name = $term->name;
}
elseif (isset($node->field_ad_category[LANGUAGE_NONE]) && !empty($node->field_ad_category[LANGUAGE_NONE][0]['tid'])) {
$term = taxonomy_term_load($node->field_ad_category[LANGUAGE_NONE][0]['tid']);
$term_name = $term->name;
}
$result .= '<h1>' . t("@adgroup: @adtitle - !link", array(
'@adgroup' => $term_name,
'@adtitle' => $node->title,
'!link' => $op_links,
)) . '</h1>';
$result .= '<span>' . _simpleads_stats_info($node, 'ad_status_detail') . '</span>';
$result .= _simpleads_stats_info($node, 'detail');
$result .= theme('table', array(
'header' => $header,
'rows' => $clicks,
'caption' => t('Ad Clicks / Unique Clicks'),
));
$result .= theme('table', array(
'header' => $header,
'rows' => $impressions,
'caption' => t('Ad Impressions / Unique Impressions'),
));
$result .= $form_after_stats;
}
}
return $result;
}