contenido\classes\class.treeitem.php
Description: Contenido Tree Item Class
Requirements:
- Author
- Timo A. Hummel
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- Contenido Backend classes
- Since
- file available since contenido release <= 4.6 {@internal created 2003-05-20 modified 2008-06-30, Dominik Ziegler, add security fix $Id: class.treeitem.php 387 2008-06-30 10:01:05Z timo.trautmann $: }}
- Version
- 1.1.4
\TreeItem
The treeitem class allows you to logically store tree-based structures.
Example:
Let's have a tree with 3 nodes. It's important that we always have a "root" key.
$root = new TreeItem("root", 1); $item1 = new TreeItem("node1",2); $item2 = new TreeItem("node2",3); $item3 = new TreeItem("node3",4);
$root->addItem($item1); $root->addItem($item2); $root->addItem($item3);
This represents the tree we described above.
If you know the ID of the item you want to add to, there's no need to have a specific item handy, but rather you can use the "addItemToID" function.
Properties
Methods


TreeItem(string $name = "", string $id = "", boolean $collapsed = false) : void
Constructor Function Creates a new, independant tree item.
Name | Type | Description |
---|---|---|
$name | string | The name of that item |
$id | string | The unique ID of that item |
$collapsed | boolean | Is this item collapsed by default |


addItem(object $item) : void
addItem Adds a new subitem to this item.
Name | Type | Description |
---|---|---|
$item | object | the item to add |


addItemToID(object $item, string $id) : void
addItemToID Adds a new subitem to a specific item with an ID.
Traverses all subitems to find the correct item.
Name | Type | Description |
---|---|---|
$item | object | the item to add |
$id | string | the ID to add the item to |


collapseAll(string $start = -2) : void
collapseAll Collapses all items, starting from the $start item.
Name | Type | Description |
---|---|---|
$start | string | the ID to start collapsing from |


expandAll(string $start = -2) : void
expandAll Expands all items, starting from the $start item.
Name | Type | Description |
---|---|---|
$start | string | the ID to start expanding from |


getCollapsedList(array $list) : void
getCollapsedList Returns all items (as ID array) which are collapsed.
Name | Type | Description |
---|---|---|
$list | array | Contains the list with all collapsed items |


getExpandedList(array $list) : void
getExpandedList Returns all items (as ID array) which are expanded.
Name | Type | Description |
---|---|---|
$list | array | Contains the list with all expanded items |


getFlatTree( $item, $flat_tree) : void
Starts iterating at root node and flattens the tree into an array
Name | Type | Description |
---|---|---|
$item | ||
$flat_tree |


getItemByID(string $id) : object
getItemByID Retrieves a specific item by its ID.
Note that this function traverses all subitems to find the correct item.
Name | Type | Description |
---|---|---|
$id | string | the ID to find |
Type | Description |
---|---|
object | The item, or false if nothing was found |


getParentNodes( $parentNodes, $stop_id) : void
Returns a list of the id of all parent nodes of the given node Not using the nodes of hierarchical tree, but flat tree !!
Name | Type | Description |
---|---|---|
$parentNodes | ||
$stop_id |


getRealCollapsedList( $list) : void
getCollapsedList thinks if a node has no subnodes it is collapsed I don't think so
Name | Type | Description |
---|---|---|
$list |


getTreeParentNodes( $parentNodes, $id) : void
Returns a list of the id of all parent nodes of the given node
Name | Type | Description |
---|---|---|
$parentNodes | ||
$id |


isCustomAttributeSet(string $item) : void
isCustomAttributeSet checks if a specific custom attribute is set
Name | Type | Description |
---|---|---|
$item | string | the attribute name to find |


markCollapsed(string $id) : void
markCollapsed Marks an item as collpased.
Traverses all subitems to find the ID. Note that only the item with $id is collapsed, but not its childs.
Name | Type | Description |
---|---|---|
$id | string | the ID to collapse |


markExpanded(string $id) : void
markExpanded Marks an item as expanded.
Traverses all subitems to find the ID. Note that only the item with $id is expanded, but not its childs.
Name | Type | Description |
---|---|---|
$id | string | the ID to expand, or an array with all id's |


removeItem(string $id) : void
removeItem Removes an item with a specific ID.
Name | Type | Description |
---|---|---|
$id | string | the ID to find |