Class cms_tree

Description

A Simple PHP Tree class that allows storing associative data along with each node.

  • author: Robert Campbell
  • copyright: Copyright (c) 2010, Robert Campbell <calguy1000@cmsmadesimple.org>
  • since: 1.9

Located in /class.cms_tree.php (line 49)


	
			
Direct descendents
Class Description
cms_content_tree A tree class that allows backward compatibility (somewhat) to the old Tree class used in CMSMS versions prior to 1.9, and provides content retrieval abilities, with interface into the content cache.
Method Summary
cms_tree __construct ([string $key = ''], [mixed $value = ''])
void add_node (cms_tree &$node)
integer count_children ()
integer count_siblings ()
cms_tree find_by_tag (string $tag_name, mixed $value, [ $case_insensitive = false])
integer get_level ()
mixed &get_tag (string $key)
boolean has_children ()
boolean remove ()
boolean remove_node (cms_tree &$node, [boolean $search_children = false])
void set_tag (string $key, mixed $value)
Methods
Constructor __construct (line 79)

Construct a new tree, or node of a tree.

  • access: public
cms_tree __construct ([string $key = ''], [mixed $value = ''])
  • string $key: An optional key for a tag
  • mixed $value: An optional value for the tag.
add_node (line 261)

Add the specified node as a child to this node.

  • access: public
void add_node (cms_tree &$node)
count_children (line 282)

Count the number of direct children to this node.

  • access: public
integer count_children ()
count_siblings (line 297)

Count the number of siblings that this node has.

  • access: public
integer count_siblings ()
find_by_tag (line 105)

Find a tree node given a specfied tag and value.

  • return: or null on failure.
  • access: public
cms_tree find_by_tag (string $tag_name, mixed $value, [ $case_insensitive = false])
  • string $tag_name: The tag name to search for
  • mixed $value: The tag value to search for
  • $case_insensitive
getParent (line 250)

Get a reference to the parent node.

  • return: Reference to the parent node, or null.
  • access: public
cms_tree &getParent ()
get_children (line 332)

Return the children of this node.

  • return: array of cms_tree objects, or null if there are no children.
  • access: public
an &get_children ()
get_level (line 314)

Find the depth of the current node.

This method counts all of the parents in the tree until there are no more parents.

  • access: public
integer get_level ()
get_tag (line 180)

Retrieve a tag for this node.

  • return: The tag value, or null
  • access: public
mixed &get_tag (string $key)
  • string $key: The tag name
has_children (line 148)

Test if this node has children.

  • access: public
boolean has_children ()
remove (line 237)

Remove this node

This is a convenience method that calls remove_node on the current object.

  • access: public
boolean remove ()
remove_node (line 203)

Remove the specified node from the tree.

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.

  • access: protected
boolean remove_node (cms_tree &$node, [boolean $search_children = false])
  • cms_tree &$node: Reference to the node to be removed.
  • boolean $search_children: Wether to recursively search children.
set_tag (line 164)

Set a tag value into this node

  • access: public
void set_tag (string $key, mixed $value)
  • string $key: Tag name
  • mixed $value: Tag value

Documentation generated on Sun, 12 Aug 2012 08:38:27 -0600 by phpDocumentor 1.3.2