Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made "Count Items" in Category Manager generic
- Loading branch information
Showing
4 changed files
with
127 additions
and
20 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
administrator/components/com_banners/helpers/countitems.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_content | ||
* | ||
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* Contentitem component helper. | ||
* | ||
* @since 1.6 | ||
*/ | ||
class ContentitemsHelper extends JHelperContent | ||
{ | ||
public static $extension = 'com_content'; | ||
|
||
/** | ||
* 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 articles | ||
$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 articles | ||
$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 articles | ||
$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 articles | ||
$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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
administrator/components/com_content/helpers/countitems.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_content | ||
* | ||
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* Contentitem component helper. | ||
* | ||
* @since 1.6 | ||
*/ | ||
class ContentitemsHelper extends JHelperContent | ||
{ | ||
public static $extension = 'com_content'; | ||
|
||
/** | ||
* 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 articles | ||
$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 articles | ||
$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 articles | ||
$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 articles | ||
$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; | ||
} | ||
} |