public
|
#
__construct( flDb $db, string $table, string $idField = 'id' )
Construct the object.
Parameters
- $db
- The database object.
- $table
- The name of the table.
- $idField
- The name of the ID field.
|
public
|
|
public
|
|
public
integer
|
#
insertNode( integer $id, enum $where, array $data = array() )
Insert a new child node before or after the given node.
Insert a new child node before or after the given node.
Parameters
- $id
- The node to insert the child before or after.
- $where
- One of BEFORE, AFTER or UNDER.
- $data
- Array of name => value pairs of the field data to set.
Returns
integer ID of the new node or false if not added.
|
public
|
#
deleteNode( integer $id )
Delete the node and all child nodes.
Delete the node and all child nodes.
Parameters
- $id
- The ID of the node to delete.
|
public
boolean
|
#
moveNode( integer $id, integer $nodeId, enum $where )
Move a node before/after another node.
Move a node before/after another node.
Parameters
- $id
- The ID of the node to move.
- $nodeId
- The ID of the node to move before/after or make the parent of $id.
- $where
- One of BEFORE, AFTER or UNDER.
Returns
boolean true of the node was moved; else false.
|
public
boolean
|
#
updateNodeData( integer $id, array $data )
Update the node data.
Parameters
- $id
- The ID of the node to update.
- $data
- The name => value pairs of the data to update
Returns
boolean true of the data was updated; else false.
|
public
array
|
#
getNodeData( integer $id, array $fields = array('id') )
Get the node data.
Parameters
- $id
- The ID of the node to get.
- $fields
- Fields to get.
Returns
array The fields fetched from the node.
|
public
integer
|
#
getParent( integer $id )
Get the parent node.
Parameters
- $id
- ID of the node to get the parent of.
Returns
integer The parent ID or false if the node doesn't exist.
|
public
array
|
#
getChildren( integer $id, array $fields = array('id'), integer $num = 0, boolean $leftToRight = true, integer $depth = 1, string $sortBy = 'lft' )
Get direct child nodes of the given node.
Get direct child nodes of the given node.
Parameters
- $id
- The ID of the node to get the children of.
- $fields
- Fields to get.
- $num
- The number of children to get or 0 for all.
- $leftToRight
- true to order nodes left to right or false to order right to left.
- $depth
- The maximum depth to descend to, 0 for unlimited.
- $sortBy
- The field to sort by.
Returns
array The fields fetched from the child nodes.
|
public
array
|
#
getFirstChild( integer $id, array $fields = array('id') )
Get the first child node of a parent.
Get the first child node of a parent.
Parameters
- $id
- ID of parent to get the 1st child of.
- $fields
- Fields to get.
Returns
array The fields fetched from the child.
|
public
array
|
#
getLastChild( integer $id, array $fields = array('id') )
Get the last child node of a parent.
Get the last child node of a parent.
Parameters
- $id
- ID of parent to get the last child of.
- $fields
- Fields to get.
Returns
array The fields fetched from the child.
|
public
array
|
#
getChildAt( integer $id, integer $idx, array $fields = array('id') )
Get the nth child node.
Parameters
- $id
- ID of the node to get the child from.
- $idx
- The zero based index of the child to get.
- $fields
- Fields to get.
Returns
array The fields fetched from the child or null/false.
|
public
array
|
#
getPrevSibling( integer $id, array $fields = array('id') )
Get the nodes previous sibling.
Get the nodes previous sibling.
Parameters
- $id
- ID of parent to get the previous sibling of.
- $fields
- Fields to get.
Returns
array The fields fetched from the child or null/false.
|
public
array
|
#
getNextSibling( integer $id, array $fields = array('id') )
Get the nodes next sibling.
Get the nodes next sibling.
Parameters
- $id
- ID of parent to get the next sibling of.
- $fields
- Fields to get.
Returns
array The fields fetched from the child or null/false.
|
public
integer
|
#
getSize( integer $id, boolean $directOnly = false )
Get the number of nodes in the specified nodes subtree.
Get the number of nodes in the specified nodes subtree.
Parameters
- $id
- ID of the node to count from.
- $directOnly
- true if counting direct decedents.
Returns
integer The number of nodes.
|
public
integer
|
#
getDepth( integer $id )
Get the depth of the node within the tree.
Get the depth of the node within the tree.
Parameters
- $id
- ID of the node to get the depth of.
Returns
integer The depth, 1 being the top level.
|
public
array
|
#
getPath( integer $id, array $fields = array('id') )
Get the path from the root to a node.
Get the path from the root to a node.
Parameters
- $id
- ID of the node to get the path to.
- $fields
- Fields to get.
Returns
array The fields for the nodes in the path or false if node not known.
|
public
array
|
#
getShortPath( integer $id, string $using = 'id' )
Get the short path from the root to a node.
Get the short path from the root to a node.
Parameters
- $id
- ID of the node to get the path to.
- $using
- The field to return in the short path.
Returns
array The short path root, node or false if node not known.
|
public
array
|
#
getByPath( string|array $path, string $using, array $fields = array('id'), boolean $useWholePath = true, string $pathField = 'childpath' )
Get a node based on the path from the root.
Get a node based on the path from the root.
Parameters
- $path
- The path to the node either an array or a / seperated string of nodes.
- $using
- The name of the field to use in the search.
- $fields
- Fields to get.
- $useWholePath
- true if the whole path must be used, false to get deepest matching node.
- $pathField
- Name of the filed to return holding unused path segments.
Returns
array The fields fetched or null if not found.
|
public
array
|
#
getByShortPath( string|array $path, string $using, array $fields = array('id') )
Get a node based on it's identifier but under a given root node.
Get a node based on it's identifier but under a given root node.
Parameters
- $path
- The path to the node formatted as root:node, or array(root,node)
- $using
- The name of the field to use in the search.
- $fields
- Fields to get.
Returns
array The fields fetched or false if not found.
|