wcmf logo wemove logo

Node Class Reference
[Model]

Node is the basic component for building trees (although a Node can have one than more parents). The Node class implements the 'Composite Pattern', so no special tree class is required, all interaction is performed using the Node interface. Subclasses for specialized Nodes must implement this interface so that clients don't have to know about special Node classes. Use the methods addChild(), deleteChild() to build/modify trees. More...

Inheritance diagram for Node:

Inheritance graph
[legend]

Public Member Functions

 Node ($type, $oid=null)
 getNumChildren ($memOnly=true, $type=null)
 addChild (&$child, $addtype=ADDCHILD_BACK)
 updateParent (&$parent, $recursive=true)
 deleteChild ($childOID, $reallyDelete=false)
 loadChildren ($type, $buildDepth=BUILDDEPTH_SINGLE, $forceUpdate=false)
getFirstChild ($type, $values, $properties)
 getChildren ()
 getChildrenEx ($oid, $type, $values, $properties)
 sortChildren ($criteria, $recursive=false, $changeSortkey=false, $sortFunction='')
 sort (&$nodeList, $criteria, $recursive=false, $changeSortkey=false, $sortFunction='')
 filter (&$nodeList, $oid, $type, $values, $properties)
 getNextSibling ()
 getPreviousSibling ()
 loadParents ($type, $forceUpdate=false)
 getNumParents ($memOnly=true, $type=null)
getParent ()
getFirstParent ($type, $values, $properties)
getParents ()
 getParentsEx ($oid, $type, $values, $properties)
 getDepth ()
 getPath ()
 acceptVisitor (&$visitor)
 setState ($state, $recursive=true)
 getDisplayValue ($useDisplayType=false)
 getDisplayValues ($useDisplayType=false)
 toString ($verbose=false)

Data Fields

 $_children = array()
 $_parents = array()
 $_depth = -1
 $_path = ''

Detailed Description

Node is the basic component for building trees (although a Node can have one than more parents). The Node class implements the 'Composite Pattern', so no special tree class is required, all interaction is performed using the Node interface. Subclasses for specialized Nodes must implement this interface so that clients don't have to know about special Node classes. Use the methods addChild(), deleteChild() to build/modify trees.

Author:
ingo herwig <ingo@wemove.com>

Definition at line 118 of file class.Node.php.


Member Function Documentation

Node ( type,
oid = null 
)

Constructor.

Parameters:
type The Nodes type.
oid The Nodes oid (, optional will be calculated if not given or not valid).

Definition at line 130 of file class.Node.php.

References PersistentObject::PersistentObject().

Referenced by AdodbseqBase::AdodbseqBase(), LocktableBase::LocktableBase(), NMUserRoleBase::NMUserRoleBase(), Role::Role(), and User::User().

Here is the call graph for this function:

getNumChildren ( memOnly = true,
type = null 
)

Get the number of children of the Node.

Parameters:
memOnly True/False wether to only get the number of loaded children or all children [default: true].
type The type of children to check (maybe null to check all children) [default: null].
Returns:
The number of children.

Definition at line 140 of file class.Node.php.

References PersistenceFacade::getOIDParameter(), PersistentObject::getProperty(), and PersistentObject::getType().

Referenced by toString().

Here is the call graph for this function:

addChild ( &$  child,
addtype = ADDCHILD_BACK 
)

Add a Node to the Nodes childrenlist.

Parameters:
child The Node to add.
addtype One of the ADDCHILD constants or any number >= 0 (if the number is greater than the number of children the effect is the same as ADDCHILD_BACK).

Reimplemented in AdodbseqBase, LocktableBase, NMUserRoleBase, RoleRDBBase, and UserRDBBase.

Definition at line 166 of file class.Node.php.

References ArrayUtil::array_insert(), and WCMFException::throwEx().

Referenced by User::addRole(), and loadChildren().

Here is the call graph for this function:

updateParent ( &$  parent,
recursive = true 
)

Set a given parent. Works recursively.

Attention:
Internal use only.
Parameters:
parent A reference to the Node to set the parent to.
recursive Apply function on all subsequent Nodes or not.

Definition at line 195 of file class.Node.php.

References ArrayUtil::array_insert(), PersistentObject::getOID(), and setState().

Here is the call graph for this function:

deleteChild ( childOID,
reallyDelete = false 
)

Delete a Node's child.

Parameters:
childOID The object id of the child Node to delete.
reallyDelete True/false [default: false]. (if reallyDelete==false mark it and it's descendants as deleted).

Reimplemented in AdodbseqBase, LocktableBase, NMUserRoleBase, RoleRDBBase, and UserRDBBase.

Definition at line 223 of file class.Node.php.

References ArrayUtil::array_remove(), and PersistentObject::getOID().

Referenced by loadChildren(), and User::removeRole().

Here is the call graph for this function:

loadChildren ( type,
buildDepth = BUILDDEPTH_SINGLE,
forceUpdate = false 
)

Load the children of a given type and add them. If all children should be loaded, set the type parameter to null.

Parameters:
type The type of children to load (maybe null, to load all children)
buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build [default: BUILDDEPTH_SINGLE)]
forceUpdate True/False wether to reload already loaded children even if they are already loaded [default: false]
Note:
This method relies on the property childoids, that should be set by the mapper, when loading the node

