function theme_ad_status_display in Advertisement 5.2
Same name and namespace in other branches
- 5 ad.module \theme_ad_status_display()
- 6.3 ad.module \theme_ad_status_display()
- 6 ad.module \theme_ad_status_display()
- 6.2 ad.module \theme_ad_status_display()
- 7 ad.module \theme_ad_status_display()
Display the status of the currently viewed ad.
2 theme calls to theme_ad_status_display()
- ad_form in ./
ad.module - Drupal _form hook.
- theme_node_ad in ./
ad.module
File
- ./
ad.module, line 432 - An advertising system for Drupal powered websites.
Code
function theme_ad_status_display($node) {
$status_array = ad_status_array();
$output = '<div class="adstatus">';
$output .= '<p>' . t($status_array["{$node->adstatus}"]) . '</p>';
switch ($node->adstatus) {
case 'approved':
if ($node->autoactivate) {
$output .= '<p>' . t('This advertisement will be automatically activated on %timestamp, in %time.', array(
'%timestamp' => format_date($node->autoactivate, 'large'),
'%time' => format_interval($node->autoactivate - time()),
)) . '</p>';
}
break;
case 'active':
$activated = db_result(db_query("SELECT activated FROM {ads} WHERE aid = %d", $node->nid));
if ($activated) {
$output .= '<p>' . t('This advertisement has been active since %date.', array(
'%date' => format_date($activated, 'large'),
)) . '</p>';
}
if ($node->autoexpire) {
$output .= '<p>' . t('This advertisement will expire on %timestamp, in %time.', array(
'%timestamp' => format_date($node->autoexpire, 'large'),
'%time' => format_interval($node->autoexpire - time()),
)) . '</p>';
}
if ($node->maxviews) {
$views = (int) db_result(db_query("SELECT SUM(count) FROM {ad_statistics} WHERE aid = %d AND action = 'view' AND date >= %d", $node->nid, date('YmdH', $node->activated)));
$output .= '<p>' . t('This advertisement will expire after %left more views.', array(
'%left' => $node->maxviews - $views,
)) . '</p>';
}
if ($node->maxclicks) {
$clicks = (int) db_result(db_query("SELECT SUM(count) FROM {ad_statistics} WHERE aid = %d AND action = 'click' AND date >= %d", $node->nid, date('YmdH', $node->activated)));
$output .= '<p>' . t('This advertisement will expire after %left more clicks.', array(
'%left' => $node->maxclicks - $clicks,
)) . '</p>';
}
break;
case 'expired':
$expired = db_result(db_query("SELECT expired FROM {ads} WHERE aid = %d", $node->nid));
if ($expired) {
$output .= '<p>' . t('This advertisement expired %date.', array(
'%date' => format_date($expired, 'large'),
)) . '</p>';
}
break;
}
$output .= '</div>';
return theme('box', t('Status'), $output);
}