Méthode |
Description |
|
__construct ( string $table, string $idField, string $parentField, string $sortField ) |
Constructor. Set the database table name and necessary field names |
|
generateTreeData ( &$arr, integer $id, integer $level, &$n ) |
Generate the tree data. A single call to this generates the n-values for
1 node in the tree. This function assigns the passed in n value as the
node's nleft value. It then processes all the node's children (which
in turn recursively processes that node's children and so on), and when
it is finally done, it takes the update n-value and assigns it as its
nright value. Because it is passed as a reference, the subsequent changes
in subrequests are held over to when control is returned so the nright
can be assigned. |
|
getChildren ( integer $id, boolean $includeSelf = false ) : array |
Fetch the children of a node, or if no node is specified, fetch the
top level items. |
|
getDescendants ( integer $id, boolean $includeSelf = false, boolean $childrenOnly = false, $unique_id_list = false ) : array |
Fetch the descendants of a node, or if no node is specified, fetch the
entire tree. Optionally, only return child data instead of all descendant
data. |
|
getFields ( ) : array |
A utility function to return an array of the fields
that need to be selected in SQL select queries |
|
getImmediateFamily ( integer $id ) : array |
Fetch the immediately family of a node. More specifically, fetch a node's
parent, siblings and children. If the node isn't valid, fetch the first
level of nodes from the tree. |
|
getNode ( integer $id ) : object |
Fetch the node data for the node identified by $id |
|
getPath ( integer $id, boolean $includeSelf = false ) : array |
Fetch the path to a node. If an invalid node is passed, an empty array is returned. |
|
getTreeWithChildren ( ) : array |
Fetch the tree data, nesting within each node references to the node's children |
|
isChildOf ( integer $child_id, integer $parent_id ) : boolean |
Check if one node is a child of another node. If either node is not
found, then false is returned. |
|
isDescendantOf ( integer $descendant_id, integer $ancestor_id ) : boolean |
Check if one node descends from another node. If either node is not
found, then false is returned. |
|
numChildren ( integer $id ) : integer |
Find the number of children a node has |
|
numDescendants ( integer $id ) : integer |
Find the number of descendants a node has |
|
rebuild ( ) |
Rebuilds the tree data and saves it to the database |
|