Back to Joomla project (class list)

Class Nested - list of methods

Table class supporting modified pre-order tree traversal behavior.

Extends

Direct known subclasses

Package: Joomla\CMS\Table
Copyright: (C) 2009 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Table/Nested.php
Project: Joomla

Method Summary

public void
(mixed $level)

Sets the debug level on or off
Parameters
  • int $level 0 = off, 1 = on
Returns
  • void
Since
  • 1.7.0
Show source code of this method: debug Source Code

public mixed
(mixed $pk = null, mixed $diagnostic = false)

Method to get an array of nodes from a given node to its root.
Parameters
  • int $pk Primary key of the node for which to get the path.
  • bool $diagnostic Only select diagnostic data for the nested sets.
Returns
  • mixed An array of node objects including the start node.
Since
  • 1.7.0
-
  • \RuntimeException on database error
Show source code of this method: getPath Source Code

public mixed
(mixed $pk = null, mixed $diagnostic = false)

Method to get a node and all its child nodes.
Parameters
  • int $pk Primary key of the node for which to get the tree.
  • bool $diagnostic Only select diagnostic data for the nested sets.
Returns
  • mixed Boolean false on failure or array of node objects on success.
Since
  • 1.7.0
-
  • \RuntimeException on database error.
Show source code of this method: getTree Source Code

public bool
(mixed $pk = null)

Method to determine if a node is a leaf node in the tree (has no children).
Parameters
  • int $pk Primary key of the node to check.
Returns
  • bool True if a leaf node, false if not or null if the node does not exist.
Since
  • 1.7.0
-
  • Since 3.0.0 this method returns null if the node does not exist.
  • \RuntimeException on database error.
Show source code of this method: isLeaf Source Code

public void
(mixed $referenceId, mixed $position = 'after')

Method to set the location of a node in the tree object. This method does not save the new location to the database, but will set it in the object so that when the node is stored it will be stored in the new location.
Parameters
  • int $referenceId The primary key of the node to reference new location by.
  • string $position Location type string.
Returns
  • void
Since
  • 1.7.0
-
  • Since 3.0.0 this method returns void and throws an \InvalidArgumentException when an invalid position is passed.
  • \Joomla\CMS\Table\Nested::$_validLocations
  • \InvalidArgumentException
Show source code of this method: setLocation Source Code

public mixed
(mixed $delta, mixed $where = '')

Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
Parameters
  • int $delta The direction and magnitude to move the row in the ordering sequence.
  • string $where WHERE clause to use for limiting the selection of rows to compact the ordering values.
Returns
  • mixed Boolean true on success.
Since
  • 1.7.0
Show source code of this method: move Source Code

public bool
(mixed $referenceId, mixed $position = 'after', mixed $pk = null, mixed $recursiveUpdate = true)

Method to move a node and its children to a new location in the tree.
Parameters
  • int $referenceId The primary key of the node to reference new location by.
  • string $position Location type string. ['before', 'after', 'first-child', 'last-child']
  • int $pk The primary key of the node to move.
  • bool $recursiveUpdate Flag indicate that method recursiveUpdatePublishedColumn should be call.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \RuntimeException on database error.
Show source code of this method: moveByReference Source Code

public bool
(mixed $pk = null, mixed $children = true)

Method to delete a node and, optionally, its child nodes from the table.
Parameters
  • int $pk The primary key of the node to delete.
  • bool $children True to delete child nodes, false to move them up a level.
Returns
  • bool True on success.
Since
  • 1.7.0
Show source code of this method: delete Source Code

public bool
()

Checks that the object is valid and able to be stored.
Returns
  • bool True if all checks pass.
Since
  • 1.7.0
Show source code of this method: check Source Code

public bool
(mixed $updateNulls = false)

Method to store a node in the database table.
Parameters
  • bool $updateNulls True to update null values as well.
Returns
  • bool True on success.
Since
  • 1.7.0
Show source code of this method: store Source Code

public bool
(mixed $pks = null, mixed $state = 1, mixed $userId = 0)

Method to set the publishing state for a node or list of nodes in the database table. The method respects rows checked out by other users and will attempt to checkin rows that it can after adjustments are made. The method will not allow you to set a publishing state higher than any ancestor node and will not allow you to set a publishing state on a node with a checked out child.
Parameters
  • mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
  • int $state The publishing state. eg. [0 = unpublished, 1 = published]
  • int $userId The user id of the user performing the operation.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: publish Source Code

public bool
(mixed $pk)

Method to move a node one position to the left in the same level.
Parameters
  • int $pk Primary key of the node to move.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \RuntimeException on database error.
Show source code of this method: orderUp Source Code

public bool
(mixed $pk)

Method to move a node one position to the right in the same level.
Parameters
  • int $pk Primary key of the node to move.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \RuntimeException on database error.
Show source code of this method: orderDown Source Code

public mixed
()

Gets the ID of the root item in the tree
Returns
  • mixed The primary id of the root row, or false if not found and the internal error is set.
