Tree
[ class tree: Tree ] [ index: Tree ] [ all elements ]

Class: Tree_Common

Source Location: /Tree-0.3.7/Tree/Common.php

Class Overview


common tree class, implements common functionality


Author(s):

Version:

  • 2001/06/27

Variables

Methods


Child classes:

Tree_OptionsMDB
this class additionally retreives a DB connection and saves it in the property "dbh"
Tree_OptionsMDB2
this class additionally retreives a DB connection and saves it in the property "dbh"
Tree_OptionsDB
this class additionally retreives a DB connection and saves it in the property "dbh"
Tree_Memory
this class can be used to step through a tree using ['parent'],['child']

Inherited Variables

Inherited Methods


Class Details

[line 33]
common tree class, implements common functionality


[ Top ]


Class Variables

$options = array()

[line 49]

put proper value-keys are given in each class, depending on the implementation only some options are needed or allowed, see the classes which extend this one
  • Var: saves the options passed to the constructor
  • Access: public

Type:   array


[ Top ]



Method Detail

getAllChildren   [line 113]

mixed getAllChildren( integer $id)

gets all the children and grand children etc.
  • Return: an array of all the children of the element with id=$id, or false if there are no children
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2002/09/30
  • Access: public

Parameters:

integer   $id     ID of the element that the children shall be retreived for

[ Top ]

getAllChildrenIds   [line 167]

mixed getAllChildrenIds( integer $id)

gets all the children-ids and grand children-ids
  • Return: an array of all the ids of the children of the element with id=$id, or false if there are no children
  • Author: Kriesing <wolfram@kriesing.de>
  • Version: 2002/09/30
  • Access: public

Parameters:

integer   $id     ID of the element that the children shall be retreived for

[ Top ]

getChildId   [line 59]

void getChildId( $id)


Parameters:

   $id     

[ Top ]

getChildrenIds   [line 80]

mixed getChildrenIds( integer $id, [integer $levels = 1])

get the ids of the children of the given element
  • Return: an array of all the ids of the children of the element with id=$id, or false if there are no children
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2002/02/06
  • Access: public

Parameters:

integer   $id     ID of the element that the children shall be retreived for
integer   $levels     how many levels deep into the tree

[ Top ]

getDepth   [line 545]

int getDepth( )

return the maximum depth of the tree
  • Return: the depth of the tree
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2003/02/25
  • Access: public

Overridden in child classes as:

Tree_Dynamic_MDBnested::getDepth()
return the maximum depth of the tree
Tree_Dynamic_MDB2nested::getDepth()
return the maximum depth of the tree
Tree_Dynamic_DBnested::getDepth()
return the maximum depth of the tree

[ Top ]

getFirstRootId   [line 314]

void getFirstRootId( )


[ Top ]

getIdByPath   [line 527]

void getIdByPath( $path, [ $startId = 0], [ $nodeName = 'name'], [ $seperator = '/'])


Overridden in child classes as:

Tree_Dynamic_MDBnested::getIdByPath()
return the id of the element which is referenced by $path
Tree_Dynamic_MDB2nested::getIdByPath()
return the id of the element which is referenced by $path
Tree_Dynamic_DBnested::getIdByPath()
return the id of the element which is referenced by $path
Tree_Memory::getIdByPath()
return the id of the element which is referenced by $path

Parameters:

   $path     
   $startId     
   $nodeName     
   $seperator     

[ Top ]

getLeftId   [line 286]

void getLeftId( $id)


Parameters:

   $id     

[ Top ]

getLevel   [line 493]

void getLevel( mixed $id)

get the level, which is how far below the root the element with the given id is

Overridden in child classes as:

Tree_Dynamic_MDBnested::getLevel()
Tree_Dynamic_MDB2nested::getLevel()
Tree_Dynamic_DBnested::getLevel()
Tree_Memory::getLevel()
get the level, which is how far below the root are we?

Parameters:

mixed   $id     the id of the node to get the level for

[ Top ]

getNextId   [line 258]

void getNextId( $id)


Parameters:

   $id     

[ Top ]

getOption   [line 803]

void getOption( boolean $option)

  • Author: copied from PEAR: DB/commmon.php
  • Access: public

Parameters:

boolean   $option     true on success

[ Top ]

getOptions   [line 831]

string getOptions( )

returns all the options
  • Return: all options as an array
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 02/05/20
  • Access: public

[ Top ]

getParentId   [line 191]

void getParentId( integer $id)

get the id of the parent for the given element

Parameters:

integer   $id     the id of the element for which the parentId shall be retreived

[ Top ]

getParents   [line 210]

array getParents( integer $id)

this gets all the preceeding nodes, the parent and it's parent and so on
  • Return: of the parent nodes including the node with id $id
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2002/08/19
  • Access: public

Parameters:

integer   $id     the id of the element for which the parentId shall be retreived

[ Top ]

getParentsIds   [line 238]

array getParentsIds( integer $id)

get the ids of the parents and all it's parents and so on it simply returns the ids of the elements returned by getParents()

Parameters:

integer   $id     the id of the element for which the parentId shall be retreived

[ Top ]

getPath   [line 407]

array getPath( mixed $id)

gets the path to the element given by its id
  • Return: this array contains all elements from the root to the element given by the id
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2001/10/10
  • Abstract:
  • Access: public

Overridden in child classes as:

Tree_Dynamic_MDBnested::getPath()
gets the path from the element with the given id down to the root. The returned array is sorted to start at root for simply walking through and retreiving the path
Tree_Dynamic_MDB2nested::getPath()
gets the path from the element with the given id down to the root. The returned array is sorted to start at root for simply walking through and retreiving the path
Tree_Dynamic_DBnested::getPath()
gets the path from the element with the given id down to the root. The returned array is sorted to start at root for simply walking through and retreiving the path
Tree_Memory::getPath()
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

Parameters:

mixed   $id     the id of the node to get the path for

[ Top ]

getPathAsString   [line 364]

array getPathAsString( mixed $id, [integer $seperator = '/'], [integer $offset = 0], [string $length = 0], [ $key = 'name'])

returns the path as a string
  • Return: this array contains all elements from the root to the element given by the id
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2002/03/28
  • Access: public

Overridden in child classes as:

treeClass::getPathAsString()

Parameters:

mixed   $id     the id of the node to get the path for
integer   $seperator     If offset is positive, the sequence will start at that offset in the array . If offset is negative, the sequence will start that far from the end of the array.
integer   $offset     If length is given and is positive, then the sequence will have that many elements in it. If length is given and is negative then the sequence will stop that many elements from the end of the array. If it is omitted, then the sequence will have everything from offset up until the end of the array.
string   $length     you can tell the key the path shall be used to be constructed with i.e. giving 'name' (=default) would use the value of the $element['name'] for the node-name (thanks to Michael Johnson).
   $key     

[ Top ]

getPreviousId   [line 272]

void getPreviousId( $id)


Parameters:

   $id     

[ Top ]

getRightId   [line 300]

void getRightId( $id)


Parameters:

   $id     

[ Top ]

getRootId   [line 328]

void getRootId( )


[ Top ]

hasChildren   [line 689]

boolean hasChildren( [integer $id = 0])

returns if the given element has any children
  • Return: true if the node has children
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2001/12/17
  • Access: public

Overridden in child classes as:

Tree_Dynamic_MDBnested::hasChildren()
Tells if the node with the given ID has children.
Tree_Dynamic_MDB2nested::hasChildren()
Tells if the node with the given ID has children.
Tree_Dynamic_DBnested::hasChildren()
Tells if the node with the given ID has children.

Parameters:

integer   $id     the id of the node to check for children

[ Top ]

isChildOf   [line 514]

boolean isChildOf( int $id, int $childId, [boolean $checkAll = true])

returns if $childId is a child of $id
  • Return: true if it is a child
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 2002/04/29
  • Abstract:
  • Access: public

Overridden in child classes as:

Tree_Dynamic_MDBnested::isChildOf()
returns if $childId is a child of $id
Tree_Dynamic_MDB2nested::isChildOf()
returns if $childId is a child of $id
Tree_Dynamic_DBnested::isChildOf()
returns if $childId is a child of $id

Parameters:

int   $id     id of the element
int   $childId     id of the element to check if it is a child
boolean   $checkAll     if this is true the entire tree below is checked

[ Top ]

setOption   [line 744]

void setOption( string $option, mixed $value, [boolean $force = false])

  • Author: Stig S. Baaken
  • Access: public

Parameters:

string   $option     the option name
mixed   $value     the value for this option
boolean   $force     if set to true options are also set even if no key(s) was/were found in the options property

[ Top ]

setOptions   [line 785]

void setOptions( array $options, [boolean $force = false])

set a number of options which are simply given in an array
  • Access: public

Parameters:

array   $options     the values to set
boolean   $force     if set to true options are also set even if no key(s) was/were found in the options property

[ Top ]

Tree_Options   [line 722]

void Tree_Options( [array $options = array()], [boolean $force = false])

this constructor sets the options, since i normally need this and in case the constructor doesnt need to do anymore i already have it done :-)

Parameters:

array   $options     the key-value pairs of the options that shall be set
boolean   $force     if set to true options are also set even if no key(s) was/were found in the options property

[ Top ]

_getAllChildren   [line 138]

mixed &_getAllChildren( integer $id)

this method gets all the children recursively

Parameters:

integer   $id     ID of the element that the children shall be retreived for

[ Top ]


Documentation generated on Wed, 04 Jan 2012 03:00:17 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.