Reimplemented in AdodbseqBase, LocktableBase, NMUserRoleBase, RoleRDBBase, and UserRDBBase.

Definition at line 255 of file class.Node.php.

References addChild(), deleteChild(), PersistenceFacade::getInstance(), PersistentObject::getOID(), PersistenceFacade::getOIDParameter(), and PersistentObject::getProperty().

Referenced by User::getRoles().

Here is the call graph for this function:

& getFirstChild ( type,
values,
properties 
)

Get the first child that matches given conditions.

Parameters:
type The type that the child should match [maybe null].
values An assoziative array holding key value pairs that the child values should match [maybe null].
properties An assoziative array holding key value pairs that the child properties should match [maybe null].
Returns:
An reference to the first child that matched or null.

Definition at line 292 of file class.Node.php.

References getChildrenEx().

Here is the call graph for this function:

getChildren (  ) 

Get the Node's children.

Returns:
An Array holding references to the children.

Definition at line 304 of file class.Node.php.

Referenced by toString().

getChildrenEx ( oid,
type,
values,
properties 
)

Get the children that match given conditions.

Parameters:
oid The object id that the children should match [maybe null].
type The type that the children should match [maybe null].
values An assoziative array holding key value pairs that the children values should match [maybe null].
properties An assoziative array holding key value pairs that the children properties should match [maybe null].
Returns:
An Array holding references to the children that matched.

Reimplemented in AdodbseqBase, LocktableBase, NMUserRoleBase, RoleRDBBase, and UserRDBBase.

Definition at line 320 of file class.Node.php.

References filter().

Referenced by getFirstChild(), and User::getRoles().

Here is the call graph for this function:

sortChildren ( criteria,
recursive = false,
changeSortkey = false,
sortFunction = '' 
)

Sort children by a given criteria.

Parameters:
criteria An assoziative array of criteria - SORTTYPE constant pairs OR a single criteria string. possible criteria: OID, TYPE or any value/property name (e.g. array(OID => SORTTYPE_ASC, 'sortkey' => SORTTYPE_DESC) OR 'sortkey')
Note:
If criteria is only a string we will sort by this criteria with SORTTYPE_ASC
Parameters:
recursive True/False whether the descendants of the children schould be sorted too (default: false)
changeSortkey True/False whether the sortkey should be changed according to the new order (default: false)
sortFunction The name of a global compare function to use. If given criteria will be ignored (default: "")

Definition at line 334 of file class.Node.php.

References sort().

Referenced by sort().

Here is the call graph for this function:

sort ( &$  nodeList,
criteria,
recursive = false,
changeSortkey = false,
sortFunction = '' 
)

Sort Node list by a given criteria.

Note:
static method
Parameters:
nodeList A reference to an array of Nodes
criteria An assoziative array of criteria - SORTTYPE constant pairs OR a single criteria string. possible criteria: OID, TYPE or any value/property name (e.g. array(OID => SORTTYPE_ASC, 'sortkey' => SORTTYPE_DESC) OR 'sortkey')
Note:
If criteria is only a string we will sort by this criteria with SORTTYPE_ASC
Parameters:
recursive True/False whether the descendants of the children schould be sorted too (default: false)
changeSortkey True/False whether the sortkey should be changed according to the new order (default: false)
sortFunction The name of a global compare function to use. If given criteria will be ignored (default: "")
Returns:
The sorted array of Nodes

Definition at line 351 of file class.Node.php.

References $g_sortCriteria, and sortChildren().

Referenced by NodeUtil::setSortProperties(), SortController::sortAll(), and sortChildren().

Here is the call graph for this function:

filter ( &$  nodeList,
oid,
type,
values,
properties 
)

Get Nodes that match given conditions from a list.

Parameters:
nodeList An reference to an array of nodes to filter.
oid The object id that the Nodes should match [maybe null].
type The type that the Nodes should match [maybe null].
values An assoziative array holding key value pairs that the Node values should match [values are interpreted as regular expression, parameter maybe null].
properties An assoziative array holding key value pairs that the Node properties should match [values are interpreted as regular expression, parameter maybe null].
Returns:
An Array holding references to the Nodes that matched.

Definition at line 395 of file class.Node.php.

References StringUtil::getDump(), WCMFException::getStackTrace(), and Log::warn().

Referenced by getChildrenEx(), UserRDBBase::getChildrenEx(), RoleRDBBase::getChildrenEx(), and getParentsEx().

Here is the call graph for this function:

getNextSibling (  ) 

Get the next sibling of the Node.

Returns:
The next sibling of the node or NULL if it does not exists.

Definition at line 447 of file class.Node.php.

References PersistentObject::getOID(), and getParent().

Here is the call graph for this function:

