BEdita API doc | 4-cactus
  • Class
  • Tree
  • Deprecated
  • Download

Classes

  • Addon
  • AddressbookController
  • AddressbookShell
  • AdminController
  • Alias
  • Annotation
  • ApiAuthComponent
  • ApiBaseController
  • ApiFormatterComponent
  • ApiUploadComponent
  • ApiValidatorComponent
  • AppController
  • AppError
  • AppHelper
  • Application
  • AppModel
  • Area
  • AreasController
  • Audio
  • AuthenticationsController
  • BannedIp
  • BEAppModel
  • BEAppObjectModel
  • BeAuthComponent
  • BeAuthFacebookComponent
  • BeAuthGoogleComponent
  • BeAuthTwitterComponent
  • BeCallbackManager
  • BeConfigure
  • BeCustomPropertyComponent
  • BeditaAnnotationModel
  • BeditaBaseShell
  • BeditaCollectionModel
  • BeditaContentModel
  • BeditaExportFilter
  • BeditaImportFilter
  • BeditaObjectModel
  • BeditaProductModel
  • BeditaShell
  • BeditaSimpleObjectModel
  • BeditaSimpleStreamModel
  • BeditaStreamModel
  • BeEmbedFlashHelper
  • BeEmbedHtml5Helper
  • BeEmbedMediaHelper
  • BeErrorCode
  • BeExceptionHandler
  • BEFile
  • BeFileHandlerComponent
  • BeFormHelper
  • BeFrontHelper
  • BeHashComponent
  • BeHtmlHelper
  • BeLangTextComponent
  • BeLib
  • BeMailComponent
  • BEObject
  • BeObjectCache
  • BePaginatorToolbarHelper
  • BeSchema
  • BeSecurityComponent
  • BeSystem
  • BeSystemComponent
  • BeThumb
  • BeTimeHelper
  • BeToolbarHelper
  • BeTreeComponent
  • BeTreeHelper
  • BeUploadToObjComponent
  • BeurlHelper
  • BeVimeoComponent
  • BeYoutubeComponent
  • BuildFilterBehavior
  • CacheableBehavior
  • CacheShell
  • CallbackBehavior
  • CaptchaComponent
  • Caption
  • CaptionsBehavior
  • Card
  • CardsImportFilter
  • Category
  • CleanupDataTask
  • CleanupTask
  • Comment
  • CommentsController
  • CompactResultBehavior
  • Content
  • CreateIndexFieldsBehavior
  • DataShell
  • DataTransfer
  • DateItem
  • DbadminShell
  • DeleteDependentObjectBehavior
  • DeleteObjectBehavior
  • DeployShell
  • Document
  • DocumentsController
  • DumpModel
  • EditorialContentsShell
  • EditorNote
  • Event
  • EventLog
  • EventsController
  • FilesController
  • ForeignDependenceSaveBehavior
  • FrontendController
  • FrontendShell
  • GalleriesController
  • Gallery
  • GeoTag
  • GettextShell
  • Git
  • GravatarHelper
  • Group
  • HashJob
  • History
  • HomeController
  • Image
  • ImageInfoHelper
  • JsonExportFilter
  • JsonImportFilter
  • JsonView
  • LangText
  • Link
  • MailGroup
  • MailGroupCard
  • MailJob
  • MailLog
  • MailMessage
  • MailShell
  • MailTemplate
  • Mask
  • MediaShell
  • MigrateDumpModel
  • MigrateShell
  • Migration
  • MigrationBase
  • MigrationDateItemsShell
  • Module
  • ModulesController
  • ModuleShell
  • MultimediaController
  • NewsController
  • NewsletterController
  • NewsletterShell
  • NotifyBehavior
  • ObjectEditor
  • ObjectProperty
  • ObjectRelation
  • ObjectType
  • ObjectUser
  • PagesController
  • Permission
  • PermissionModule
  • PermsHelper
  • Product
  • Property
  • PropertyOption
  • PublicationShell
  • RedisShell
  • RelationCheck
  • RelationRepair
  • RelationShell
  • RelationStats
  • RemoveDummyNameBehavior
  • ResponseHandlerComponent
  • RestClientModel
  • Revision
  • RevisionObjectBehavior
  • SearchText
  • SearchTextSaveBehavior
  • Section
  • SectionDummy
  • SessionFilterComponent
  • SessionFilterHelper
  • ShortNews
  • SmartyView
  • SoapClientModel
  • SplitterSql
  • StatisticsController
  • Stream
  • StreamLog
  • StreamsController
  • Svn
  • TagsController
  • ThemeSmartyView
  • ThumbnailHelper
  • ThumbShell
  • TransactionComponent
  • TransactionFS
  • TranslationsController
  • Tree
  • TrHelper
  • User
  • UserProperty
  • UsersController
  • Utility
  • Version
  • Video
  • VimeoHelper
  • WebmarksController
  • XmlExportFilter
  • XmlImportFilter
  • XmlJsonConverter
  • XmlView
  • YoutubeHelper

