cvs: pear /Tree Memory.php
| From: | Wolfram Kriesing | Date: | Sat, 18 Jan 2003 15:38:04 +0000 |
| Subject: | cvs: pear /Tree Memory.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8378@lists.php.net to get a copy of this message | ||
cain Sat Jan 18 10:38:04 2003 EDT
Modified files:
/pear/Tree Memory.php
Log:
- prevent some E_ALL warnings
- enhance getChildren method
Index: pear/Tree/Memory.php
diff -u pear/Tree/Memory.php:1.16 pear/Tree/Memory.php:1.17
--- pear/Tree/Memory.php:1.16 Sat Jan 4 06:56:27 2003
+++ pear/Tree/Memory.php Sat Jan 18 10:38:04 2003
@@ -16,7 +16,7 @@
// | Authors: Wolfram Kriesing <wolfram@kriesing.de> |
// +----------------------------------------------------------------------+
//
-// $Id: Memory.php,v 1.16 2003/01/04 11:56:27 mj Exp $
+// $Id: Memory.php,v 1.17 2003/01/18 15:38:04 cain Exp $
require_once('Tree/Common.php');
require_once('Tree/Error.php');
@@ -163,7 +163,8 @@
$this->dataSourceClass =& new $className( $dsn , $options );
// copy the options to be able to get them via getOption(s)
//FIXXME this is not really cool, maybe overwrite the *Option* methods!!!
- $this->options = $this->dataSourceClass->options;
+ if( isset($this->dataSourceClass->options) )
+ $this->options = $this->dataSourceClass->options;
} // end of function
@@ -1194,19 +1195,34 @@
} // end of function
/**
- * returns if the given element has any children
+ * returns the children of the given ids
*
* @version 2001/12/17
* @access public
* @author Wolfram Kriesing <wolfram@kriesing.de>
* @param integer $id the id of the node to check for children
+ * @param integer the children of how many levels shall be returned
* @return boolean true if the node has children
*/
- function getChildren( $id=0 )
- {
- if( $this->hasChildren( $id ) )
- return $this->data[$id]['children'];
- return array();
+ function getChildren( $ids , $levels=1 )
+ {
+//FIXXME $levels to be implemented
+ $ret = array();
+ if( is_array($ids) )
+ {
+ foreach( $ids as $aId )
+ {
+ if( $this->hasChildren( $aId ) )
+ $ret[$aId] = $this->data[$aId]['children'];
+ }
+
+ }
+ else
+ {
+ if( $this->hasChildren( $ids ) )
+ $ret = $this->data[$ids]['children'];
+ }
+ return $ret;
} // end of function
/**