Tuskfish API V1.1.2
  • Package
  • Class

Packages

  • content
  • core
  • database
  • installation
  • security
  • user
  • utilities

Classes

  • TfCache
  • TfFileHandler
  • TfLogger
  • TfMetadata
  • TfPaginationControl
  • TfPreference
  • TfPreferenceHandler
  • TfTemplate
  • TfTree

Traits

  • TfLanguage
  • TfMagicMethods
  • TfMimetypes
  • TfRights

Functions

  • checkPasswordStrength
  • hashPassword
  • tf_autoload
  • tfContentModuleAutoload

Class TfTree

Build and manipulate a tree representing hierarchical relationships between objects.

Essentially this is a category tree, although collections (category analogues) are fully-fledged content objects in their own right. Pass in an array of collection objects; you can choose to pass in all collection objects or you can pass in a branch, in which case the tree will just consist of descendants of the root node.

Package: core
Copyright: http://smartfactory.ca The SmartFactory
License: GNU General Public License (GPL)
Author: Kazumi Ono onokazu@xoops.org
Author: marcan aka Marc-André Lanciault marcan@smartfactory.ca
Author: Madfish simon@isengard.biz
Version: Release: 1.0
Since: 1.0
Var: array $_objects Array of objects to be assembled into a category tree.
Var: string $_myId Name of the ID field used to identify objects in the tree.
Var: string $_parentId Name of ID field used to identify an object's parent in the tree.
Var:

int $_rootId Name of root object ID field. This is the object that will be used as the base node for building a tree (or subtree) from the broader tree structure.


Var: object $_tree Associative array that comprises the category tree.
Located at trust_path/libraries/tuskfish/class/TfTree.php

Methods summary

public
# __construct( array & $objectArr, string $myId, string $parentId, string $rootId = null )

Constructor.

Constructor.

Parameters

$objectArr
Array of collection objects that the tree will be built from.
$myId
Name of the ID field used to identify objects in the tree.
$parentId
Name of ID field used to identify an object's parent in the tree.
$rootId

Name of root object ID field. This is the object that will be used as the base node for building a tree (or subtree) from the $objectArr.

public array &
# getTree( )

Get a category tree.

Get a category tree.

Returns

array
Associative array comprising the tree.
public array
# getAllChild( integer $key, array $ret = array() )

Returns an array of all child objects of a parental object specified by its ID.

Returns an array of all child objects of a parental object specified by its ID.

Parameters

$key
ID of the parent.
$ret
Array of child objects from previous recursions (empty if called from client).

Returns

array
Array of child nodes.
public array
# getAllParent( integer $key, array $ret = array(), integer $uplevel = 1 )

Returns an array of all parent objects.

Returns an array of all parent objects.

The key of returned array represents how many levels up from the specified object.

Parameters

$key
ID of the child object.
$ret
Result from previous recursions (empty when called from outside).
$uplevel
Level of recursion (empty when called from outside).

Returns

array
Array of parent nodes.
public object &
# getByKey( integer $key )

returns an object from the category tree specified by its id.

returns an object from the category tree specified by its id.

Parameters

$key
ID of the object to retrieve.

Returns

object
Object (node) within the tree.
public array
# getFirstChild( integer $key )

Returns an array of all the first child objects of a parental object specified by its id.

Returns an array of all the first child objects of a parental object specified by its id.

Parameters

$key
ID of the parent object.

Returns

array
Array of child objects.
public string
# makeParentSelectBox( integer $selected = 0, integer $key = 0 )

Make a select box of parent collections from the tree.

Make a select box of parent collections from the tree.

Parameters

$selected
Currently selected option.
$key
ID of the object to display as root of the select options.

Returns

string
HTML select box.
public array
# makeSelBox( string $name, string $fieldName, string $prefix = '-- ', integer $selected = 0, boolean $addEmptyOption = false, integer $key = 0 )

Make select box options from the tree.

Make select box options from the tree.

Returns an indented array of options that can be used to build a HTML select box, indented according to the relative hierarchy.

Parameters

$name
Name of the select box.
$fieldName

Name of the member variable from the node objects that should be used as the title field for the options.

$prefix
String to indent deeper levels.
$selected
Value to display as selected.
$addEmptyOption

Set TRUE to add an empty option with value "0" at the top of the hierarchy.

$key
ID of the object to display as the root of select options.

Returns

array
Select box options as ID => title pairs.
Tuskfish API V1.1.2 API documentation generated by ApiGen