3 * @version $Id:tree.php 6961 2007-03-15 16:06:53Z tcp $
4 * @package Joomla.Framework
6 * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
7 * @license GNU/GPL, see LICENSE.php
8 * Joomla! is free software. This version may have been modified pursuant to the
9 * GNU General Public License, and as distributed it includes or is derivative
10 * of works licensed under the GNU General Public License or other free or open
11 * source software licenses. See COPYRIGHT.php for copyright notices and
15 // Check to ensure this file is within the rest of the framework
16 //defined('JPATH_BASE') or die();
21 * @package Joomla.Framework
25 class JTree extends JObject
33 * Current working node
37 function __construct()
39 $this->_root = new JNode('ROOT');
40 $this->_current = & $this->_root;
43 function addChild(&$node, $setCurrent = false)
45 $this->_current->addChild($node);
47 $this->_current =& $node;
53 $this->_current =& $this->_current->getParent();
58 $this->_current =& $this->_root;
65 * @package Joomla.Framework
69 class JNode extends JObject
79 var $_children = array();
81 function __construct()
86 function addChild( &$node )
88 $node->setParent($this);
89 $this->_children[] = & $node;
94 return $this->_parent;
97 function setParent( &$node )
99 $this->_parent = & $node;
102 function hasChildren()
104 return count($this->_children);
107 function &getChildren()
109 return $this->_children;