|
cvs: pear /Tree Common.php: msg#00678php.cvs.pear
cain Mon Sep 30 10:51:08 2002 EDT Modified files: /pear/Tree Common.php Log: - added getChildrens :-) Index: pear/Tree/Common.php diff -u pear/Tree/Common.php:1.11 pear/Tree/Common.php:1.12 --- pear/Tree/Common.php:1.11 Fri Aug 23 13:18:57 2002 +++ pear/Tree/Common.php Mon Sep 30 10:51:07 2002 @@ -16,7 +16,7 @@ // | Authors: Wolfram Kriesing <wolfram@xxxxxxxxxxx> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.11 2002/08/23 17:18:57 cain Exp $ +// $Id: Common.php,v 1.12 2002/09/30 14:51:07 cain Exp $ require_once('Tree/OptionsDB.php'); @@ -85,6 +85,72 @@ } /** + * gets all the children and grand children + * i know there is no such word as 'childrens' but it makes sense here :-) + * + * @version 2002/09/30 + * @access public + * @author Wolfram Kriesing <wolfram@xxxxxxxxxxx> + * @param integer $id ID of the element that the children shall be retreived for + * @return mixed an array of all the children of the element with id=$id, + * or false if there are no children + */ + function getChildrens( $id ) + { + $retChildrens = false; + if( $childrens = $this->hasChildren( $id ) ) + { + $retChildrens = $this->_getChildrens( $id ); + } + return $retChildrens; + } + + /** + * this method gets all the children recursively + * + * @see getChildrens() + * @version 2002/09/30 + * @access public + * @author Wolfram Kriesing <wolfram@xxxxxxxxxxx> + * @param integer $id ID of the element that the children shall be retreived for + * @return mixed an array of all the ids of the children of the element with id=$id, + * or false if there are no children + */ + function &_getChildrens( $id ) + { + $retChildrens = array(); + if( $children = $this->getChildren( $id ) ) + { + foreach( $children as $key=>$aChild ) + { + $retChildrens[] = &$children[$key]; + //$retChildrens = array_merge($retChildrens,$this->_getChildrens( $aChild['id'] )); + } + } + return $retChildrens; + } + + /** + * gets all the children-ids and grand children-ids + * + * @version 2002/09/30 + * @access public + * @author Wolfram Kriesing <wolfram@xxxxxxxxxxx> + * @param integer $id ID of the element that the children shall be retreived for + * @return mixed an array of all the ids of the children of the element with id=$id, + * or false if there are no children + */ + function getChildrensIds( $id ) + { + if( $childrens = $this->getChildrens($id) ) + { + $childrensIds = array(); + foreach( $childrens as $aNode ) + $childrensIds[] = $aNode['id']; + } + return $childrensIds; + } + /** * get the id of the parent for the given element * * @version 2002/01/18 @@ -385,4 +451,4 @@ } } -?> \ No newline at end of file +?> -- PEAR CVS Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | cvs: pearweb /weeklynews 20020929.pl.html: 00678, Robert Janeczek |
|---|---|
| Next by Date: | RE: cvs: pear /Tree Common.php: 00678, LIMBOURG Arnaud |
| Previous by Thread: | cvs: pearweb /weeklynews 20020929.pl.htmli: 00678, Robert Janeczek |
| Next by Thread: | RE: cvs: pear /Tree Common.php: 00678, LIMBOURG Arnaud |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |