Get the short name of an object, returns only the last portion of the full name. For display purposes only.
static string
getShortName
(string $name)
-
string
$name: The name of the object.
Constructor.
DataTree
DataTree
([array $params = array()])
-
array
$params: A hash containing any additional configuration or connection parameters a subclass might need. We always need 'group', a string that defines the prefix for each set of hierarchical data.
Adds an object.
TODO
add
(mixed $object, [boolean $id_as_name = false])
-
mixed
$object: The object to add (string or DataTreeObject).
-
boolean
$id_as_name: True or false to indicate if object ID is to be used as object name. Used in situations where there is no available unique input for object name.
Redefined in descendants as:
Counts objects.
integer
count
([string $startleaf = DATATREE_ROOT])
-
string
$startleaf: The name of the leaf from which we start counting.
Returns the number of objects matching a set of attribute criteria.
TODO
countByAttributes
(array $criteria, [string $parent = DATATREE_ROOT], [boolean $allLevels = true], [string $restrict = 'name'])
-
array
$criteria: The array of criteria.
-
string
$parent: The parent node to start searching from.
-
boolean
$allLevels: Return all levels, or just the direct children of $parent? Defaults to all levels.
-
string
$restrict: Only return attributes with the same attribute_name or attribute_id.
Redefined in descendants as:
Replace all occurences of ':' in an object name with '.'.
string
encodeName
(string $name)
-
string
$name: The name of the object.
Check if an object exists or not. The root element DATATREE_ROOT always exists.
boolean
exists
(mixed $object)
-
mixed
$object: The name of the object.
Attempts to return a concrete DataTree instance based on $driver.
DataTree
&factory
(
mixed $driver, [
array $params =
null])
-
mixed
$driver: The type of concrete DataTree subclass to return. This is based on the storage driver ($driver). The code is dynamically included. If $driver is an array, then we will look in $driver[0]/lib/DataTree/ for the subclass implementation named $driver[1].php.
-
array
$params: A hash containing any additional configuration or connection parameters a subclass might need. Here, we need 'group' = a string that defines top-level groups of objects.
Export a list of objects.
mixed
get
(constant $format, [string $startleaf = DATATREE_ROOT], [boolean $reload = false], [string $rootname = DATATREE_ROOT], [integer $maxdepth = -1], [boolean $loadTree = false], [string $sortby_name = null], [string $sortby_key = null], [integer $direction = 0])
-
constant
$format: Format of the export
-
string
$startleaf: The name of the leaf from which we start the export tree.
-
boolean
$reload: Re-load the requested chunk? Defaults to false (only what is currently loaded).
-
string
$rootname: The label to use for the root element. Defaults to DATATREE_ROOT.
-
integer
$maxdepth: The maximum number of levels to return. Defaults to DATATREE_ROOT, which is no limit.
-
boolean
$loadTree: Load a tree starting at $root, or just the requested level and direct parents? Defaults to single level.
-
string
$sortby_name: Attribute name to use for sorting.
-
string
$sortby_key: Attribute key to use for sorting.
-
integer
$direction: Sort direction:
- - ascending
- - descending
Retrieve data for an object from the horde_datatree_attributes table.
array
getAttributes
(integer $cid)
-
integer
$cid: | array $cid The object id to fetch, or an array of object ids.
Redefined in descendants as:
Returns a set of object ids based on a set of attribute criteria.
TODO
getByAttributes
(array $criteria, [string $parent = DATATREE_ROOT], [boolean $allLevels = true], [string $restrict = 'name'], [integer $from = 0], [integer $count = 0], [string $sortby_name = null], [string $sortby_key = null], [integer $direction = 0])
-
array
$criteria: The array of criteria.
-
string
$parent: The parent node to start searching from.
-
boolean
$allLevels: Return all levels, or just the direct children of $parent? Defaults to all levels.
-
string
$restrict: Only return attributes with the same attribute_name or attribute_id.
-
integer
$from: The object to start to fetching
-
integer
$count: The number of objects to fetch
-
string
$sortby_name: Attribute name to use for sorting.
-
string
$sortby_key: Attribute key to use for sorting.
-
integer
$direction: Sort direction:
- - ascending
- - descending
Redefined in descendants as:
Export a list of objects just like get() above, but uses an object id to fetch the list of objects.
mixed
getById
(constant $format, [string $startleaf = DATATREE_ROOT], [boolean $reload = false], [string $rootname = DATATREE_ROOT], [integer $maxdepth = -1])
-
constant
$format: Format of the export.
-
string
$startleaf: The id of the leaf from which we start the export tree.
-
boolean
$reload: Reload the requested chunk? Defaults to false (only what is currently loaded).
-
string
$rootname: The label to use for the root element. Defaults to DATATREE_ROOT.
-
integer
$maxdepth: The maximum number of levels to return Defaults to -1, which is no limit.
Retrieve data for an object from the datatree_data field.
TODO
getData
(integer $cid)
-
integer
$cid: The object id to fetch, or an array of object ids.
Redefined in descendants as:
Returns a list of all groups (root nodes) of the data tree.
mixed
getGroups
()
Redefined in descendants as:
Get the id of an object from its name.
string
getId
(mixed $name)
-
mixed
$name: Either the object, an array containing the path elements, or the object name for which to look up the id.
Get the name of an object from its id.
string
getName
(integer $id)
-
integer
$id: The id for which to look up the name.
Get the number of children an object has, only counting immediate children, not grandchildren, etc.
integer
getNumberOfChildren
([mixed $parent = DATATREE_ROOT])
-
mixed
$parent: Either the object or the name for which to count the children, defaults to the root (DATATREE_ROOT).
Returns a DataTreeObject (or subclass) object of the data in the object defined by $object.
TODO
&getObject
(string $object, [string $class = 'DataTreeObject'])
-
string
$object: The object to fetch: 'parent:sub-parent:name'.
-
string
$class: Subclass of DataTreeObject to use. Defaults to DataTreeObject. Null forces the driver to look into the attributes table to determine the subclass to use. If none is found it uses DataTreeObject.
Returns a DataTreeObject (or subclass) object of the data in the object with the ID $id.
TODO
&getObjectById
(integer $id, [string $class = 'DataTreeObject'])
-
integer
$id: An object id.
-
string
$class: Subclass of DataTreeObject to use. Defaults to DataTreeObject. Null forces the driver to look into the attributes table to determine the subclass to use. If none is found it uses DataTreeObject.
Returns an array of DataTreeObject (or subclass) objects corresponding to the objects in $ids, with the object names as the keys of the array.
TODO
&getObjects
(array $ids, [string $class = 'DataTreeObject'])
-
array
$ids: An array of object ids.
-
string
$class: Subclass of DataTreeObject to use. Defaults to DataTreeObject. Null forces the driver to look into the attributes table to determine the subclass to use. If none is found it uses DataTreeObject.
Get the order position of an object.
mixed
getOrder
(mixed $child)
-
mixed
$child: Either the object or the name.
Returns a parameter of this DataTree instance.
mixed
getParam
(string $param)
-
string
$param: The parameter to return.
Returns a child's direct parent ID.
mixed
getParent
(mixed $child)
-
mixed
$child: Either the object, an array containing the path elements, or the object name for which to look up the parent's ID.
Get a $child's direct parent ID.
mixed
getParentById
(integer $childId)
-
integer
$childId: Get the parent of this object.
Get a parent ID string (id:cid format) for the specified object.
string|PEAR_Error
getParentIdString
(mixed $object)
-
mixed
$object: The object to return a parent string for.
Get a list of parents all the way up to the root object for $child.
array
getParentList
(integer $childId, [array $parents = array()])
-
integer
$childId: The id of the child.
-
array
$parents: The array, as we build it up.
Get a list of parents all the way up to the root object for $child.
mixed
getParents
(mixed $child, [boolean $getids = false])
-
mixed
$child: The name of the child
-
boolean
$getids: If true, return parent IDs; otherwise, return names.
Returns a tree sorted by the specified attribute name and/or key.
array
getSortedTree
(string $root, [boolean $loadTree = false], [string $sortby_name = null], [string $sortby_key = null], [integer $direction = 0])
-
string
$root: Which portion of the tree to sort. Defaults to all of it.
-
boolean
$loadTree: Sort the tree starting at $root, or just the requested level and direct parents? Defaults to single level.
-
string
$sortby_name: Attribute name to use for sorting.
-
string
$sortby_key: Attribute key to use for sorting.
-
integer
$direction: Sort direction:
- - ascending
- - descending
Redefined in descendants as:
Move an object to a new parent.
mixed
move
(mixed $object, [string $newparent = null])
-
mixed
$object: The object to move.
-
string
$newparent: The new parent object. Defaults to the root.
Redefined in descendants as:
Removes an object.
TODO
remove
(string $object, [boolean $force = false])
-
string
$object: The object to remove.
-
boolean
$force: Force removal of every child object?
Redefined in descendants as:
Removes all DataTree objects owned by a certain user.
TODO
removeUserData
(string $user)
-
string
$user: A user name.
Change an object's name.
mixed
rename
(mixed $old_object, string $new_object_name)
-
mixed
$old_object: The old object.
-
string
$new_object_name: The new object name.
Redefined in descendants as:
Changes the order of the children of an object.
TODO
reorder
( $parents, [mixed $order = null], [integer $cid = null], string $parent)
-
string
$parent: The full id path of the parent object.
-
mixed
$order: If an array it specifies the new positions for all child objects. If an integer and $cid is specified, the position where the child specified by $cid is inserted. If $cid is not specified, the position gets deleted, causing the following positions to shift up.
-
integer
$cid: See $order.
-
$parents
Redefined in descendants as:
Import a list of objects. Used by drivers to populate the internal $_data array.
TODO
set
(array $data, [string $charset = null])
-
array
$data: The data to import.
-
string
$charset: The charset to convert the object name from.
Explicitly set the order for a datatree object.
TODO
setOrder
(integer $id, integer $order)
-
integer
$id: The datatree object id to change.
-
integer
$order: The new order.
Redefined in descendants as:
Attempts to return a reference to a concrete DataTree instance based on $driver.
It will only create a new instance if no DataTree instance with the same parameters currently exists.
This should be used if multiple DataTree sources (and, thus, multiple DataTree instances) are required.
This method must be invoked as: $var = &DataTree::singleton();
DataTree
&singleton
(
mixed $driver, [
array $params =
null])
-
mixed
$driver: Type of concrete DataTree subclass to return, based on storage driver ($driver). The code is dynamically included. If $driver is an array, then look in $driver[0]/lib/DataTree/ for subclass implementation named $driver[1].php.
-
array
$params: A hash containing any additional configuration or connection parameters a subclass might need.
Sorts IDs by attribute values. IDs without attributes will be added to the end of the sorted list.
array
sortByAttributes
(array $unordered_ids, [array $sortby_name = null], [array $sortby_key = null], [array $direction = 0])
-
array
$unordered_ids: Array of ids to sort.
-
array
$sortby_name: Attribute name to use for sorting.
-
array
$sortby_key: Attribute key to use for sorting.
-
array
$direction: Sort direction:
- - ascending
- - descending
Redefined in descendants as:
Create attribute sort hash
string
sortHash
(string $root, [string $sortby_name = null], [string $sortby_key = null], [integer $direction = 0])
-
string
$root: The name of the leaf from which we start the export tree.
-
string
$sortby_name: Attribute name to use for sorting.
-
string
$sortby_key: Attribute key to use for sorting.
-
integer
$direction: Sort direction:
- - ascending
- - descending
Update the data in an object. Does not change the object's parent or name, just serialized data or attributes.
Redefined in descendants as:
-
DataTree_null::updateData()
: Update the data in an object. Does not change the object's parent or name, just serialized data.
-
DataTree_sql::updateData()
: Update the data in an object. Does not change the object's parent or name, just serialized data or attributes.
Add an object.
TODO
_add
(string $name, integer $id, integer $pid, [integer $order = ''])
-
string
$name: The short object name.
-
integer
$id: The new object's unique ID.
-
integer
$pid: The unique ID of the object's parent.
-
integer
$order: The ordering data for the object.
Sort two objects by their order field, and if that is the same, alphabetically (case insensitive) by name.
You never call this function; it's used in uasort() calls. Do NOT use usort(); you'll lose key => value associations.
integer
_cmp
(array $a, array $b)
-
array
$a: The first object
-
array
$b: The second object
Sorts two objects by their sorter hash field.
You never call this function; it's used in uasort() calls. Do NOT use usort(); you'll lose key => value associations.
integer
_cmpSorted
(array $a, array $b)
-
array
$a: The first object
-
array
$b: The second object
Dynamically determines the object class.
TODO
_defineObjectClass
(array $attributes)
-
array
$attributes: The set of attributes that contain the class information. Defaults to DataTreeObject.
Extract one level of data for a parent leaf, sorted first by their order and then by name. This function is a way to get a collection of $leaf's children.
array
_extractOneLevel
([string $leaf = DATATREE_ROOT])
-
string
$leaf: Name of the parent from which to start.
Change order of children of an object.
void
_reorder
(string $pid, [mixed $order = null], [integer $cid = null])
-
string
$pid: The parent object id string path.
-
mixed
$order: Specific new order position or an array containing the new positions for the given parent.
-
integer
$cid: If provided indicates insertion of a new child to the parent to avoid incrementing it when shifting up all other children's order. If not provided indicates deletion, so shift all other positions down one.