You are here

function theme_ad_status_display in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 ad.module \theme_ad_status_display()
  2. 5 ad.module \theme_ad_status_display()
  3. 6 ad.module \theme_ad_status_display()
  4. 6.2 ad.module \theme_ad_status_display()
  5. 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
Implementation of hook_form().
theme_node_ad in ./ad.pages.inc
@file Advertisement nodes pages and forms.

File

./ad.module, line 324

Code

function theme_ad_status_display($node) {
  if (isset($node->adstatus)) {
    $status_array = ad_status_array($node->nid, $node->adstatus);
    $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 impressions.', 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);
  }
}