\Horde_Tree

The Horde_Tree class provides a tree view of hierarchical information. It allows for expanding/collapsing of branches.

Copyright 2003-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
__construct()
addNode()
addNodeParams()
getRootNodes()
getNodes()
sort()
sortHelper()
isExpanded()
nodeId()
count()
$instance
TOGGLE
_buildIndents()
$_session
$_nodes
$_root_nodes
N/A
No private methods found
No private properties found
N/A

Constants

TOGGLE

TOGGLE

The preceding text, before the Horde_Tree instance name, used for collapse/expand submissions.

Properties

$instance

$instance : string

The name of this instance.

Type

string

$_session

$_session : array

Callbacks used to store session data.

Type

array

$_nodes

$_nodes : array

An array containing all the tree nodes.

Type

array

$_root_nodes

$_root_nodes : array

The top-level nodes in the tree.

Type

array

Methods

__construct()

__construct(string  $name, array  $session = array()) 

Constructor.

Parameters

string $name

The name of this tree instance.

array $session

Callbacks used to store session data. Must define two keys: 'get' and 'set'. Function definitions: (string) = get([string - Instance], [string - ID]); set([string - Instance], [string - ID], [boolean - value]); DEFAULT: No session storage

addNode()

addNode(array  $node) 

Adds a node to the node tree array.

Parameters

array $node

A hash with node properties:

  • id: (string) The unique node id.
  • parent: (string) The parent's unique node id.
  • label: (string) The text label for the node.
  • expanded: (boolean) Is this level expanded or not.
  • params: (array) Any other parameters to set (see addNodeParams() of the renderers for full details).

addNodeParams()

addNodeParams(string  $id, array  $params = array()) 

Adds additional parameters to a node.

Parameters

string $id

The unique node id.

array $params

Parameters to set (key/value pairs).

getRootNodes()

getRootNodes() : array

Returns the root node IDs.

Returns

array —

The root nodes.

getNodes()

getNodes() : array

Returns the nodes of the tree.

Returns

array —

The nodes with IDs as keys and node hashes as values.

sort()

sort(string  $criteria, integer  $id = -1) 

Sorts the tree by the specified node property.

Parameters

string $criteria

The node property to sort by.

integer $id

Used internally for recursion.

sortHelper()

sortHelper(  $a,   $b) 

Helper method for sort() to compare two tree elements.

Parameters

$a
$b

isExpanded()

isExpanded(mixed  $id) : boolean

Returns whether the specified node is currently expanded.

Parameters

mixed $id

The unique node id.

Returns

boolean —

True if the specified node is expanded.

nodeId()

nodeId(string  $id) : string

Returns the escaped node ID.

Parameters

string $id

Node ID.

Returns

string —

Escaped node ID.

count()

count() 

_buildIndents()

_buildIndents(array  $nodes, integer  $indent) 

Set the indent level for each node in the tree.

Parameters

array $nodes

TODO

integer $indent

TODO