Tree
class Tree
Build and manipulate a tree representing hierarchical relationships between objects.
Essentially this is a category tree, although collections (category analogues) are fully-fledged content objects in their own right. Pass in an array of collection objects; you can choose to pass in all collection objects or you can pass in a branch, in which case the tree will just consist of descendants of the root node.
Methods
Constructor.
Get a category tree.
Returns an array of all child objects of a parental object specified by its ID.
Returns an array of all parent objects.
returns an object from the category tree specified by its id.
Returns an array of all the first child objects of a parental object specified by its id.
Make a select box of parent collections from the tree.
Make select box options from the tree.
Details
at line 90
__construct(array $objectArr, string $myId, string $parentId, string $rootId = null)
Constructor.
at line 127
array
getTree()
Get a category tree.
at line 139
array
getAllChild(int $key, array $ret = [])
Returns an array of all child objects of a parental object specified by its ID.
at line 168
array
getAllParent(int $key, array $ret = [], int $uplevel = 1)
Returns an array of all parent objects.
The key of returned array represents how many levels up from the specified object.
at line 191
object
getByKey(int $key)
returns an object from the category tree specified by its id.
at line 202
array
getFirstChild(int $key)
Returns an array of all the first child objects of a parental object specified by its id.
at line 224
array
makeParentSelectBox(int $selected = 0, int $key = 0)
Make a select box of parent collections from the tree.
at line 248
array
makeSelBox(string $name, string $fieldName, string $prefix = '-- ', int $selected = 0, bool $addEmptyOption = false, int $key = 0)
Make select box options from the tree.
Returns an indented array of options that can be used to build a HTML select box, indented according to the relative hierarchy.