View Source

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p>

<p>When Zend_Tree got proposed (April 2006) the Zend team was very much focused on making enough progress on what they considered the absolutely must-have components. </p>

<p>For that reason, Zend_Tree had to be put aside because even if the Zend team doesn't do the proposal writing and coding, each such component requires a significant amount of energy on their side on reviewing, helping with, and polishing up the component and making it ready for release.</p>

<p>I have received an email from Andi Gutmans, where he tells me that we are at the point now where most of what we labeled &quot;must-have&quot; is starting to stabilize. He asked me if I was still interested in &quot;re-proposing&quot; Zend_Tree, so it could be reconsidered.</p>

<p>This proposal is a revised proposal, based on the feedback that I have received throughout the months, from various contributors.</p>

<p>I have decided to put this proposal in the standard proposal template, as fast as possible, so we can gather feedback from the very start.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}


[Andries Seutens|]

0.1 - 28 January 2007: Added first draft for proposal

*About tree's*
A tree is a data structure that emulates a tree structure with a set of linked nodes. Each node has zero or more child nodes, which are below it in the tree. A node that has a child is called the child's parent node. A node has at most one parent.

*The root node*
The topmost node in a tree is called the root node. Being the topmost node, the root node will not have parents. It is the node at which all operations on the tree begin. All other nodes can be reached from it by following edges or links. Every node in a tree can be seen as the root node of the subtree rooted at that node.

*A subtree*
A subtree is a portion of a tree data structure that can be viewed as a complete tree in itself. Any node in a tree T, together with all the nodes below it, comprise a subtree of T. The subtree corresponding to the root node is the entire tree; the subtree corresponding to any other node is called a proper subtree.

*Leaf nodes*
Nodes at the bottom most level of the tree are called leaf nodes. Since they are at the bottom most level, they will not have any children. An internal node or inner node is any node of a tree data structure that has child nodes and is thus not a leaf node.

*Zend_Tree's role*
Zend_Tree will be a data structure which would probably have three most interesting adapters. Db, PHP array, and XML:

* DB because it will help with catalogues and other Db related data.
* PHP array's for sessions and other PHP centric functionality.
* XML for data exchange.

*Other known components*

* [PEAR's Tree|]
* [Horde Framework's Tree|]

*Popular tree data structures:*

* [AA tree|]
* [AVL tree|]
* [Red-black tree|]
* [Splay tree|]
* [Scapegoat tree|]

*Other tree data structures:*

* [B-tree (2-3 tree, B+ tree, B*-tree)|]
* [DSW algorithm|]
* [Dancing tree|]
* [R-tree|]
* [Radix tree|]
* [Skip list|]


*This component will:*

* Allow subclassing;
* Support various import/export formats;
* Support the enumerating all the items;
* Support searching for an item;
* Support adding a new item at a certain position on the tree;
* Support deleting an item;
* Support removing a whole section of a tree;
* Support adding a whole section to a tree;
* Support finding the root for any node;
* Support manipulating hierarchical data;
* Make information easy to search;
* Support exporting to a variety of different formats;
* Know how to serialize itself (could be useful in storing it in Zend_Session);

*This component will not:*

* Create tight connection to Zend_Acl, Zend_Session, or other modules;

* Zend_Exception


* Milestone 1: write proposal / use cases / class skeletons and try to gather feedback from community
* Milestone 2: Class development
* Milestone 3: Unit tests and debugging
* Milestone 4: Documentation

* Zend_Tree
* Zend_Tree_Exception
* Zend_Tree_Adapter_Abstract
* Zend_Tree_Adapter_Db
* Zend_Tree_Adapter_Xml
* Zend_Tree_Adapter_Array

*Working with XML (comparible to simple xml)*

// zend.xml


{card:label=UC 1 : Adding a new item at a certain position on the tree}
$tree = new Zend_Tree(new Zend_Tree_Adapter_Xml('zend.xml'));
$tree->add('/users/user', array(
'fname' => 'Andries',
'name' => 'Seutens'

{card:label=UC 2 : Searching/looping the tree}
$tree = new Zend_Tree(new Zend_Tree_Adapter_Xml('zend.xml'));
foreach ($tree->lookup('/users') as $user) {
echo $user->fname;