diff --git a/administrator/components/com_categories/models/categories.php b/administrator/components/com_categories/models/categories.php index 3abca0d1ff985..92e62b26728e2 100644 --- a/administrator/components/com_categories/models/categories.php +++ b/administrator/components/com_categories/models/categories.php @@ -147,6 +147,10 @@ protected function getListQuery() $query = $db->getQuery(true); $user = JFactory::getUser(); + // Determine for which component the category manager retrieves its categories (for item count) + $jinput = JFactory::getApplication()->input; + $countitemhelper = JPATH_ADMINISTRATOR . "/components/" . $jinput->get('extension') . '/helpers/countitems.php'; + // Select the required fields from the table. $query->select( $this->getState( @@ -276,6 +280,17 @@ protected function getListQuery() $query->order($db->escape($listOrdering) . ' ' . $listDirn); } + // Group by on Categories for JOIN with component tables to count items + $query->group('a.id'); + + // Load Helper file of the component for which com_categories displays the categories + $classname = ucfirst(substr($extension, 4)) . 'Helper'; + if (class_exists($classname) && method_exists($classname, 'countItems')) + { + // Get the SQL to extend the com_category $query object with item count (published, unpublished, trashed) + $classname::countItems($query); + } + return $query; } diff --git a/administrator/components/com_categories/views/categories/tmpl/default.php b/administrator/components/com_categories/views/categories/tmpl/default.php index c5a3bde2b2d56..0693c14ea8948 100644 --- a/administrator/components/com_categories/views/categories/tmpl/default.php +++ b/administrator/components/com_categories/views/categories/tmpl/default.php @@ -24,6 +24,8 @@ $listDirn = $this->escape($this->state->get('list.direction')); $ordering = ($listOrder == 'a.lft'); $saveOrder = ($listOrder == 'a.lft' && strtolower($listDirn) == 'asc'); +$component = $app->input->get('extension'); +$columns = 7; if ($saveOrder) { @@ -61,10 +63,35 @@ + items[0]) && property_exists($this->items[0], 'count_published')) : + $columns++; ?> + + + + + items[0]) && property_exists($this->items[0], 'count_unpublished')) : + $columns++; ?> + + + + + items[0]) && property_exists($this->items[0], 'count_archived')) : + $columns++; ?> + + + + + items[0]) && property_exists($this->items[0], 'count_trashed')) : + $columns++; ?> + + + + - assoc) : ?> + assoc) : + $columns++; ?> @@ -79,7 +106,7 @@ - + pagination->getListFooter(); ?> @@ -164,6 +191,31 @@ + items[0]) && property_exists($this->items[0], 'count_published')) : ?> + + " title="" href="id . '&filter[published]=1' . '&filter[level]=' . (int) $item->level);?>"> + count_published; ?> + + + items[0]) && property_exists($this->items[0], 'count_unpublished')) : ?> + + " title="" href="id . '&filter[published]=0' . '&filter[level]=' . (int) $item->level);?>"> + count_unpublished; ?> + + + items[0]) && property_exists($this->items[0], 'count_archived')) : ?> + + " title="" href="id . '&filter[published]=2' . '&filter[level]=' . (int) $item->level);?>"> + count_archived; ?> + + + items[0]) && property_exists($this->items[0], 'count_trashed')) : ?> + + " title="" href="id . '&filter[published]=-2' . '&filter[level]=' . (int) $item->level);?>"> + count_trashed; ?> + + + escape($item->access_level); ?> diff --git a/administrator/components/com_content/helpers/content.php b/administrator/components/com_content/helpers/content.php index 5408f1931bdc8..9f7e62e1a9b6f 100644 --- a/administrator/components/com_content/helpers/content.php +++ b/administrator/components/com_content/helpers/content.php @@ -60,4 +60,35 @@ public static function filterText($text) return JComponentHelper::filterText($text); } + + /** + * 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', '#__content AS cp ON cp.catid = a.id AND cp.state = 1'); + + // Count unpublished items + $query->select('COUNT(DISTINCT cu.id) AS count_unpublished'); + $query->join('LEFT', '#__content AS cu ON cu.catid = a.id AND cu.state = 0'); + + // Count archived items + $query->select('COUNT(DISTINCT ca.id) AS count_archived'); + $query->join('LEFT', '#__content AS ca ON ca.catid = a.id AND ca.state = 2'); + + // Count trashed items + $query->select('COUNT(DISTINCT ct.id) AS count_trashed'); + $query->join('LEFT', '#__content AS ct ON ct.catid = a.id AND ct.state = -2'); + + return $query; + } + } diff --git a/administrator/language/en-GB/en-GB.com_categories.ini b/administrator/language/en-GB/en-GB.com_categories.ini index 180044f981f91..27690d3296bf4 100644 --- a/administrator/language/en-GB/en-GB.com_categories.ini +++ b/administrator/language/en-GB/en-GB.com_categories.ini @@ -42,7 +42,6 @@ COM_CATEGORIES_FIELDSET_PUBLISHING="Publishing" COM_CATEGORIES_FIELDSET_RULES="Permissions" COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS="%d items are assigned to this category's subcategories." COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS_1="%d item is assigned to one of this category's subcategories." -COM_CATEGORY_HEADING_ASSOCIATION="Association" COM_CATEGORIES_ITEM_ASSOCIATIONS_FIELDSET_LABEL="Category Item Associations" COM_CATEGORIES_ITEM_ASSOCIATIONS_FIELDSET_DESC="Multilingual only! This choice will only display if the Language Filter parameter 'Item Associations' is set to 'Yes'. Choose a category item for the target language. This association will let the Language Switcher module redirect to the associated category item in another language. If used, make sure to display the Language switcher module on the concerned pages. A category item set to language 'All' can't be associated." COM_CATEGORIES_ITEMS_SEARCH_FILTER="Search" @@ -70,6 +69,11 @@ COM_CATEGORIES_SELECT_A_CATEGORY="Select a Category" COM_CATEGORIES_TIP_ASSOCIATION="Associated categories" COM_CATEGORIES_TIP_ASSOCIATED_LANGUAGE="%s %s" COM_CATEGORIES_XML_DESCRIPTION="This component manages categories." +COM_CATEGORY_COUNT_ARCHIVED_ITEMS="Archived items" +COM_CATEGORY_COUNT_PUBLISHED_ITEMS="Published items" +COM_CATEGORY_COUNT_TRASHED_ITEMS="Trashed items" +COM_CATEGORY_COUNT_UNPUBLISHED_ITEMS="Unpublished items" +COM_CATEGORY_HEADING_ASSOCIATION="Association" JGLOBAL_NO_ITEM_SELECTED="No categories selected." JLIB_HTML_ACCESS_SUMMARY_DESC="Shown below is an overview of the permission settings for this category. Click the tabs above to customise these settings by action." JLIB_RULES_SETTING_NOTES_ITEM="1. If you change the setting, it will apply to this and all child categories. Note that:
Inherited means that the permissions from the parent category will be used if there is a parent category or those from the component if there is no parent category.
Denied means that no matter what the parent category setting is, the group being edited can't take this action within this category.
Allowed means that the group being edited will be able to take this action within this category (but if this is in conflict with the parent category setting or the component setting it will have no impact; a conflict will be indicated by Not Allowed (Locked) under Calculated Settings).
2. If you select a new setting, click Save to refresh the calculated settings." diff --git a/administrator/templates/hathor/html/com_categories/categories/default.php b/administrator/templates/hathor/html/com_categories/categories/default.php index 0c540a8f6b2c5..c7e4744a00d93 100644 --- a/administrator/templates/hathor/html/com_categories/categories/default.php +++ b/administrator/templates/hathor/html/com_categories/categories/default.php @@ -24,6 +24,8 @@ $ordering = ($listOrder == 'a.lft'); $saveOrder = ($listOrder == 'a.lft' && $listDirn == 'asc'); $assoc = JLanguageAssociations::isEnabled(); +$jinput = JFactory::getApplication()->input; +$component = $jinput->get('extension'); ?>
@@ -98,6 +100,26 @@ items, 'filesave.png', 'categories.saveorder'); ?> + items[0]) && property_exists($this->items[0], count_published)) : ?> + + + + + items[0]) && property_exists($this->items[0], count_unpublished)) : ?> + + + + + items[0]) && property_exists($this->items[0], count_archived)) : ?> + + + + + items[0]) && property_exists($this->items[0], count_trashed)) : ?> + + + + @@ -162,6 +184,30 @@ + items[0]) && property_exists($this->items[0], count_published)) : ?> + + + count_published; ?> + + + items[0]) && property_exists($this->items[0], count_unpublished)) : ?> + + + count_unpublished; ?> + + + items[0]) && property_exists($this->items[0], count_archived)) : ?> + + + count_archived; ?> + + + items[0]) && property_exists($this->items[0], count_trashed)) : ?> + + + count_trashed; ?> + + escape($item->access_level); ?>