Interfaces

  • ApiAuthInterface
  • MediaProviderInterface
  • UploadableInterface

Exceptions

  • BeditaAjaxException
  • BEditaAllowURLException
  • BeditaBadRequestException
  • BeditaConflictException
  • BEditaDeleteStreamObjException
  • BeditaException
  • BEditaFileExistException
  • BeditaForbiddenException
  • BeditaFrontAccessException
  • BeditaHashException
  • BEditaInfoException
  • BeditaInternalErrorException
  • BEditaIOException
  • BeditaLengthRequiredException
  • BeditaMailException
  • BEditaMediaProviderException
  • BeditaMethodNotAllowedException
  • BEditaMIMEException
  • BeditaNotFoundException
  • BeditaNotImplementedException
  • BeditaPublicationException
  • BeditaRuntimeException
  • BEditaSaveStreamObjException
  • BeditaServiceUnavailableException
  • BeditaUnauthorizedException
  • BEditaUploadPHPException
  • BEditaURLException

Class Tree

Tree operations model

Model
Extended by AppModel
Extended by BEAppModel
Extended by Tree
Located at models/tree.php

Methods summary

public
# __construct( )
public boolean
# isUniqueSection( array $check )

Custom validation rule to verify that a branch node (section, publication) is not already on the tree. A section must stay only in one tree node.

Custom validation rule to verify that a branch node (section, publication) is not already on the tree. A section must stay only in one tree node.

Parameters

$check
The array to validate

Returns

boolean
public boolean
# beforeSave( )

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

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

Returns

boolean
public mixed integer,
# getParent( integer $id, integer $area_id = null, $status = array() )

get parent or array of parents

get parent or array of parents

Parameters

$id
$area_id
$area_id, publication id: if defined search parent only inside the publication
$status

Returns

mixed integer,

integer, if only one parent found array, if two or more parents found false, error or none parent found

public array,
# getParents( integer|null $id = null, integer|null $area_id = null, array $status = array(), boolean $useCache = true )

Array of object $id tree parents objects

Array of object $id tree parents objects

If $useCache is true it will try to read/write from/to cache

Parameters

$id
The child id
$area_id
The publication (area) id
$status
An array of object status that parent must have
$useCache
If it has to use cache (true default)

Returns

array,
parent ids (may be empty)
public
# updateTree( integer $id, array|integer $destination, array $options = array() )

Update tree position of object $id with new $destination 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. - mantain_hidden_branch if hidden branches are to mantain. Default true.

Parameters

$id
The object id
$destination
An array of parents or a parent.
$options
Options.

Throws

BeditaException
If $id is an area or a section with too much destination.
BeditaBadRequestException
If errors happen moving a section.
public integer
# getRootForSection( integer $id )

Return id of publication that contains the section, by id

Return id of publication that contains the section, by id

Parameters

$id

Returns

integer
public boolean
# appendChild( integer $id, integer|null $idParent = null, integer|null $priority = null )

Append an object to a parent.

Append an object to a parent.

Parameters

$id
Child object's ID.
$idParent
Parent object's ID (null for roots).
$priority
Priority in children's list (null to append as last child).

Returns

boolean

See

Tree::appendChildWorker()
protected boolean
# appendChildWorker( integer $id, integer $idParent = null, integer $priority = null )

append an object to a parent in tree

append an object to a parent in tree

Parameters

$id
object id
$idParent
parent object id
$priority
if not passed append as last child else use passed position

Returns

boolean
public integer
# getAreaIdByPath( string $path )

Return id of publication by path

Return id of publication by path

Parameters

$path

Returns

integer
public boolean
# movePriority( integer $id, integer $idParent, boolean $up = true )

move up or down a leaf tree inside a branch

move up or down a leaf tree inside a branch

Parameters

$id
object id to move
$idParent
parent object (branch)
$up
true move up (priority - 1), false move down (priority + 1)

Returns

boolean
public boolean
# movePriorityUp( integer $id, integer $idParent )

move up a leaf tree inside a branch

move up a leaf tree inside a branch

