mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-19 13:25:36 -04:00
Change the children methods on Item_Core and ORM_MPTT in order to
specify a type parameter, so tht we can filter the children based on type (i.e. album, photo, etc). In addition, expose the sort order, so that we can specify the order we want to return the children.
This commit is contained in:
@@ -146,11 +146,15 @@ class ORM_MPTT_Core extends ORM {
|
||||
* @chainable
|
||||
* @param integer SQL limit
|
||||
* @param integer SQL offset
|
||||
* @param string type to return
|
||||
* @param array orderby
|
||||
* @return array ORM
|
||||
*/
|
||||
function children($limit=null, $offset=0, $orderby=null) {
|
||||
function children($limit=null, $offset=0, $type=null, $orderby=null) {
|
||||
$this->where("parent_id", $this->id);
|
||||
if ($type) {
|
||||
$this->where("type", $type);
|
||||
}
|
||||
if (empty($orderby)) {
|
||||
$this->orderby("id", "ASC");
|
||||
} else {
|
||||
@@ -163,16 +167,18 @@ class ORM_MPTT_Core extends ORM {
|
||||
* Return all of the children of this node, ordered by id.
|
||||
*
|
||||
* @chainable
|
||||
* @param integer SQL limit
|
||||
* @param integer SQL offset
|
||||
* @param string type to return
|
||||
* @return array ORM
|
||||
*/
|
||||
function children_count() {
|
||||
function children_count($type=null) {
|
||||
if ($type) {
|
||||
$this->where("type", $type);
|
||||
}
|
||||
return $this->where("parent_id", $this->id)->count_all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the children of the specified type, ordered by id.
|
||||
* Return all of the decendents of the specified type, ordered by id.
|
||||
*
|
||||
* @param integer SQL limit
|
||||
* @param integer SQL offset
|
||||
|
||||
Reference in New Issue
Block a user