function theme_node_ad in Advertisement 7
Same name and namespace in other branches
- 5.2 ad.module \theme_node_ad()
- 5 ad.module \theme_node_ad()
- 6.3 ad.pages.inc \theme_node_ad()
- 6 ad.pages.inc \theme_node_ad()
- 6.2 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
File
- ./
ad.pages.inc, line 11 - Advertisement nodes pages and forms.
Code
function theme_node_ad($variables) {
$node = $variables['node'];
$yield_form = isset($variables['yield_form']) ? $variables['yield_form'] : TRUE;
$output = '';
if (ad_check_permission($node, 'access statistics')) {
$output = theme('ad_status_display', array(
'node' => $node,
));
$output .= theme('ad_statistics_display', array(
'statistics' => ad_statistics($node->nid),
));
}
if (ad_check_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) {
$result = db_select('ad_clicks', 'clicks')
->extend('PagerDefault')
->extend('TableSort')
->limit(25)
->condition('aid', $node->nid)
->orderByHeader($header)
->fields('clicks', array(
'cid',
'timestamp',
'uid',
'status',
'hostname',
'url',
))
->execute();
foreach ($result as $ad) {
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($ad->uid);
$row[] = format_date($ad->timestamp, 'custom', 'M j H:i');
$row[] = theme('username', array(
'name' => $click_user->name,
));
$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', array(
'header' => $header,
'rows' => $rows,
));
}
$click_history .= theme('pager');
$output .= theme('ad_box', array(
'title' => t('Click history'),
'content' => $click_history,
));
}
}
return $output;
}