Parameters

$id
to move
$idParent
parent object (branch)

Returns

boolean
public boolean
# movePriorityDown( integer $id, integer $idParent )

move down a leaf tree inside a branch

move down a leaf tree inside a branch

Parameters

$id
to move
$idParent
parent object (branch)

Returns

boolean
public boolean
# removeChild( integer $id, integer $idParent )

Remove a leaf node from a tree.

Remove a leaf node from a tree.

Parameters

$id
Leaf node ID.
$idParent
Parent node ID.

Returns

boolean

See

Tree::removeChildWorker()
protected boolean
# removeChildWorker( integer $id, integer $idParent )

remove a leaf tree from a branch

remove a leaf tree from a branch

Parameters

$id
to remove
$idParent
parent object (branch)

Returns

boolean
public boolean
# setPriority( integer $id, integer $priority, $idParent )

set position for a leaf tree in a branch

set position for a leaf tree in a branch

Parameters

$id
to move
$priority
$idParent parent object (branch)
$idParent

Returns

boolean
public integer
# getPriority( integer $id, integer $idParent )

object position in a tree branch

object position in a tree branch

Parameters

$id
object id
$idParent
parent object (branch) id

Returns

integer
public boolean
# move( integer $idNewParent, integer $idOldParent, integer $id )

Move branch to another parent.

Move branch to another parent.

Parameters

$idNewParent
The new parent id.
$idOldParent
The old parent id.
$id
The object id to move.

Returns

boolean
public array
# getAllRoots( integer $userid = null, mixed $status = null, array $filter = array(), array $expandBranch = array() )

get all tree roots objects (publications)

get all tree roots objects (publications)

Parameters

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

Returns

array
public array
# getAll( integer $id = null, string $userid = null, string $status = null, array $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

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

$id
publication id. If null get all trees, one for every publication
$userid
user. if null: no permission check (default); if '': guest user
$status
only objs with this status
$filter
see BEAppModel::findObjects

Returns

array
every first level key is a publication
public array
# buildTree( array $items )

Return a tree build for the items passed

Return a tree build for the items passed

Parameters

$items

Returns

array
private
# putBranchInTree( array & $tree, array $branch )

search where have to stay $branch in $tree and put in

search where have to stay $branch in $tree and put in

Parameters

$tree
$branch
to put in tree
public boolean
# isParent( integer $idParent, integer $id )

check if $idParent is an ancestor

check if $idParent is an ancestor

Parameters

$idParent
$id

Returns

boolean
public array
# titlesPaths( integer $id, array $hiddenBranchIds = array() )

