You are here

function simpleads_simpleads_stats_info in SimpleAds 7

Implements hook_simpleads_stats_info().

File

./simpleads.module, line 537

Code

function simpleads_simpleads_stats_info($node, $op) {
  $activity = t('Active');
  if (isset($node->field_ad_status[$node->language])) {
    if ($node->field_ad_status[$node->language][0]['value'] == 1) {
      $activity = t('Active');
    }
    else {
      $activity = t('Inactive');
    }
  }
  if ($op == 'list') {
    $ad_title = l($node->title, 'admin/content/simpleads/' . $node->nid . '/stat', array(
      'html' => FALSE,
    ));
    return array(
      $ad_title,
    );
  }
  if ($op == 'ad_group') {
    $term_name = "";
    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;
    }
    $ad_group = !empty($term_name) ? $term_name : '';
    return array(
      $ad_group,
    );
  }
  if ($op == 'ad_status') {
    return array(
      _simpleads_statuses($node),
    );
  }
  if ($op == 'ad_activity') {
    return array(
      $activity,
    );
  }
  if ($op == 'ad_status_detail') {
    $days_left_str = "";
    $days_left = _simpleads_date_diff($node);
    if ($days_left && $days_left > 0) {
      $days_left_str = ', ' . format_plural($days_left, '1 day left.', '@count days left.');
    }

    // Domain module information (if available).
    $domain_module = "";
    if (module_exists('domain')) {
      if (isset($node->subdomains) && count($node->subdomains)) {
        $domain_module = t('Published on !list', array(
          '!list' => join(", ", $node->subdomains),
        ));
      }
    }
    return array(
      _simpleads_statuses($node) . ' (' . $activity . ')' . $days_left_str,
      $domain_module,
    );
  }
  if ($op == 'ad_operations') {
    $operations = array();
    $operations[] = l(t('Statistics'), 'admin/content/simpleads/' . $node->nid . '/stat') . '    ' . l(t('Edit'), 'node/' . $node->nid . '/edit', array(
      'query' => array(
        'destination' => 'admin/content/simpleads',
      ),
    )) . '    ' . l(t('Delete'), 'node/' . $node->nid . '/delete', array(
      'query' => array(
        'destination' => 'admin/content/simpleads',
      ),
    ));
    return $operations;
  }
}