Tuskfish API
  • Package
  • Class

Packages

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

Classes

  • TfishAncestralObject
  • TfishAngryTree
  • TfishCache
  • TfishFileHandler
  • TfishLogger
  • TfishPreference
  • TfishPreferenceHandler

Functions

  • tfish_autoload

Class TfishAngryTree

Represents hierarchical relationships between collections and member content 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.

As for the name, don't ask.

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
Located at trust_path/libraries/tuskfish/class/TfishAngryTree.php

Methods summary

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

Constructor

Constructor

Parameters

$objectArr
Array of collection objects.
$myId
Name of object ID field.
$parentId
Name of parent object ID field.
$rootId
Name of root object ID field.
public array &
# getTree( )

Get a category tree.

Get a category tree.

Returns

array
Associative array comprising the tree.
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 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 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.
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.

Properties summary

public array $_objects

$_objects Array of objects to be assembled into a category tree.

$_objects Array of objects to be assembled into a category tree.

#
public string $_myId

$_myId Name of object ID field.

$_myId Name of object ID field.

#
public object $_tree

$_tree Associative array that comprises the category tree.

$_tree Associative array that comprises the category tree.

# array()
Tuskfish API API documentation generated by ApiGen