Class PU_tree

Description

A class to deal with tree-structured data (such as groups)

Usage: $tree = new PU_tree $tree->add(1, 0); // add a root node $tree->add(2, 1, 'leaf'); // add a named leaf to the root node $tree->climb(); // study the tree YOU HAVE TO DO THAT BEFORE ACTUALLY USING THE TREE

  • author: greg
  • version: 1.0
  • date: 20100514

Located in /PHPDS_utils.inc.php (line 586)


	
			
Variable Summary
array $ascendants
array $descendants
array $elements
Method Summary
this add (mixed $leaf, mixed $node, [mixed $label = ''])
array ascendants ($node $node, [$as_array $as_array = false])
this climb ([unknown_type $branch = 0])
array descendants ($node $node, [$as_array $as_array = false])
array nodes ([ $filter = null])
Variables
array $ascendants = array() (line 599)

Associative array: for each node (by ref), what are the nodes upper in the tree

  • access: protected
array $descendants = array() (line 605)

Associative array: for each node (by ref), what are the nodes lower in the tree

  • access: protected
array $elements = array(0) (line 593)

Associative array of the nodes (element ref => element, usually a label)

  • access: protected
Methods
add (line 615)

Add an element to the tree. When all elements are added, you MUST call climb()

  • access: public
this add (mixed $leaf, mixed $node, [mixed $label = ''])
  • mixed $leaf: the new element ref
  • mixed $node: the element onto this new element is stuck
  • mixed $label: an optional label to display
ascendants (line 649)

Returns the ascendants of the given node, either as array or as a string for sql

  • return: or string
  • access: public
array ascendants ($node $node, [$as_array $as_array = false])
  • $node $node: the node which ascendants are asked
  • $as_array $as_array: boolean, do you want an array (true) or a string (false)
climb (line 630)

Climb the tree in order to fill the descendant array.

Don't call it with parameter

  • access: public
this climb ([unknown_type $branch = 0])
  • unknown_type $branch
descendants (line 664)

Returns the descendants of the given node, either as array or as a string for sql

  • return: or string
  • access: public
array descendants ($node $node, [$as_array $as_array = false])
  • $node $node: the node which ascendants are asked
  • $as_array $as_array: boolean, do you want an array (true) or a string (false)
nodes (line 678)

Returns an array of nodes, either the whole tree, or only the nodes listed in the filter

  • access: public
array nodes ([ $filter = null])
  • array $filter

Documentation generated on Tue, 09 Aug 2011 09:05:32 +0200 by phpDocumentor 1.4.3