Public Member Functions | Public Attributes

Tree Class Reference

Tree structure. More...

Inheritance diagram for Tree:
BEAppModel AppModel

List of all members.

Public Member Functions

 beforeSave ()
 check object_path and parent_path, avoid object is parent or ancestor of itself
 getParent ($id, $area_id=null, $status=array())
 get parent or array of parents
 getParents ($id=null, $area_id=null, $status=array())
 Array of objcet $id tree parents objects.
 updateTree ($id, $destination, array $options=array())
 Update tree position of object $id with new $destination array.
 getRootForSection ($id)
 Return id of publication that contains the section, by id.
 appendChild ($id, $idParent=null, $priority=null)
 append an object to a parent in tree
 getAreaIdByPath ($path)
 Return id of publication by path.
 movePriority ($id, $idParent, $up=true)
 move up or down a leaf tree inside a branch
 movePriorityUp ($id, $idParent)
 move up a leaf tree inside a branch
 movePriorityDown ($id, $idParent)
 move down a leaf tree inside a branch
 removeChild ($id, $idParent)
 remove a leaf tree from a branch
 setPriority ($id, $priority, $idParent)
 set position for a leaf tree in a branch
 getPriority ($id, $idParent)
 object position in a tree branch
 move ($idNewParent, $idOldParent, $id)
 move branch to another parent
 getAllRoots ($userid=null, $status=null, $filter=array(), $expandBranch=array())
 get all tree roots objects (publications)
 getAll ($id=null, $userid=null, $status=null, $filter=array())
 Get Tree where 'id' (if it passed) has to be tree root If it's a section id then an empty array is returned.
 buildTree ($items)
 Return a tree build for the items passed.
 isParent ($idParent, $id)
 check if $idParent is an ancestor
 isOnTree ($id, $area_id=null, $status=array())
 check if an object is on the tree
 relatedObjectsOnTree ($id, array $options=array())
 Return a list of a count (based on $option['count']) of related object to $id that are on tree.
 getChildren ($id=null, $userid=null, $status=null, $filter=array(), $order=null, $dir=true, $page=1, $dim=null, $excludeIds=array())
 Children of id element (only 1 level in tree).
 getDescendants ($id=null, $userid=null, $status=null, $filter=array(), $order=null, $dir=true, $page=1, $dim=null, $excludeIds=array())
 Descendants of id element (all elements in tree).
 saveMenuVisibility ($ids, $parent_id, $menu=null)
 save Tree.menu field to set menu and canonical path visibility
 cloneStructure ($id, array $options=array())
 Clone a tree structure Clone Publication and sections and add related contents.
 copyContentsToBranch ($originalBranchId, $newBranchId)
 copy contents from a branch to another brnach
 countUbiquity (array $objects, array $options=array())
 Add to array of BEdita objects a count of ubiquity.
 removeBranch ($id)
 Removes a full branch that originates from the element with passed `$id`.
 removeTree ($id)
 Removes a full tree that originates from the element with passed `$id`.
 countChildrenContents ($parentId, array $options=array())
 Count children using $options if any $options can contain every params used to customize Model::find().
 countChildrenSections ($parentId, array $options=array())
 Count children using $options if any $options can contain every params used to customize Model::find().
 countChildren ($parentId, array $options=array())
 Count children using $options if any $options can contain every params used to customize Model::find().

Public Attributes

 $primaryKey = "object_path"

Detailed Description

Tree structure.

Version:
$Revision$ $LastChangedBy$ $LastChangedDate$

$Id$

Definition at line 31 of file tree.php.


Member Function Documentation

Tree::appendChild ( id,
idParent = null,
priority = null 
)

append an object to a parent in tree

Parameters:
int $id object id
int $idParent parent object id
int $priority if not passed append as last child else use passed position
Returns:
boolean

Definition at line 222 of file tree.php.

References getAreaIdByPath().

Referenced by copyContentsToBranch(), and updateTree().

Tree::beforeSave (  ) 

check object_path and parent_path, avoid object is parent or ancestor of itself

Returns:
boolean

Definition at line 41 of file tree.php.

References getAreaIdByPath().

Tree::buildTree ( items  ) 

Return a tree build for the items passed.

Parameters:
array $items
Returns:
array

Definition at line 523 of file tree.php.

Referenced by getAll().

Tree::cloneStructure ( id,
array $  options = array() 
)

Clone a tree structure Clone Publication and sections and add related contents.

Parameters:
int $id, publication/section id
array $options, see BEAppObjectModel::arrangeDataForClone()
Returns:
array, contain couple of original id and cloned id
Exceptions:
BeditaException 

Definition at line 781 of file tree.php.

References copyContentsToBranch(), and setPriority().

Tree::copyContentsToBranch ( originalBranchId,
newBranchId 
)

copy contents from a branch to another brnach

Parameters:
int $originalBranchId, branch (publication/section) id where the contents are
int $newBranchId, branch (publication/section) id where the contents have to be copied
Exceptions:
BeditaException 