Titles paths for branches related to $id passed Returns array, each element is like: [ { 'ids' => [223481, 274603], // array of integers 'parentId' => 274603, // integer parent id 'idsPath' => '/223481/274603', // string representing ids path 'titles' => [ 223481 => 'Publication A', // publication title 274603 => 'Section B' // section title ], 'titlesPath' => 'Publication A > Section B' // string that concats titles },, // ... ]

Titles paths for branches related to $id passed Returns array, each element is like: [ { 'ids' => [223481, 274603], // array of integers 'parentId' => 274603, // integer parent id 'idsPath' => '/223481/274603', // string representing ids path 'titles' => [ 223481 => 'Publication A', // publication title 274603 => 'Section B' // section title ], 'titlesPath' => 'Publication A > Section B' // string that concats titles },, // ... ]

Parameters

$id
object id
$hiddenBranchIds
ids

Returns

array
tree descriptive data
public boolean
# isOnTree( integer $id, integer $area_id = null, $status = array() )

check if an object is on the tree

check if an object is on the tree

Parameters

$id
$area_id
if defined check if the object is a descendant of a publication
$status

Returns

boolean
public array|integer
# relatedObjectsOnTree( integer $id, array $options = array() )

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

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

$id
the object id
$options

Returns

array|integer
public array
# getChildren( integer $id = null, string $userid = null, string $status = null, array $filter = array(), string $order = null, boolean $dir = true, integer $page = 1, integer $dim = null, array $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.

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

$id
root id
$userid
user: null (default) => no permission check. ' ' => guest/anonymous user,
$status
object status
$filter

Filter: object types, search text query, eg. array(21, 22, "search" => "text to search"). Default: all object types

$order
field to order result (id, status, modified..)
$dir
true (default), ascending, otherwiese descending.
$page
Page number (for pagination)
$dim
Page dim (for pagination)
$excludeIds
array of ids to exclude

Returns

array
public array
# getDescendants( integer $id = null, string $userid = null, string $status = null, array $filter = array(), string $order = null, boolean $dir = true, integer $page = 1, integer $dim = null, array $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.

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

$id
root id
$userid
user: null (default) => no permission check. ' ' => guest/anonymous user,
$status
object status
$filter

Filter: object types, search text query, eg. array(21, 22, "search" => "text to search"). Default: all object types

$order
field to order result (id, status, modified..)
$dir
true (default), ascending, otherwiese descending.
$page
Page number (for pagination)
$dim
Page dim (for pagination)
$excludeIds
array of ids to exclude

Returns

array
public
# saveMenuVisibility( mixed $ids, integer $parent_id, mixed $menu = null )

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

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

Parameters

$ids

$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

$parent_id
$menu

$menu, can be 1, 0 or null if it's null the default value for every object is used (section = 1, other objects = 0)

Throws

BeditaException
public array,
# cloneStructure( integer $id, array $options = array() )

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

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

Parameters

$id
$id, publication/section id
$options
$options, see BEAppObjectModel::arrangeDataForClone()

Returns

array,
contain couple of original id and cloned id

Throws

BeditaException
public
# copyContentsToBranch( integer $originalBranchId, integer $newBranchId )

copy contents from a branch to another brnach

copy contents from a branch to another brnach

Parameters

$originalBranchId
$originalBranchId, branch (publication/section) id where the contents are
$newBranchId
$newBranchId, branch (publication/section) id where the contents have to be copied

Throws

BeditaException
public array
# countUbiquity( array $objects, array $options = array() )

Add to array of BEdita objects a count of ubiquity

Add to array of BEdita objects a count of ubiquity

Parameters

$objects
$options

Returns

array
public
# removeBranch( $id )
public boolean
# removeTree( integer $id )

Removes a full tree that originates from the element with passed $id. This method is an alias of Tree::removeBranch().

Removes a full tree that originates from the element with passed $id. This method is an alias of Tree::removeBranch().

Parameters

$id
ID of element to remove.

Returns

boolean
true if everything was ok, false otherwise.

Throws

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

Tree::removeBranch()
public integer
# countChildrenContents( integer $parentId, array $options = array() )

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

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

Parameters

$parentId
the parent id
$options

Returns

integer

See

self::countChildren()
public integer
# countChildrenSections( integer $parentId, array $options = array() )

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

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

Parameters

$parentId
the parent id
$options

Returns

integer

See

self::countChildren()
public integer
# countChildren( integer $parentId, array $options = array() )

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

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

Parameters

$parentId
the parent id
$options

Returns

integer
public array
# findChildrenList( integer $parentId, boolean $descendants = false )

Return a list of children ids

Return a list of children ids

Parameters

$parentId
The parent id
$descendants
True to get all descendants, false to get just children

Returns

array
protected
# dispatchUpdatedTreeEvent( integer $id, string $eventType )

Dispatch event to notify that tree has been updated for an object.

Dispatch event to notify that tree has been updated for an object.

Parameters

$id
ID of object whose position in tree has been updated.
$eventType
Name of event to dispatch. Should be one of static::EVENT_* constants.

Methods inherited from BEAppModel

am(), buildQueryStatement(), checkDate(), checkDuration(), checkFloat(), checkNumber(), containLevel(), email(), fieldsString(), findObjects(), findObjectsAfterFilter(), findObjectsClauses(), findObjectsCount(), getBindingsLevel(), getDefaultDateFormat(), getDriver(), getEndQuote(), getLimitClausole(), getStartQuote(), setBindingsLevel(), setupDbParams(), toolbar()

Methods inherited from AppModel

apiTransformer()

Constants summary

string EVENT_PARENTS_UPDATED

Name of event dispatched when an object's parents are updated.

Name of event dispatched when an object's parents are updated.

# 'Tree.parentsUpdated'
string EVENT_CHILDREN_UPDATED

Name of event dispatched when a node's children are updated.

Name of event dispatched when a node's children are updated.

# 'Tree.childrenUpdated'

Properties summary

public string $primaryKey
# "object_path"
protected $BeObjectCache

Object cache

Object cache

# null
public array $validate
# array( 'id' => array( 'rule' => 'isUniqueSection', 'message' => 'Ubiquitous sections/publications are not allowed', ), )

Properties inherited from BEAppModel

$actsAs, $driver, $eQ, $modelBindings, $sQ

Properties inherited from AppModel

$apiTransformerOptions

BEdita API doc | 4-cactus API documentation generated by ApiGen