XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
XoopsObjectTree Class Reference

Public Member Functions

 __construct (&$objectArr, $myId, $parentId, $rootId=null)
 
 _initialize ()
 
getTree ()
 
getByKey ($key)
 
getFirstChild ($key)
 
getAllChild ($key, $ret=[])
 
getAllParent ($key, $ret=[], $uplevel=1)
 
 _makeSelBoxOptions ($fieldName, $selected, $key, &$ret, $prefix_orig, $prefix_curr='')
 
makeSelBox ($name, $fieldName, $prefix='-', $selected='', $addEmptyOption=false, $key=0)
 

Data Fields

 $_parentId
 
 $_myId
 
 $_rootId = null
 
 $_tree = []
 
 $_objects
 

Detailed Description

Definition at line 14 of file tree.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( & $objectArr,
$myId,
$parentId,
$rootId = null )

#- Constructor

Parameters
array$objectArrArray of XoopsObjects
string$myIdfield name of object ID
string$parentIdfield name of parent object ID
string$rootIdfield name of root object ID

Definition at line 35 of file tree.php.

Member Function Documentation

◆ _initialize()

_initialize ( )

Initialize the object

@access private

Definition at line 51 of file tree.php.

◆ _makeSelBoxOptions()

_makeSelBoxOptions ( $fieldName,
$selected,
$key,
& $ret,
$prefix_orig,
$prefix_curr = '' )

Make options for a select box from

Parameters
string$fieldNameName of the member variable from the node objects that should be used as the title for the options.
string$selectedValue to display as selected
int$keyID of the object to display as the root of select options
string$ret(reference to a string when called from outside) Result from previous recursions
string$prefix_origString to indent items at deeper levels
string$prefix_currString to indent the current item
Returns
void

@access private

Definition at line 159 of file tree.php.

◆ getAllChild()

& getAllChild ( $key,
$ret = [] )

returns an array of all child objects of an object specified by its id

Parameters
string$keyID of the parent
array$ret(Empty when called from client) Array of children from previous recursions.
Returns
array Array of child nodes.

Definition at line 110 of file tree.php.

◆ getAllParent()

& getAllParent ( $key,
$ret = [],
$uplevel = 1 )

returns an array of all parent objects. the key of returned array represents how many levels up from the specified object

Parameters
string$keyID of the child object
array$ret(empty when called from outside) Result from previous recursions
int$uplevel(empty when called from outside) level of recursion
Returns
array Array of parent nodes.

Definition at line 133 of file tree.php.

◆ getByKey()

& getByKey ( $key)

returns an object from the tree specified by its id

Parameters
string$keyID of the object to retrieve
Returns
object Object within the tree

Definition at line 81 of file tree.php.

◆ getFirstChild()

& getFirstChild ( $key)

returns an array of all the first child object of an object specified by its id

Parameters
string$keyID of the parent object
Returns
array Array of children of the parent

Definition at line 92 of file tree.php.

◆ getTree()

& getTree ( )

Get the tree

Returns
array Associative array comprising the tree

Definition at line 70 of file tree.php.

◆ makeSelBox()

& makeSelBox ( $name,
$fieldName,
$prefix = '-',
$selected = '',
$addEmptyOption = false,
$key = 0 )

Make a select box with options from the tree

Parameters
string$nameName of the select box
string$fieldNameName of the member variable from the node objects that should be used as the title for the options.
string$prefixString to indent deeper levels
string$selectedValue to display as selected
bool$addEmptyOptionSet TRUE to add an empty option with value "0" at the top of the hierarchy
int$keyID of the object to display as the root of select options
Returns
string HTML select box

Definition at line 189 of file tree.php.

Field Documentation

◆ $_myId

$_myId

Definition at line 21 of file tree.php.

◆ $_objects

$_objects

Definition at line 24 of file tree.php.

◆ $_parentId

$_parentId

#+ @access private

Definition at line 20 of file tree.php.

◆ $_rootId

$_rootId = null

Definition at line 22 of file tree.php.

◆ $_tree

$_tree = []

Definition at line 23 of file tree.php.


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