public __construct ($file)
Constructor method. Decodes the tree from the specified file in JSON format.
public path ($id, $titles = false, $tree = false)
Find the path to a specific node in the tree, including the node itself.
If titles is true, it will return an associative array with the keys being
object IDs and the values being their data attribute (usually, the title or
$titles is false, it will return an array of IDs only.
public add ($obj, $parent = false, $data = false)
Add an object to the tree under the specified parent node.
$id can be an ID or a node object. If
$data is passed, it
it will set the
data property to that instead of the value
$obj, which would typically be used as follows:
$mytree->add ('id-value', 'parent-id', 'Title here');
public remove ($id, $recursive = true)
Remove an object from the tree. Removes all children as well unless you set $recursive to false.
public remove_path ($path)
Remove a specific path from the tree recursively. Used primarily by move().
public move ($id, $ref, $pos = 'inside')
Move an object to the specified location ($ref) in the tree. $pos can be one of: after, before, inside (default is inside).
Handles managing a tree of objects as a JSON file. Items in the tree have the following structure:
Item that have children will have an additional
childrenproperty that is an array of other items.