function total_control_get_content_overview in Total Control Admin Dashboard 7.2
Same name and namespace in other branches
- 6.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 293 - Helper functions for total control.
Code
function total_control_get_content_overview($conf = array()) {
$items = array();
$types = node_type_get_types();
$comments_exist = module_exists('comment');
foreach ($types as $type => $object) {
// Compare against type option on pane config.
if (!array_key_exists($type, $conf['types']) || isset($conf['types']) && $conf['types'][$type] == $type) {
$type_count = db_query("SELECT count(*) FROM {node} WHERE type = :type and status = 1", array(
':type' => $type,
))
->fetchField();
$content_data[$type] = format_plural($type_count, '1 ' . $object->name . ' item', '@count ' . $object->name . ' items');
// Check if comments module is enabled.
if ($comments_exist) {
// Compare against comment options on pane config.
if (array_key_exists($type, $conf['comments']) && $conf['comments'][$type] === $type) {
$comment_count = db_query("SELECT count(DISTINCT cid) FROM {comment} c INNER JOIN {node} n ON c.nid = n.nid WHERE n.type = :type and c.status = 1 AND n.status = 1", array(
':type' => $type,
))
->fetchField();
$content_data[$type . '_comments'] = format_plural($comment_count, '1 comment', '@count comments');
// Compare against spam option checkbox on pane config.
if (isset($conf['spam']) && $conf['spam'] == 1) {
$spam_count = db_query("SELECT count(DISTINCT c.cid) FROM {comment} c INNER JOIN {node} n ON c.nid = n.nid WHERE n.type = :type and c.status = 0 AND n.status = 1", array(
':type' => $type,
))
->fetchField();
$content_data[$type . '_comments_spam'] = format_plural($spam_count, '1 spam', '@count spam');
}
}
}
$line = $content_data[$type];
$line .= isset($content_data[$type . '_comments']) ? ' with ' . $content_data[$type . '_comments'] : '';
$line .= isset($content_data[$type . '_comments_spam']) ? ' (' . $content_data[$type . '_comments_spam'] . ')' : '';
$items[] = $line;
}
}
return $items;
}