contenido\classes\class.treeitem.php

Show: PublicProtectedPrivateinherited
Table of Contents
Project: Contenido Content Management System

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

Package: Default
Class TreeItem Class to create tree-based items

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

>VPropertypublicboolean $collapsed
Determinates if this tree item is collapsed
Details
Type
boolean
>VPropertypublicstring $collapsed_icon
Icon for the collapsed item
Details
Type
string
>VPropertypublicarray $custom
Contains custom entries
Details
Type
array
>VPropertypublicstring $expanded_icon
Icon for the expanded item
Details
Type
string
>VPropertypublicstring $id
ID for this item
Details
Type
string
>VPropertypublicstring $lastnode_icon
Icon for last node in a branch
Details
Type
string
>VPropertypublicinteger $level
Contains the level of this item
Details
Type
integer
>VPropertypublicstring $name
Name for this item
Details
Type
string
>VPropertypublicarray $parent
Contains the parent of this item
Details
Type
array
>VPropertypublicarray $subitems
Sub Items for this tree item
Details
Type
array

Methods

methodpublicTreeItem(string $name = "", string $id = "", boolean $collapsed = false) : void

Constructor Function Creates a new, independant tree item.

Parameters
NameTypeDescription
$namestring

The name of that item

$idstring

The unique ID of that item

$collapsedboolean

Is this item collapsed by default

methodpublicaddItem(object $item) : void

addItem Adds a new subitem to this item.

Parameters
NameTypeDescription
$itemobject

the item to add

methodpublicaddItemToID(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.

Parameters
NameTypeDescription
$itemobject

the item to add

$idstring

the ID to add the item to

methodpubliccollapseAll(string $start = -2) : void

collapseAll Collapses all items, starting from the $start item.

Parameters
NameTypeDescription
$startstring

the ID to start collapsing from

methodpublicexpandAll(string $start = -2) : void

expandAll Expands all items, starting from the $start item.

Parameters
NameTypeDescription
$startstring

the ID to start expanding from

methodpublicgetCollapsedList(array $list) : void

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

Parameters
NameTypeDescription
$listarray

Contains the list with all collapsed items

methodpublicgetExpandedList(array $list) : void

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

Parameters
NameTypeDescription
$listarray

Contains the list with all expanded items

methodpublicgetFlatTree( $item,  $flat_tree) : void

Starts iterating at root node and flattens the tree into an array

Parameters
NameTypeDescription
$item
$flat_tree
methodpublicgetItemByID(string $id) : object

getItemByID Retrieves a specific item by its ID.

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

Parameters
NameTypeDescription
$idstring

the ID to find

Returns
TypeDescription
objectThe item, or false if nothing was found
methodpublicgetParentNodes( $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 !!

Parameters
NameTypeDescription
$parentNodes
$stop_id
methodpublicgetRealCollapsedList( $list) : void

getCollapsedList thinks if a node has no subnodes it is collapsed I don't think so

Parameters
NameTypeDescription
$list
methodpublicgetTreeParentNodes( $parentNodes,  $id) : void

Returns a list of the id of all parent nodes of the given node

Parameters
NameTypeDescription
$parentNodes
$id
methodpublichasCollapsedNode( $item_id) : void

Parameters
NameTypeDescription
$item_id
methodpublicisCustomAttributeSet(string $item) : void

isCustomAttributeSet checks if a specific custom attribute is set

Parameters
NameTypeDescription
$itemstring

the attribute name to find

methodpublicmarkCollapsed(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.

Parameters
NameTypeDescription
$idstring

the ID to collapse

methodpublicmarkExpanded(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.

Parameters
NameTypeDescription
$idstring

the ID to expand, or an array with all id's

methodpublicremoveItem(string $id) : void

removeItem Removes an item with a specific ID.

Parameters
NameTypeDescription
$idstring

the ID to find

methodpublictraverse(object $objects, integer $level = 0) : void

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

Parameters
NameTypeDescription
$objectsobject

all found objects

$levelinteger

Level to start on

Documentation was generated by phpDocumentor 2.0.0a12.