cvs: pear /Tree Common.php
| From: | Wolfram Kriesing | Date: | Wed, 05 Feb 2003 18:58:10 +0000 |
| Subject: | cvs: pear /Tree Common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8723@lists.php.net to get a copy of this message | ||
cain Wed Feb 5 13:58:10 2003 EDT
Modified files:
/pear/Tree Common.php
Log:
- add second parameter to getChildrenIds, since it will also go deeper some levels, if someone
implements it
Index: pear/Tree/Common.php
diff -u pear/Tree/Common.php:1.17 pear/Tree/Common.php:1.18
--- pear/Tree/Common.php:1.17 Tue Jan 28 14:18:37 2003
+++ pear/Tree/Common.php Wed Feb 5 13:58:10 2003
@@ -16,7 +16,7 @@
// | Authors: Wolfram Kriesing <wolfram@kriesing.de> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.17 2003/01/28 19:18:37 cain Exp $
+// $Id: Common.php,v 1.18 2003/02/05 18:58:10 cain Exp $
require_once('Tree/OptionsDB.php');
@@ -67,18 +67,20 @@
* @access public
* @author Wolfram Kriesing <wolfram@kriesing.de>
* @param integer $id ID of the element that the children shall be retreived
for
+ * @param integer how many levels deep into the tree
* @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 getChildrenIds( $id )
+ function getChildrenIds( $id , $levels=1 )
{
- if( !($children = $this->getChildren( $id )) ) // returns false if no children exist
+ if (!($children = $this->getChildren($id,$levels))) { // returns false if no children
exist
return array(); // return an empty array, if you want to know
if there are children, use hasChildren
+ }
- if( $children && sizeof($children) )
- {
- foreach( $children as $aChild )
+ if ($children && sizeof($children)) {
+ foreach ($children as $aChild) {
$childrenIds[] = $aChild['id'];
+ }
}
return $childrenIds;