You are here

function total_control_overview_content_content_type_render in Total Control Admin Dashboard 6

Same name and namespace in other branches
  1. 6.2 plugins/content_types/overview_content.inc \total_control_overview_content_content_type_render()
  2. 7.2 plugins/content_types/overview_content.inc \total_control_overview_content_content_type_render()

File

plugins/content_types/overview_content.inc, line 29

Code

function total_control_overview_content_content_type_render($subtype, $conf, $panel_args, &$context) {
  $block = new stdClass();
  $block->module = t('total_control');
  $types = node_get_types('types');
  $overview = array();

  // Content Overview
  foreach ($types as $type => $object) {
    if (empty($conf['types']) || isset($conf['types']) && $conf['types'][$type]) {

      // compare against type option on pane config
      $type_query = db_query("SELECT count(*) FROM {node} WHERE type = '%s' and status = 1", $type);
      $total[$type] = format_plural(db_result($type_query), '1 ' . $object->name . ' item', '@count ' . $object->name . ' items');
      $comment_setting = variable_get('comment_' . $type, 'comment');
      if ($comment_setting != 0 || isset($conf['comments']) && $conf['comments'][$type]) {

        // compare against comment option on pane config
        $comment_query = db_query("SELECT count(DISTINCT cid) FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid WHERE n.type = '%s' and c.status = 1 AND n.status = 1", $type);
        $total[$type . '_comments'] = format_plural(db_result($comment_query), '1 comment', '@count comments');
        if (isset($conf['spam']) && $conf['spam'] == 1) {

          // compare against comment option on pane config
          $spam_query = db_query("SELECT count(DISTINCT c.cid) FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid WHERE n.type = '%s' and c.status = 0 AND n.status = 1", $type);
          $total[$type . '_comments_spam'] = format_plural(db_result($spam_query), '1 spam', '@count spam');
        }

        // if spam
      }

      // if comment
      $line = $total[$type];
      $line .= isset($total[$type . '_comments']) ? ' with ' . $total[$type . '_comments'] : '';
      $line .= isset($total[$type . '_comments_spam']) ? ' (' . $total[$type . '_comments_spam'] . ')' : '';
      $overview[] = $line;
    }

    // if type
  }

  // foreach
  $pane = total_control_overview_content_ctools_content_types();

  // assemble content
  $content = '<div class="total-control-content-overview">';
  $content .= '  <h2 class="title">' . $pane['title'] . '</h2>';
  $content .= '  <div class="content">';
  $content .= theme('item_list', $overview);
  $content .= '  </div>';
  $content .= '</div>';
  $block->content = $content;
  return $block;
}