function _community_tags_get_tag_counts_by_type_and_vocabulary in Community Tags 7
Same name and namespace in other branches
- 6.2 community_tags.admin.inc \_community_tags_get_tag_counts_by_type_and_vocabulary()
- 6 community_tags.admin.inc \_community_tags_get_tag_counts_by_type_and_vocabulary()
Get tag counts by vocabulary and type.
2 calls to _community_tags_get_tag_counts_by_type_and_vocabulary()
- community_tags_delete_all_form in ./
community_tags.admin.inc - Confirmation form for tag purge. Assumes defaults.
- community_tags_settings in ./
community_tags.admin.inc - Form builder; Builds the settings form.
File
- ./
community_tags.admin.inc, line 393 - community_tags.admin.inc
Code
function _community_tags_get_tag_counts_by_type_and_vocabulary() {
$counts = array();
// stat query for all ctags even for invalid combos - e.g. unassigned content type
$tag_count_result = db_query('SELECT td.vid, n.type, count(*) tag_count, count(distinct ct.nid) node_count, count(distinct ct.tid) term_count, count(distinct ct.uid) user_count
FROM {community_tags} ct
INNER JOIN {taxonomy_term_data} td ON td.tid = ct.tid
INNER JOIN {node} n ON n.nid = ct.nid
GROUP BY td.vid, n.type');
// put tag counts into vocabularies array. If a new type is found for a vocabulary
// then tags are left over from a previous configuration - i.e. content type was assigned for tagging but now is not.
foreach ($tag_count_result as $row) {
$counts[$row->vid][$row->type] = $row;
}
return $counts;
}