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
Afficher le fichier Open project: horde/horde Class Usage Examples

Méthodes publiques

Свойство Type Description
$instance string The name of this instance.

Protected Properties

Свойство 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.

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

__construct() public méthode

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 méthode

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

addNode() public méthode

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 méthode

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 méthode

* Countable methods.
public count ( )

getNodes() public méthode

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

getRootNodes() public méthode

Returns the root node IDs.
public getRootNodes ( ) : array
Résultat array The root nodes.

isExpanded() public méthode

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

nodeId() public méthode

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

sort() public méthode

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 méthode

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
Résultat array

$_root_nodes protected_oe property

The top-level nodes in the tree.
protected array $_root_nodes
Résultat array

$_session protected_oe property

Callbacks used to store session data.
protected array $_session
Résultat array

$instance public_oe property

The name of this instance.
public string $instance
Résultat string