A Simple PHP Tree class that allows storing associative data along with each node.
package |
CMS |
---|---|
author |
Robert Campbell |
copyright |
Copyright (c) 2010, Robert Campbell calguy1000@cmsmadesimple.org |
since | 1.9 |
__construct(string $key = '', mixed $value = '')
string
$keyAn optional key for a tag
mixed
$valueAn optional value for the tag.
find_by_tag(string $tag_name, mixed $value, boolean $case_insensitive = FALSE) : \cms_tree
string
$tag_nameThe tag name to search for
mixed
$valueThe tag value to search for
boolean
$case_insensitiveWether the value should be treated as case insensitive.
or null on failure.
has_children() : boolean
boolean
set_tag(string $key, mixed $value)
string
$keyTag name
mixed
$valueTag value
get_tag(string $key) : mixed
string
$keyThe tag name
mixed
The tag value, or null
remove_node(\cms_tree &$node, boolean $search_children = false) : boolean
Search through the children of this node (and optionally recursively through the tree) for the specified node. If found, remove it.
Use this method with caution, as it is very easy to break your tree, corrupt memory and have tree nodes hanging out there with no parents.
\cms_tree
$nodeReference to the node to be removed.
boolean
$search_childrenWether to recursively search children.
boolean
remove() : boolean
This is a convenience method that calls remove_node on the current object.
boolean
get_parent() : \cms_tree
getParent() : \cms_tree
add_node(\cms_tree &$node)
count_children() : integer
integer
count_siblings() : integer
integer
count_nodes() : integer
integer
get_level() : integer
This method counts all of the parents in the tree until there are no more parents.
integer
get_children() : \an
\an
array of cms_tree objects, or null if there are no children.