Since
  • 1.7.0
Show source code of this method: getRootId Source Code

public int
(mixed $parentId = null, mixed $leftId = 0, mixed $level = 0, mixed $path = '')

Method to recursively rebuild the whole nested set tree.
Parameters
  • int $parentId The root of the tree to rebuild.
  • int $leftId The left id to start with in building the tree.
  • int $level The level to assign to the current nodes.
  • string $path The path to the current nodes.
Returns
  • int 1 + value of root rgt on success, false on failure
Since
  • 1.7.0
-
  • \RuntimeException on database error.
Show source code of this method: rebuild Source Code

public bool
(mixed $pk = null)

Method to rebuild the node's path field from the alias values of the nodes from the current node to the root node of the tree.
Parameters
  • int $pk Primary key of the node for which to get the path.
Returns
  • bool True on success.
Since
  • 1.7.0
Show source code of this method: rebuildPath Source Code

public void
()

Method to reset class properties to the defaults set in the class definition. It will ignore the primary key as well as any private class properties (except $_errors).
Returns
  • void
Since
  • 3.2.1
Show source code of this method: reset Source Code

public int|bool
(mixed $idArray = null, mixed $lftArray = null)

Method to update order of table rows
Parameters
  • array $idArray id numbers of rows to be reordered.
  • array $lftArray lft values of rows to be reordered.
Returns
  • int|bool 1 + value of root rgt on success, false on failure.
Since
  • 1.7.0
-
  • \Exception on database error.
Show source code of this method: saveorder Source Code

protected bool
(mixed $pk, mixed $newState = null)

Method to recursive update published column for children rows.
Parameters
  • int $pk Id number of row which published column was changed.
  • int $newState An optional value for published column of row identified by $pk .
Returns
  • bool True on success.
Since
  • 3.7.0
-
  • \RuntimeException on database error.
Show source code of this method: recursiveUpdatePublishedColumn Source Code

protected mixed
(mixed $id, mixed $key = null)

Method to get nested set properties for a node in the tree.
Parameters
  • int $id Value to look up the node by.
  • string $key An optional key to look up the node by (parent | left | right). If omitted, the primary key of the table is used.
Returns
  • mixed Boolean false on failure or node object on success.
Since
  • 1.7.0
-
  • \RuntimeException on database error.
Show source code of this method: _getNode Source Code

protected mixed
(mixed $referenceNode, mixed $nodeWidth, mixed $position = 'before')

Method to get various data necessary to make room in the tree at a location for a node and its children. The returned data object includes conditions for SQL WHERE clauses for updating left and right id values to make room for the node as well as the new left and right ids for the node.
Parameters
  • object $referenceNode A node object with at least a 'lft' and 'rgt' with which to make room in the tree around for a new node.
  • int $nodeWidth The width of the node for which to make room in the tree.
  • string $position The position relative to the reference node where the room should be made.
Returns
  • mixed Boolean false on failure or data object on success.
Since
  • 1.7.0
Show source code of this method: _getTreeRepositionData Source Code

protected void
(mixed $showData = true, mixed $showQuery = true)

Method to create a log table in the buffer optionally showing the query and/or data.
Parameters
  • bool $showData True to show data
  • bool $showQuery True to show query
Returns
  • void
Since
  • 1.7.0
-
Show source code of this method: _logtable Source Code

protected void
(mixed $query, mixed $errorMessage)

Runs a query and unlocks the database on an error.
Parameters
  • mixed $query A string or DatabaseQuery object.
  • string $errorMessage Unused.
Returns
  • void
Since
  • 1.7.0
-
  • Since 3.0.0 this method returns void and will rethrow the database exception.
  • \Exception on database error.
Show source code of this method: _runQuery Source Code

Properties Summary

public int
$parent_id
Object property holding the primary key of the parent node. Provides adjacency list data for nodes.
Since
  • 1.7.0
public int
$level
Object property holding the depth level of the node in the tree.
Since
  • 1.7.0
public int
$lft
Object property holding the left value of the node for managing its placement in the nested sets tree.
Since
  • 1.7.0
public int
$rgt
Object property holding the right value of the node for managing its placement in the nested sets tree.
Since
  • 1.7.0
public string
$alias
Object property holding the alias of this node used to construct the full text path, forward-slash delimited.
Since
  • 1.7.0
protected string
$_location
Object property to hold the location type to use when storing the row.
Since
  • 1.7.0
-
  • string
protected int
$_location_id
Object property to hold the primary key of the location reference node to use when storing the row.
Since
  • 1.7.0
protected array
$_cache
An array to cache values in recursive processes.
Since
  • 1.7.0
protected int
$_debug
Debug level
Since
  • 1.7.0
protected static int
$root_id
Cache for the root ID
Since
  • 3.3
private array
$_validLocations
Array declaring the valid location values for moving a node
Since
  • 3.7.0

Tags Summary

Since
1.7.0