getPreviousSibling (  ) 

Get the previous sibling of the Node.

Returns:
The previous sibling of the node or NULL if it does not exists.

Definition at line 471 of file class.Node.php.

References PersistentObject::getOID(), and getParent().

Here is the call graph for this function:

loadParents ( type,
forceUpdate = false 
)

Load the parents of a given type and add them. If all parents should be loaded, set the type parameter to null.

Parameters:
type The type of parents to load (maybe null, to load all children)
forceUpdate True/False wether to reload already loaded parents even if they are already loaded [default: false]
Note:
This method relies on the property childoids, that should be set by the mapper, when loading the node

Definition at line 498 of file class.Node.php.

References PersistenceFacade::getInstance(), PersistentObject::getOID(), PersistenceFacade::getOIDParameter(), getParentsEx(), and PersistentObject::getProperty().

Here is the call graph for this function:

getNumParents ( memOnly = true,
type = null 
)

Get the number of parents of the Node.

Parameters:
memOnly True/False wether to only get the number of loaded parents or all parents [default: true].
type The type of parents to check (maybe null to check all parents) [default: null].
Returns:
The number of parents.

Definition at line 538 of file class.Node.php.

References PersistenceFacade::getOIDParameter(), PersistentObject::getProperty(), and PersistentObject::getType().

Referenced by toString().

Here is the call graph for this function:

& getParent (  ) 

Get the Nodes parent. This method exists for compatibility with previous versions. It returns the first parent.

Returns:
A reference to the Nodes parent.

Definition at line 563 of file class.Node.php.

Referenced by getDepth(), getNextSibling(), getPath(), and getPreviousSibling().

& getFirstParent ( type,
values,
properties 
)

Get the first parent that matches given conditions.

Parameters:
type The type that the parent should match [maybe null].
values An assoziative array holding key value pairs that the parent values should match [maybe null].
properties An assoziative array holding key value pairs that the parent properties should match [maybe null].
Returns:
An reference to the first parent that matched or null.

Definition at line 577 of file class.Node.php.

References getParentsEx().

Here is the call graph for this function:

& getParents (  ) 

Get the Nodes parents.

Returns:
An array of references to the Nodes parents.

Definition at line 589 of file class.Node.php.

Referenced by toString().

getParentsEx ( oid,
type,
values,
properties 
)

Get the parents that match given conditions.

Parameters:
oid The object id that the parent should match [maybe null].
type The type that the parents should match [maybe null].
values An assoziative array holding key value pairs that the parent values should match [maybe null].
properties An assoziative array holding key value pairs that the parent properties should match [maybe null].
Returns:
An Array holding references to the parents that matched.

Definition at line 605 of file class.Node.php.

References filter().

Referenced by getFirstParent(), NMUserRoleBase::getRoleRDBParents(), NMUserRoleBase::getUserRDBParents(), LocktableBase::getUserRDBParents(), and loadParents().

Here is the call graph for this function:

getDepth (  ) 

Get the Nodes depth.

Returns:
The number of parents of the Node.

Definition at line 613 of file class.Node.php.

References getParent().

Here is the call graph for this function:

getPath (  ) 

Get the Nodes path (to root).

Returns:
The Node path.

Definition at line 628 of file class.Node.php.

References getParent(), and PersistentObject::getType().

Here is the call graph for this function:

acceptVisitor ( &$  visitor  ) 

Accept a Visitor. For use with the 'Visitor Pattern'.

Parameters:
visitor The Visitor.

Definition at line 643 of file class.Node.php.

setState ( state,
recursive = true 
)

Set the state of the node.

Parameters:
state The state to set.
recursive True/False [Default: True]

Definition at line 652 of file class.Node.php.

Referenced by updateParent().

getDisplayValue ( useDisplayType = false  ) 

Output

See also:
PersistentObject::getDisplayValue() Delegates to NodeUtil::getDisplayValue

Definition at line 668 of file class.Node.php.

References PersistentObject::getDisplayValue().

Here is the call graph for this function:

getDisplayValues ( useDisplayType = false  ) 

Delegates to NodeUtil::getDisplayValues

Definition at line 675 of file class.Node.php.

toString ( verbose = false  ) 

Get a string representation of the Node.

Parameters:
verbose True to get a verbose output [default: false]
Returns:
The string representation of the Node.

Reimplemented from PersistentObject.

Definition at line 684 of file class.Node.php.

References getChildren(), getNumChildren(), getNumParents(), PersistentObject::getOID(), and getParents().

Here is the call graph for this function:


Field Documentation

$_children = array()

Definition at line 120 of file class.Node.php.

$_parents = array()

Definition at line 121 of file class.Node.php.

$_depth = -1

Definition at line 122 of file class.Node.php.

$_path = ''

Definition at line 123 of file class.Node.php.


The documentation for this class was generated from the following file:

This page generated via doxygen 1.5.8 Mon Mar 30 01:58:44 2009.
Copyright © 2009 wemove digital solutions GmbH.
sourceforge logo