PHP Class Horde_Tree, horde

Copyright 2003-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Marko Djukic ([email protected])
Author: Michael Slusarz ([email protected])
Author: Jan Schneider ([email protected])
Inheritance: implements Countable
ファイルを表示 Open project: horde/horde Class Usage Examples

Public Properties

Property Type Description
$instance string The name of this instance.

Protected Properties

Property Type Description
$_nodes array An array containing all the tree nodes.
$_root_nodes array The top-level nodes in the tree.
$_session array Callbacks used to store session data.

Public Methods

Method Description
__construct ( string $name, array $session = [] ) Constructor.
addNode ( array $node ) Adds a node to the node tree array.
addNodeParams ( string $id, array $params = [] ) Adds additional parameters to a node.
count ( ) * Countable methods.
getNodes ( ) : array Returns the nodes of the tree.
getRootNodes ( ) : array Returns the root node IDs.
isExpanded ( mixed $id ) : boolean Returns whether the specified node is currently expanded.
nodeId ( string $id ) : string Returns the escaped node ID.
sort ( string $criteria, integer $id ) Sorts the tree by the specified node property.
sortHelper ( $a, $b ) Helper method for sort() to compare two tree elements.

Protected Methods

Method Description
_buildIndents ( array $nodes, integer $indent ) Set the indent level for each node in the tree.

Method Details

__construct() public method

Constructor.
public __construct ( string $name, array $session = [] )
$name string The name of this tree instance.
$session array 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

_buildIndents() protected method

Set the indent level for each node in the tree.
protected _buildIndents ( array $nodes, integer $indent )
$nodes array TODO
$indent integer TODO

addNode() public method

Adds a node to the node tree array.
public addNode ( array $node )
$node array 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() public method

Adds additional parameters to a node.
public addNodeParams ( string $id, array $params = [] )
$id string The unique node id.
$params array Parameters to set (key/value pairs).

count() public method

* Countable methods.
public count ( )

getNodes() public method

Returns the nodes of the tree.
public getNodes ( ) : array
return array The nodes with IDs as keys and node hashes as values.

getRootNodes() public method

Returns the root node IDs.
public getRootNodes ( ) : array
return array The root nodes.

isExpanded() public method

Returns whether the specified node is currently expanded.
public isExpanded ( mixed $id ) : boolean
$id mixed The unique node id.
return boolean True if the specified node is expanded.

nodeId() public method

Returns the escaped node ID.
public nodeId ( string $id ) : string
$id string Node ID.
return string Escaped node ID.

sort() public method

Sorts the tree by the specified node property.
public sort ( string $criteria, integer $id )
$criteria string The node property to sort by.
$id integer Used internally for recursion.

sortHelper() public method

Helper method for sort() to compare two tree elements.
public sortHelper ( $a, $b )

Property Details

$_nodes protected_oe property

An array containing all the tree nodes.
protected array $_nodes
return array

$_root_nodes protected_oe property

The top-level nodes in the tree.
protected array $_root_nodes
return array

$_session protected_oe property

Callbacks used to store session data.
protected array $_session
return array

$instance public_oe property

The name of this instance.
public string $instance
return string