SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class Treenode

Represents a node in the tree

Variables

NameVisibilityDescription
$data 
$filtered_children 
$parent 
$real_children 

Functions

NameVisibilityDescription
__constructpublicCreates a node, with the specified data
__getpublicGeneric field getter for unknown properties - used for TreeNode->children
__setpublicGeneric field getter for unknown properties - used for TreeNode->children
filterChildrenpublicFilter the children of this node, removing any children which don't match the specified TreenodeMatcher.
findAllNodespublicFinds all nodes which match the specified matcher.
findAncestorspublicFinds all ancestors of a specific node, including the node, not including the root node of the tree
findNodepublicFinds a node by looking at this node
findNodeValuepublicFinds a node by looking at this node
getAllChildrenpublicReturns an array of all children nodes, including sub-children
getChildrenpublic 
isOrphanpublicIs this node an orphan?
isRootpublicReturns true if this node is the root node
loadTreepublic (static)Loads a flat table into a tree structure.
offsetExistspublicArrayAccess function for checking if a specified key exists
offsetGetpublicArrayAccess function for getting a value by its key
offsetSetpublicArrayAccess function for setting a value by its key
offsetUnsetpublicArrayAccess function for unsetting a value
removeFilterpublicRemoves the currently active filter

public __construct

void $Treenode->__construct ( [ array $data ] );

Creates a node, with the specified data

public __get

unknown $Treenode->__get ( string &$field );

Generic field getter for unknown properties - used for TreeNode->children

Be aware that data gotten through this getter is BY REFERENCE
For by-value data retrival, use the array-access functions.

public __set

void $Treenode->__set ( string $field , mixed $value );

Generic field getter for unknown properties - used for TreeNode->children

public filterChildren

void $Treenode->filterChildren ( TreenodeMatcher $matcher );

Filter the children of this node, removing any children which don't match the specified TreenodeMatcher.
The nodes are not actually removed, matching nodes are just added to a filtered children list
Which is returned instead of the original children list.

public findAllNodes

static[] $Treenode->findAllNodes ( TreenodeMatcher $matcher );

Finds all nodes which match the specified matcher.

public findAncestors

static[] $Treenode->findAncestors ( );

Finds all ancestors of a specific node, including the node, not including the root node of the tree
The array is in order from top to bottom, so $ancestors[0] is the top-parent, and $ancestors[len-1] is the node.

        A
   B         C
 D   E     F   G
H I

NODE    RESULT ARRAY
 H       B D H
 D       B D
 B       B
 A       (empty)

public findNode

static $Treenode->findNode ( TreenodeMatcher $matcher );

Finds a node by looking at this node
If that does not match, looking at each of this nodes children in turn.
If that does not match, return null

public findNodeValue

TreeNode $Treenode->findNodeValue ( mixed $key , mixed $value );

Finds a node by looking at this node
If that does not match, looking at each of this nodes children in turn.
If that does not match, return null

public getAllChildren

unknown $Treenode->getAllChildren ( [ mixed $exclude_id [, mixed $indent_str [, mixed $indent ]]] );

Returns an array of all children nodes, including sub-children

The array will be id => name.
This function requires the table to have a column named 'name'.
The name field will be indented according to the depth.
If specified, the exclude_id argument will be used to
exclude nodes (and their children) according to id.

public getChildren

static[] $Treenode->getChildren ( );

This function does not have a description

public isOrphan

bool $Treenode->isOrphan ( );

Is this node an orphan?
Orphans are at the top of the tree, and they don't have any children.

public isRoot

unknown $Treenode->isRoot ( );

Returns true if this node is the root node

public loadTree

Treenode Treenode::loadTree ( string $table [, array $conditions [, string $order ]] );

Loads a flat table into a tree structure.
Requires the table to have an id, parent_id and record_order field.

public offsetExists

unknown $Treenode->offsetExists ( mixed $offset );

ArrayAccess function for checking if a specified key exists

public offsetGet

unknown $Treenode->offsetGet ( mixed $offset );

ArrayAccess function for getting a value by its key

public offsetSet

void $Treenode->offsetSet ( mixed $offset , mixed $value );

ArrayAccess function for setting a value by its key

public offsetUnset

void $Treenode->offsetUnset ( mixed $offset );

ArrayAccess function for unsetting a value

public removeFilter

void $Treenode->removeFilter ( );

Removes the currently active filter