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 to create an instance of this class. |
public
string
|
|
public
string
|
|
public
string
|
|
public
string
|
|
public
string
|
|
public
array
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
boolean
|
|
public
|
|
protected
|
#
_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
|
|
protected
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(
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 |
protected
|
#
_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( array & $list )
getCollapsedList thinks if a node has no subnodes it is collapsed I don't think so |
public
|
|
public
|
protected
array
|
$_subitems |
|
#
Sub Items for this tree item |
protected
boolean
|
$_collapsed |
|
#
Determinates if this tree item is collapsed |
protected
string
|
$_id |
|
#
ID for this item |
protected
string
|
$_name |
|
#
Name for this item |
protected
string
|
$_collapsed_icon |
|
#
Icon for the collapsed item |
protected
string
|
$_expanded_icon |
|
#
Icon for the expanded item |
protected
string
|
$_lastnode_icon |
|
#
Icon for last node in a branch |
protected
integer
|
$_level |
|
#
Contains the level of this item |
protected
array
|
$_custom |
|
#
Contains custom entries |
protected
array
|
$_parent |
|
#
Contains the parent of this item |