function theme_node_ad in Advertisement 6.3
Same name and namespace in other branches
- 5.2 ad.module \theme_node_ad()
- 5 ad.module \theme_node_ad()
- 6 ad.pages.inc \theme_node_ad()
- 6.2 ad.pages.inc \theme_node_ad()
- 7 ad.pages.inc \theme_node_ad()
@file Advertisement nodes pages and forms.
Copyright (c) 2005-2009. Jeremy Andrews <jeremy@tag1consulting.com>
1 theme call to theme_node_ad()
- ad_nodeapi in ./
ad.module - Implementation of hook_nodeapi().
File
- ./
ad.pages.inc, line 11 - Advertisement nodes pages and forms.
Code
function theme_node_ad($node, $yield_form = TRUE) {
$output = '';
if (ad_permission($node, 'access statistics')) {
$output = theme('ad_status_display', $node);
$output .= theme('ad_statistics_display', ad_statistics($node->nid));
}
if (ad_permission($node, 'access click history')) {
$header = array(
array(
'data' => t('Time'),
'field' => 'timestamp',
'sort' => 'desc',
),
array(
'data' => t('User'),
'field' => 'uid',
),
array(
'data' => t('URL where clicked'),
'field' => 'url',
),
);
if (function_exists('click_filter_status_text') && user_access('view filtered clicks')) {
$header[] = array(
'data' => t('Status'),
'field' => 'status',
);
}
$header[] = '';
if (isset($node->nid) && $node->nid > 0) {
$sql = "SELECT cid, timestamp, uid, status, hostname, url FROM {ad_clicks} WHERE aid = %d";
$sql .= tablesort_sql($header);
$result = pager_query($sql, 25, 0, NULL, $node->nid);
while ($ad = db_fetch_object($result)) {
if (module_exists('click_filter') && $ad->status != CLICK_VALID) {
// Only show filtered clicks to users with permission to view them.
if (!user_access('view filtered clicks')) {
continue;
}
}
if (strlen($ad->url) > 40) {
$url = substr($ad->url, 0, 37) . '...';
}
else {
$url = $ad->url;
}
$row = array();
$click_user = user_load(array(
'uid' => $ad->uid,
));
$row[] = format_date($ad->timestamp, 'custom', 'M j H:i');
$row[] = theme('username', $click_user);
$row[] = l($url, $ad->url);
if (function_exists('click_filter_status_text') && user_access('view filtered clicks')) {
$row[] = click_filter_status_text($ad->status);
}
$row[] = '[' . l(t('details'), 'node/' . $node->nid . '/details/' . $ad->cid) . ']';
$rows[] = $row;
}
if (empty($rows)) {
$click_history = '<p>' . t('There are no clicks yet.') . '</p>';
}
else {
$click_history = theme('table', $header, $rows);
}
$click_history .= theme('pager', NULL, 25, 0);
$output .= theme('box', t('Click history'), $click_history);
}
}
return $output;
}