diff --git a/administrator/components/com_banners/helpers/banners.php b/administrator/components/com_banners/helpers/banners.php index 3cc32044ec4da..563ebac6cc6dd 100644 --- a/administrator/components/com_banners/helpers/banners.php +++ b/administrator/components/com_banners/helpers/banners.php @@ -185,4 +185,36 @@ public static function getClientOptions() return $options; } + + /** + * 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', '#__banners 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', '#__banners 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', '#__banners 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', '#__banners AS ct ON ct.catid = a.id AND ct.state = -2'); + + return $query; + } + } diff --git a/administrator/components/com_banners/models/banners.php b/administrator/components/com_banners/models/banners.php index 3a504037c0ad5..4eed2c432a1c6 100644 --- a/administrator/components/com_banners/models/banners.php +++ b/administrator/components/com_banners/models/banners.php @@ -124,7 +124,7 @@ protected function getListQuery() ->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid'); // Filter by published state - $published = $this->getState('filter.state'); + $published = $this->getState('filter.published'); if (is_numeric($published)) { @@ -210,7 +210,7 @@ protected function getStoreId($id = '') // Compile the store id. $id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.access'); - $id .= ':' . $this->getState('filter.state'); + $id .= ':' . $this->getState('filter.published'); $id .= ':' . $this->getState('filter.category_id'); $id .= ':' . $this->getState('filter.language'); @@ -251,8 +251,8 @@ protected function populateState($ordering = null, $direction = null) $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); - $state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string'); - $this->setState('filter.state', $state); + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '', 'string'); + $this->setState('filter.published', $published); $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', ''); $this->setState('filter.category_id', $categoryId); diff --git a/administrator/components/com_banners/models/forms/filter_banners.xml b/administrator/components/com_banners/models/forms/filter_banners.xml index a50dc10142c81..956e144a7e073 100644 --- a/administrator/components/com_banners/models/forms/filter_banners.xml +++ b/administrator/components/com_banners/models/forms/filter_banners.xml @@ -9,7 +9,7 @@ class="js-stools-search-string" />