diff --git a/administrator/components/com_contact/helpers/contact.php b/administrator/components/com_contact/helpers/contact.php index 823086aa5739a..b292d89ee0bf7 100644 --- a/administrator/components/com_contact/helpers/contact.php +++ b/administrator/components/com_contact/helpers/contact.php @@ -39,4 +39,35 @@ public static function addSubmenu($vName) $vName == 'categories' ); } + + /** + * Adds Count Items for Category Manager. + * + * @param object $query The query object of com_categories + * + * @return object + * + * @since 3.4 + */ + public static function countItems(&$query) + { + // Join articles to categories and count published items + $query->select('COUNT(DISTINCT cp.id) AS count_published'); + $query->join('LEFT', '#__contact_details AS cp ON cp.catid = a.id AND cp.published = 1'); + + // Count unpublished items + $query->select('COUNT(DISTINCT cu.id) AS count_unpublished'); + $query->join('LEFT', '#__contact_details AS cu ON cu.catid = a.id AND cu.published = 0'); + + // Count archived items + $query->select('COUNT(DISTINCT ca.id) AS count_archived'); + $query->join('LEFT', '#__contact_details AS ca ON ca.catid = a.id AND ca.published = 2'); + + // Count trashed items + $query->select('COUNT(DISTINCT ct.id) AS count_trashed'); + $query->join('LEFT', '#__contact_details AS ct ON ct.catid = a.id AND ct.published = -2'); + + return $query; + } + }