function total_control_get_content_overview in Total Control Admin Dashboard 6.2
Same name and namespace in other branches
- 7.2 includes/total_control.inc \total_control_get_content_overview()
Retrieves overview data for all content on the site.
Parameters
$conf: Panel content pane config data.
Return value
$items An array of items for a bulleted list.
2 calls to total_control_get_content_overview()
- total_control_overview_content_content_type_render in plugins/
content_types/ overview_content.inc - Run-time rendering of the body of the block.
- total_control_overview_content_type_render in plugins/
content_types/ overview.inc - Run-time rendering of the body of the block.
File
- includes/
total_control.inc, line 339 - total_control.inc
Code
function total_control_get_content_overview($conf = array()) {
$types = node_get_types('types');
$items = array();
foreach ($types as $type => $object) {
// Compare against type option on pane config.
if (empty($conf['types']) || isset($conf['types']) && $conf['types'][$type] == $type) {
$type_sql = "SELECT count(*) FROM {node} \n WHERE type = '%s' and status = 1";
$type_query = db_query($type_sql, $type);
$singular = '1 ' . $object->name . ' item';
$plural = '@count ' . $object->name . ' items';
$total[$type] = format_plural(db_result($type_query), $singular, $plural);
// Check if comments module is enabled.
if (module_exists('comment')) {
// Compare against comment options on pane config.
if (is_array($conf['comments']) && array_key_exists($type, $conf['comments']) && $conf['comments'][$type] === $type) {
$comment_sql = "SELECT count(DISTINCT cid) FROM {comments} c \n INNER JOIN {node} n ON c.nid = n.nid \n WHERE n.type = '%s' and c.status = 1 AND n.status = 1";
$comment_query = db_query($comment_sql, $type);
$total[$type . '_comments'] = format_plural(db_result($comment_query), '1 comment', '@count comments');
// Compare against spam option checkbox on pane config.
if (isset($conf['spam']) && $conf['spam'] == 1) {
$spam_sql = "SELECT count(DISTINCT c.cid) FROM {comments} c \n INNER JOIN {node} n ON c.nid = n.nid \n WHERE n.type = '%s' and c.status = 0 AND n.status = 1";
$spam_query = db_query($spam_sql, $type);
$total[$type . '_comments_spam'] = format_plural(db_result($spam_query), '1 spam', '@count spam');
}
}
}
$line = $total[$type];
$line .= isset($total[$type . '_comments']) ? ' with ' . $total[$type . '_comments'] : '';
$line .= isset($total[$type . '_comments_spam']) ? ' (' . $total[$type . '_comments_spam'] . ')' : '';
$items[] = $line;
}
}
return $items;
}