class cTreeItem

 Methods

__construct()

__construct($id, $name, $collapsed) 

Parameters

$id

$name

$collapsed

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) 
deprecated 2012-08-24 Use __construct()

Parameters

$id

$name

$collapsed

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

Exports a tree as an array of arrays.

exportTree() : array

Array format: array( array("id" => "Item ID", "name" => "Item name", "level" => 1, "attributes" => array("attr_name" => "attr_value")) );

access public
deprecated 2011-08-22

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

Collapsed state getter

getCollapsed() : bool

Returns

bool

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

Id getter

getId() : string

Returns

string

Retrieves a specific item by its ID.

getItemByID(string $id) : \cTreeItem

Note that this function traverses all subitems to find the correct item.

access public

Parameters

$id

string

id ID to retrieve

Returns

Name getter

getName() : string

Returns

string

hasAttribute()

hasAttribute($attributeName, $bRecursive) 

Parameters

$attributeName

$bRecursive

importStructuredArray()

importStructuredArray($array) 

Parameters

$array

Imports a table from an array of arrays.

importTable(array $flat_array) : void

Array format: array( array("id" => "Item ID", "name" => "Item name", "level" => 1, "collapsed" => true|false, "attributes" => array("attr_name" => "attr_value")) );

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

_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.

_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.

_flattenArray()

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

Parameters

$sourcearray

$destarray

$lastid

$level

 Properties

 

$_attributes : array
 

$_collapsed : boolean
 

$_id : string
 

$_level : integer
 

$_name : string
 

$_next : array
 

$_parent : array
 

$_previous : array
 

$_subitems : array