Definition at line 861 of file tree.php.

References appendChild(), getChildren(), and setPriority().

Referenced by cloneStructure().

Tree::countChildren ( parentId,
array $  options = array() 
)

Count children using $options if any $options can contain every params used to customize Model::find().

Parameters:
int $parentId the parent id
array $options
Returns:
int

Definition at line 1073 of file tree.php.

Referenced by countChildrenContents(), and countChildrenSections().

Tree::countChildrenContents ( parentId,
array $  options = array() 
)

Count children using $options if any $options can contain every params used to customize Model::find().

See also:
self::countChildren()
Parameters:
int $parentId the parent id
array $options
Returns:
int

Definition at line 1028 of file tree.php.

References countChildren().

Tree::countChildrenSections ( parentId,
array $  options = array() 
)

Count children using $options if any $options can contain every params used to customize Model::find().

See also:
self::countChildren()
Parameters:
int $parentId the parent id
array $options
Returns:
int

Definition at line 1051 of file tree.php.

References countChildren().

Tree::countUbiquity ( array $  objects,
array $  options = array() 
)

Add to array of BEdita objects a count of ubiquity.

Parameters:
array $objects
array $options
Returns:
array

Definition at line 891 of file tree.php.

Tree::getAll ( id = null,
userid = null,
status = null,
filter = array() 
)

Get Tree where 'id' (if it passed) has to be tree root If it's a section id then an empty array is returned.

Parameters:
integer $id publication id. If null get all trees, one for every publication
string $userid user. if null: no permission check (default); if '': guest user
string $status only objs with this status
array $filter see BEAppModel::findObjects
Returns:
array every first level key is a publication

Definition at line 502 of file tree.php.

References buildTree(), and BEAppModel::findObjects().

Referenced by getAllRoots().

Tree::getAllRoots ( userid = null,
status = null,
filter = array(),
expandBranch = array() 
)

get all tree roots objects (publications)

Parameters:
int $userid
mixed $status string or array of status
array $filter filter options see BEAppModel::findObjects
array $expandBranch array of branch ids of which roots have to expanded
Returns:
array

Definition at line 474 of file tree.php.

References getAll(), and getRootForSection().

Tree::getAreaIdByPath ( path  ) 

Return id of publication by path.

Parameters:
string $path
Returns:
int

Definition at line 266 of file tree.php.

Referenced by appendChild(), beforeSave(), and move().

Tree::getChildren ( id = null,
userid = null,
status = null,
filter = array(),
order = null,
dir = true,
page = 1,
dim = null,
excludeIds = array() 
)

Children of id element (only 1 level in tree).

If userid != null, only objects with read permissione for user, if ' ' - use guest/anonymous user, if userid = null -> no permission check. Filter: object types, search text query.

Parameters:
integer $id root id
string $userid user: null (default) => no permission check. ' ' => guest/anonymous user,
string $status object status
array $filter Filter: object types, search text query, eg. array(21, 22, "search" => "text to search"). Default: all object types
string $order field to order result (id, status, modified..)
boolean $dir true (default), ascending, otherwiese descending.
integer $page Page number (for pagination)
integer $dim Page dim (for pagination)
array $excludeIds array of ids to exclude
Returns:
array

Definition at line 712 of file tree.php.

References BEAppModel::findObjects().

Referenced by copyContentsToBranch().

Tree::getDescendants ( id = null,
userid = null,
status = null,
filter = array(),
order = null,
dir = true,
page = 1,
dim = null,
excludeIds = array() 
)

Descendants of id element (all elements in tree).

(see: BEObject->find(), to search not using content tree ). If userid present, only objects with read permissione, if ' ' - guest/anonymous user, if userid = null -> no permission check. Filter: object types, search text query.

Parameters:
integer $id root id
string $userid user: null (default) => no permission check. ' ' => guest/anonymous user,
string $status object status
array $filter Filter: object types, search text query, eg. array(21, 22, "search" => "text to search"). Default: all object types
string $order field to order result (id, status, modified..)
boolean $dir true (default), ascending, otherwiese descending.
integer $page Page number (for pagination)
integer $dim Page dim (for pagination)
array $excludeIds array of ids to exclude
Returns:
array

Definition at line 735 of file tree.php.

References BEAppModel::findObjects().

Tree::getParent ( id,
area_id = null,
status = array() 
)

get parent or array of parents

Parameters:
integer $id
integer $area_id, publication id: if defined search parent only inside the publication
Returns:
mixed integer, if only one parent founded array, if two or more parents founded false, error or none parent founded

Definition at line 97 of file tree.php.

Referenced by getParents().

Tree::getParents ( id = null,
area_id = null,
status = array() 
)

Array of objcet $id tree parents objects.

Parameters:
integer $id
Returns:
array, parent ids (may be empty)

Definition at line 150 of file tree.php.

References getParent().

Referenced by updateTree().

Tree::getPriority ( id,
idParent 
)

object position in a tree branch

