Class TreeItem
Class TreeItem Class to create tree-based items
The treeitem class allows you to logically store tree-based structures.
Example:
Let's have a tree with 3 nodes. It's important that we always have a "root" key.
$root = new TreeItem("root", 1); $item1 = new TreeItem("node1",2); $item2 = new TreeItem("node2",3); $item3 = new TreeItem("node3",4);
$root->addItem($item1); $root->addItem($item2); $root->addItem($item3);
This represents the tree we described above.
If you know the ID of the item you want to add to, there's no need to have a specific item handy, but rather you can use the "addItemToID" function.
Copyright: four for business AG <www.4fb.de>
License: http://www.contenido.org/license/LIZENZ.txt
Author: Timo Hummel
Located at classes/class.treeitem.php
public
|
#
__construct( string $name = "", string $id = "", boolean $collapsed = false )
Constructor Function Creates a new, independant tree item. |
public
|
|
public
|
#
addItemToID( object $item, string $id )
Adds a new subitem to a specific item with an ID. Traverses all subitems to find the correct item. |
public
object
&
|
#
getItemByID( string $id )
Retrieves a specific item by its ID. Note that this function traverses all subitems to find the correct item. |
public
|
|
public
boolean
|
|
public
boolean
|
#
markExpanded( string $id )
Marks an item as expanded. Traverses all subitems to find the ID. Note that only the item with $id is expanded, but not its childs. |
public
|
|
public
|
|
public
|
#
markCollapsed( string $id )
Marks an item as collpased. Traverses all subitems to find the ID. Note that only the item with $id is collapsed, but not its childs. |
public
|
|
public
|
#
getFlatTree( unknown_type $item, unknown_type & $flat_tree )
Starts iterating at root node and flattens the tree into an array |
public
boolean
|
|
public
|
#
getTreeParentNodes( unknown_type & $parentNodes, unknown_type $id )
Returns a list of the id of all parent nodes of the given node |
public
|
#
getParentNodes( unknown_type & $parentNodes, unknown_type $stop_id )
Returns a list of the id of all parent nodes of the given node Not using the nodes of hierarchical tree, but flat tree !! |
public
|
#
getRealCollapsedList( unknown_type & $list )
getCollapsedList thinks if a node has no subnodes it is collapsed I don't think so |
public
|
|
public
|
public
array
|
$subitems |
|
#
Sub Items for this tree item |
public
boolean
|
$collapsed |
|
#
Determinates if this tree item is collapsed |
public
string
|
$id |
|
#
ID for this item |
public
string
|
$name |
|
#
Name for this item |
public
string
|
$collapsed_icon |
|
#
Icon for the collapsed item |
public
string
|
$expanded_icon |
|
#
Icon for the expanded item |
public
string
|
$lastnode_icon |
|
#
Icon for last node in a branch |
public
integer
|
$level |
|
#
Contains the level of this item |
public
array
|
$custom |
|
#
Contains custom entries |
public
array
|
$parent |
|
#
Contains the parent of this item |