class cTreeItem

 Methods

_flattenArray()

_flattenArray($sourcearray, $destarray, $lastid, $level) 

Parameters

$sourcearray

$destarray

$lastid

$level

adds an item as a subitem to the current item

addItem(\cTreeItem $item) : void

access public

Parameters

$item

\cTreeItem

item item object to add

adds an item to a specific ID

addItemToID(string $id, \cTreeItem $item) : void

access public

Parameters

$id

string

id ID to add the item to

$item

\cTreeItem

item Item to add

cTreeItem()

cTreeItem($id, $name, $collapsed) 

Parameters

$id

$name

$collapsed

collapseBelowID()

collapseBelowID(int $id, $found) : void

access public

Parameters

$id

int

leveloffset Level offset. Ignores all expand operations below the offset.

$found

collapseBelowLevel()

collapseBelowLevel(int $leveloffset) : void

access public

Parameters

$leveloffset

int

leveloffset Level offset. Ignores all expand operations below the offset.

deletes an attribute

deleteAttribute(string $attributeName) : void

access public

Parameters

$attributeName

string

attributeName

deletes a subitem

deleteItem(mixed $id) : \deleted

access public

Parameters

$id

mixed

item object or ID to delete

Returns

\deletedobject

expandBelowID()

expandBelowID(int $id, $found) : void

access public

Parameters

$id

int

leveloffset Level offset. Ignores all expand operations below the offset.

$found

expandBelowLevel()

expandBelowLevel(int $leveloffset) : void

access public

Parameters

$leveloffset

int

leveloffset Level offset. Ignores all expand operations below the offset.

Exports a tree as an array of arrays. Array format: array( array("id" => "Item ID", "name" => "Item name", "level" => 1, "attributes" => array("attr_name" => "attr_value")) );

exportTree() : array

access public

Returns

array

flatTraverse traverses the tree starting from this item, and returning all objects as $objects in a flat array.

flatTraverse(integer $level) 

Parameters

$level

integer

Level to start on

returns an attribute

getAttribute(string $attributeName) : mixed

access public

Parameters

$attributeName

string

attributeName

Returns

mixed

getCollapsedList Returns all items (as ID array) which are collapsed.

getCollapsedList(array $list) 

Parameters

$list

array

Contains the list with all collapsed items

getExpandedList Returns all items (as ID array) which are expanded.

getExpandedList(array $list) 

Parameters

$list

array

Contains the list with all expanded items

Retrieves a specific item by its ID. Note that this function traverses all subitems to find the correct item.

getItemByID(string $id) : \cTreeItem

access public

Parameters

$id

string

id ID to retrieve

Returns

hasAttribute()

hasAttribute($attributeName, $bRecursive) 

Parameters

$attributeName

$bRecursive

importStructuredArray()

importStructuredArray($array) 

Parameters

$array

Imports a table from an array of arrays. Array format: array( array("id" => "Item ID", "name" => "Item name", "level" => 1, "collapsed" => true|false, "attributes" => array("attr_name" => "attr_value")) );

importTable(array $flat_array) : void

The entries "collapsed" and "attributes" are optional!

access public

Parameters

$flat_array

array

flat_array See above

moves an item to another object

moveItem(\cTreeItem $targetItem, mixed $itemToMove) : void

access public

Parameters

$targetItem

\cTreeItem

targetItem Item to move the subitem to

$itemToMove

mixed

itemToMove cTreeItem-Object or id of object to move

sets a custom attribute for this TreeItem

setAttribute(string $attributeName, array $attributeValue) : void

access public

Parameters

$attributeName

string

attributeName

$attributeValue

array

attributeValue The value(s) of the attribute

sets a bunch of attributes

setAttributes(string $aAttributeArray) : void

access public

Parameters

$aAttributeArray

string

attributeName

setCollapsed()

setCollapsed(mixed $id) : void

access public

Parameters

$id

mixed

collapse ID to collapse or an array with items to collapse

setExpanded()

setExpanded(mixed $id) : void

access public

Parameters

$id

mixed

expand ID of item to expand or array of item ID's to expand

setName sets the Name for this item.

setName(string $name) : \none

Parameters

$name

string

New name for this item

Returns

\none

sets a payload object for later reference

setPayloadObject(object $payload) : void

access public

Parameters

$payload

object

payload The object to payload

traverse traverses the tree starting from this item, and returning all objects as $objects in a nested array.

traverse(object $objects, integer $level) 

Parameters

$objects

object

all found objects

$level

integer

Level to start on

unsets a payload object

unsetPayloadObject() : object

access public

Returns

object

 Properties

 

Contains custom entries

$_attributes : array

 

Determinates if this tree item is collapsed

$_collapsed : boolean

 

ID for this item

$_id : string

 

Contains the level of this item

$_level : integer

 

Name for this item

$_name : string

 

Contains the next item

$_next : array

 

Contains the parent of this item

$_parent : array

 

Contains the previous item

$_previous : array

 

Sub Items for this tree item

$_subitems : array