Parameters:
int $id object id
int $idParent parent object (branch) id
Returns:
int

Definition at line 386 of file tree.php.

Tree::getRootForSection ( id  ) 

Return id of publication that contains the section, by id.

Parameters:
int $id
Returns:
int

Definition at line 209 of file tree.php.

Referenced by getAllRoots().

Tree::isOnTree ( id,
area_id = null,
status = array() 
)

check if an object is on the tree

Parameters:
integer $id
integer $area_id if defined check if the object is a descendant of a publication
Returns:
boolean

Definition at line 588 of file tree.php.

Tree::isParent ( idParent,
id 
)

check if $idParent is an ancestor

Parameters:
integer $idParent
integer $id
Returns:
boolean

Definition at line 566 of file tree.php.

Referenced by move().

Tree::move ( idNewParent,
idOldParent,
id 
)

move branch to another parent

Parameters:
int $idNewParent
int $idOldParent
int $id
Returns:
boolean

Definition at line 400 of file tree.php.

References getAreaIdByPath(), and isParent().

Tree::movePriority ( id,
idParent,
up = true 
)

move up or down a leaf tree inside a branch

Parameters:
int $id object id to move
int $idParent parent object (branch)
boolean $up true move up (priority - 1), false move down (priority + 1)
Returns:
boolean

Definition at line 279 of file tree.php.

Referenced by movePriorityDown(), and movePriorityUp().

Tree::movePriorityDown ( id,
idParent 
)

move down a leaf tree inside a branch

Parameters:
int $id to move
int $idParent parent object (branch)
Returns:
boolean

Definition at line 340 of file tree.php.

References movePriority().

Tree::movePriorityUp ( id,
idParent 
)

move up a leaf tree inside a branch

Parameters:
int $id to move
int $idParent parent object (branch)
Returns:
boolean

Definition at line 329 of file tree.php.

References movePriority().

Tree::relatedObjectsOnTree ( id,
array $  options = array() 
)

Return a list of a count (based on $option['count']) of related object to $id that are on tree.

$options can contain

  • 'area_id' to filter on publication
  • 'status' to filter on object status
  • 'count' (default false) to get a count or a list of object ids
  • 'relation' to filter on relation name
Parameters:
int $id the object id
array $options
Returns:
array|int

Definition at line 631 of file tree.php.

Tree::removeBranch ( id  ) 

Removes a full branch that originates from the element with passed `$id`.

Parameters:
int $id ID of element to remove.
Returns:
bool `true` if everything was ok, `false` otherwise.
Exceptions:
BeditaException Throws an exception if attempting to remove a leaf (or a branch generated by an object that should be a leaf instead!), or an ubiquitous branch.

Definition at line 908 of file tree.php.

References removeChild().

Referenced by removeTree().

Tree::removeChild ( id,
idParent 
)

remove a leaf tree from a branch

Parameters:
int $id to remove
int $idParent parent object (branch)
Returns:
boolean

Definition at line 351 of file tree.php.

Referenced by removeBranch(), and updateTree().

Tree::removeTree ( id  ) 

Removes a full tree that originates from the element with passed `$id`.

This method is an alias of `TreeremoveBranch()`.

Parameters:
int $id ID of element to remove.
Returns:
bool `true` if everything was ok, `false` otherwise.
Exceptions:
BeditaException Throws an exception if attempting to remove a non-root element, a leaf (or a tree generated by an object that should be a leaf instead!), or an ubiquitous tree (?!).
See also:
Tree::removeBranch()

Definition at line 1006 of file tree.php.

References removeBranch().

Tree::saveMenuVisibility ( ids,
parent_id,
menu = null 
)

save Tree.menu field to set menu and canonical path visibility

Parameters:
mixed $ids, id or array of ids on which save menu field. if it's an array cycles on ids and save $menu value foreach of them
int $parent_id
mixed $menu, can be 1, 0 or null if it's null the default value for every object is used (section = 1, other objects = 0)
Exceptions:
BeditaException 

Definition at line 749 of file tree.php.

Tree::setPriority ( id,
priority,
idParent 
)

set position for a leaf tree in a branch

Parameters:
int $id to move
int $idParent parent object (branch)
Returns:
boolean

Definition at line 363 of file tree.php.

Referenced by cloneStructure(), and copyContentsToBranch().

Tree::updateTree ( id,
destination,
array $  options = array() 
)

Update tree position of object $id with new $destination array.

To update tree:

  • all parents are taken
  • ids in all parents that missing from $destination are removed
  • ids in $destination that missing from all parents are added

With $options you can limit the parents taken

Possible values are:

  • `area_id` to limit parents to some publication.
  • `status` to limit parents with specific status
Parameters:
integer $id
array $options
array $destination

Definition at line 182 of file tree.php.

References appendChild(), getParents(), and removeChild().


The documentation for this class was generated from the following file:
Generated on Fri Dec 11 2015 15:29:47 by Doxygen 1.7.1  BEditaBEdita 3.7 Corylus