Class: Tree_Memory
Source Location: /Tree-0.3.7/Tree/Memory.php
Tree_Common
|
--Tree_Memory
this class can be used to step through a tree using ['parent'],['child']
Author(s):
Version:
|
|
|
Child classes:
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
Method Detail
Tree_Memory (Constructor) [line 175]
Tree_Memory Tree_Memory(
mixed
$type, [array
$dsn = ''], [
$options = array()])
|
|
set up this object
Parameters:
add [line 437]
mixed add(
array
$newValues, [int
$parentId = 0], [int
$prevId = 0])
|
|
adds _one_ new element in the tree under the given parent the values' keys given have to match the db-columns, because the value gets inserted in the db directly to add an entire node containing children and so on see 'addNode()'
Parameters:
addNode [line 853]
mixed addNode(
array
$node)
|
|
Adds multiple elements. You have to pass those elements in a multidimensional array which represents the tree structure as it shall be added (this array can of course also simply contain one element). The following array $x passed as the parameter $x[0] = array('name' => 'bla', 'parentId' => '30', array('name' => 'bla1', 'comment' => 'foo', array('name' => 'bla2'), array('name' => 'bla2_1') ), array('name'=>'bla1_1'), ); $x[1] = array('name' => 'fooBla', 'parentId' => '30'); would add the following tree (or subtree/node) under the parent with the id 30 (since 'parentId'=30 in $x[0] and in $x[1]): +--bla | +--bla1 | | +--bla2 | | +--bla2_1 | +--bla1_1 +--fooBla
Parameters:
buildStructure [line 680]
boolean buildStructure(
integer
$parentId, integer
&$insertIn)
|
|
builds the structure in the parameter $insertIn this function works recursively down into depth of the folder structure it builds an array which goes as deep as the structure goes
Parameters:
copy [line 1497]
boolean copy(
the
$srcId, the
$destId)
|
|
NOT IMPLEMENTED YET copies a part of the tree under a given parent
Parameters:
getChild [line 1117]
void &getChild(
mixed
$id)
|
|
returns the child if the node given has one !!! ATTENTION watch out that you never change any of the data returned, since they are references to the internal property $data
Parameters:
getChildren [line 1389]
boolean getChildren(
$ids, [integer
$levels = 1], integer
$id)
|
|
returns the children of the given ids
Parameters:
getElementByPath [line 1075]
integer &getElementByPath(
string
$path, [integer
$startId = 0], [string
$nodeName = 'name'], [string
$seperator = '/'])
|
|
gets an element given by it's path as a reference
Parameters:
getFirstRoot [line 1280]
this gets the first element that is in the root node i think that there can't be a "getRoot" method since there might be multiple number of elements in the root node, at least the way it works now
getIdByPath [line 1225]
integer getIdByPath(
string
$path, [integer
$startId = 0], [string
$nodeName = 'name'], [string
$seperator = '/'])
|
|
return the id of the element which is referenced by $path this is useful for xml-structures, like: getIdByPath('/root/sub1/sub2') this requires the structure to use each name uniquely if this is not given it will return the first proper path found i.e. there should only be one path /x/y/z
Overrides Tree_Common::getIdByPath() (parent method not documented)
Parameters:
getLevel [line 1098]
void getLevel(
mixed
$id)
|
|
get the level, which is how far below the root are we?
Overrides Tree_Common::getLevel() (get the level, which is how far below the root the element with the given id is)
Parameters:
getNext [line 1157]
mixed &getNext(
mixed
$id)
|
|
returns the next element if the node given has one !!! ATTENTION watch out that you never change any of the data returned, since they are references to the internal property $data
Parameters:
getNode [line 1326]
array &getNode(
[integer
$startId = 0], [integer
$depth = 0])
|
|
gets the tree under the given element in one array, sorted so you can go through the elements from begin to end and list them as they are in the tree, where every child (until the deepest) is retreived
Parameters:
getParent [line 1137]
void &getParent(
mixed
$id)
|
|
returns the child if the node given has one !!! ATTENTION watch out that you never change any of the data returned, since they are references to the internal property $data
Parameters:
getPath [line 907]
array getPath(
mixed
$id)
|
|
gets the path to the element given by its id !!! ATTENTION watch out that you never change any of the data returned, since they are references to the internal property $data
Overrides Tree_Common::getPath() (gets the path to the element given by its id)
Parameters:
getPrevious [line 1177]
mixed &getPrevious(
mixed
$id)
|
|
returns the previous element if the node given has one !!! ATTENTION watch out that you never change any of the data returned, since they are references to the internal property $data
Parameters:
getRoot [line 1302]
since in a nested tree there can only be one root which i think (now) is correct, we also need an alias for this method this also makes all the methods in Tree_Common, which access the root element work properly!
isNode [line 1419]
boolean isNode(
[integer
$id = 0])
|
|
returns if the given element is a valid node
Parameters:
move [line 545]
boolean move(
integer
$idsToMove, integer
$newParentId, [integer
$newPrevId = 0])
|
|
move an entry under a given parent or behind a given entry. !!! the 'move behind another element' is only implemented for nested trees now!!!. If a newPrevId is given the newParentId is dismissed! call it either like this: $tree->move(x, y) to move the element (or entire tree) with the id x under the element with the id y or // ommit the second parameter by setting it to 0
to move the element (or entire tree) with the id x behind the element with the id y or $tree->move(array (x1 ,x2 ,x3 ), ...
the first parameter can also be an array of elements that shall be moved the second and third para can be as described above
Parameters:
remove [line 461]
boolean remove(
mixed
$id)
|
|
removes the given node and all children if removeRecursively is on
Parameters:
setRemoveRecursively [line 940]
void setRemoveRecursively(
[boolean
$case = true])
|
|
sets the remove-recursively mode, either true or false
Parameters:
setup [line 256]
true setup(
[array
$data = null])
|
|
Parameters:
setupByRawData [line 235]
boolean setupByRawData(
$string)
|
|
Parameters:
switchDataSource [line 211]
boolean switchDataSource(
string
$type, [array
$dsn = ''], [
$options = array()])
|
|
use this to switch data sources on the run i.e. if you are reading the data from a db-tree and want to save it as xml data (which will work one day too) or reading the data from an xml file and writing it in the db which should already work
Parameters:
update [line 644]
mixed update(
integer
$id, array
$data)
|
|
update data in a node
Parameters:
varDump [line 1442]
void varDump(
[
$node = 0])
|
|
this is for debugging, dumps the entire data-array an extra method is needed, since this array contains recursive elements which make a normal print_f or var_dump not show all the data
Parameters:
walk [line 736]
mixed walk(
mixed
$walkFunction, [array
$id = 0], [string
$returnType = 'string'])
|
|
this method only serves to call the _walk method and reset $this->walkReturn that will be returned by all the walk-steps
Parameters:
_move [line 580]
mixed _move(
integer
$idToMove, integer
$newParentId, [integer
$prevId = 0])
|
|
this method moves one tree element
Parameters:
_remove [line 502]
boolean _remove(
$element, mixed
$id)
|
|
collects the ID's of the elements to be removed
Parameters:
Documentation generated on Mon, 11 Mar 2019 15:47:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|