cms_content_tree
extends cms_tree
in package
A tree class that allows backward compatibility (somewhat) to the old Tree class used in CMSMS versions prior to 1.9, and provides content retrieval abilities, with interface into the content cache.
Tags
Table of Contents
Methods
- __construct() : mixed
- Construct a new tree, or node of a tree.
- add_node() : mixed
- Add the specified node as a child to this node.
- addNode() : mixed
- Add a node to the tree
- count_children() : int
- Count the number of direct children to this node.
- count_nodes() : int
- Count the total number of all nodes, including myself.
- count_siblings() : int
- Count the number of siblings that this node has.
- find_by_tag() : cms_tree
- Find a tree node given a specfied tag and value.
- get_children() : an
- Return the children of this node.
- get_level() : int
- Find the depth of the current node.
- get_parent() : cms_tree
- Get a reference to the parent node.
- get_tag() : mixed
- Retrieve a tag for this node.
- getChildren() : array<string|int, mixed>
- Get the children for this node.
- getChildrenCount() : int
- Count the number of children
- getContent() : mixed
- Retrieve the content object associated with this node.
- getFlatList() : array<string|int, mixed>
- A function to build an array of cms_tree nodes, containing this node and all of the children.
- getHierarchy() : string
- Get the hierarchy position of this node
- getId() : int
- Get this nodes id.
- getLevel() : int
- Get this nodes depth in the tree
- getNodeByAlias() : cms_content_tree
- Retrieve a node by it's alias
- getNodeByHierarchy() : cms_content_tree
- Retrieve a node by hierarchy position.
- getNodeById() : cms_content_tree
- Retrieve a node by it's id.
- getParent() : cms_tree
- Get a reference to the parent node.
- getParentNode() : cms_tree
- Get this nodes parent.
- getSiblingCount() : int
- Count the number of siblings
- getTag() : mixed
- Get a node tag.
- has_children() : bool
- Test if this node has children.
- hasChildren() : bool
- Test if this node has children.
- isContentCached() : bool
- A method to indicate wether the content object for this node is cached.
- remove() : bool
- Remove this node
- set_tag() : mixed
- Set a tag value into this node
- setTag() : mixed
- Set a tag value
- sureGetNodeByAlias() : cms_content_tree
- Retrieve a node by it's alias
- sureGetNodeById() : cms_content_tree
- Retrieve a node by it's id.
- remove_node() : bool
- Remove the specified node from the tree.
- _getPeerIndex() : string
- A recursive method to find the (estimated) hierarchy position of this node.
Methods
__construct()
Construct a new tree, or node of a tree.
public
__construct([string $key = '' ][, mixed $value = '' ]) : mixed
Parameters
- $key : string = ''
-
An optional key for a tag
- $value : mixed = ''
-
An optional value for the tag.
add_node()
Add the specified node as a child to this node.
public
add_node(cms_tree &$node) : mixed
Parameters
- $node : cms_tree
-
The node to add
addNode()
Add a node to the tree
public
addNode(cms_content_tree &$node) : mixed
A backwards compatibility method.
Parameters
- $node : cms_content_tree
Tags
count_children()
Count the number of direct children to this node.
public
count_children() : int
Return values
intcount_nodes()
Count the total number of all nodes, including myself.
public
count_nodes() : int
Return values
intcount_siblings()
Count the number of siblings that this node has.
public
count_siblings() : int
Return values
intfind_by_tag()
Find a tree node given a specfied tag and value.
public
& find_by_tag(string $tag_name, mixed $value[, bool $case_insensitive = FALSE ][, bool $usequick = TRUE ]) : cms_tree
Parameters
- $tag_name : string
-
The tag name to search for
- $value : mixed
-
The tag value to search for
- $case_insensitive : bool = FALSE
-
Wether the value should be treated as case insensitive.
- $usequick : bool = TRUE
-
Optionally, when searching by id... uise the quickfind method if possible.
Return values
cms_treeget_children()
Return the children of this node.
public
& get_children() : an
Return values
an —array of cms_tree objects, or null if there are no children.
get_level()
Find the depth of the current node.
public
get_level() : int
This method counts all of the parents in the tree until there are no more parents.
Return values
intget_parent()
Get a reference to the parent node.
public
& get_parent() : cms_tree
Tags
Return values
cms_tree —Reference to the parent node, or null.
get_tag()
Retrieve a tag for this node.
public
& get_tag(string $key) : mixed
Parameters
- $key : string
-
The tag name
Return values
mixed —The tag value, or null
getChildren()
Get the children for this node.
public
& getChildren([bool $deep = false ][, bool $all = false ][, bool $loadcontent = true ]) : array<string|int, mixed>
This method will retrieve a list of the children of this node, loading their content objects at the same time (as a preformance enhancement).
This method takes advantage of the content cache.
Parameters
- $deep : bool = false
-
Optionally load the properties of the children (only used when loadcontent is true)
- $all : bool = false
-
Load all children, including inactive/disabled ones (only used when loadcontent is true)
- $loadcontent : bool = true
-
Load content objects for children
Return values
array<string|int, mixed> —of cms_tree objects.
getChildrenCount()
Count the number of children
public
getChildrenCount() : int
A backwards compatibility function
Tags
Return values
intgetContent()
Retrieve the content object associated with this node.
public
& getContent([bool $deep = false ][, bool $loadsiblings = true ][, bool $loadall = false ]) : mixed
This method will return the content object associated with this node, loading it if necessary, and placing it in the cache for subsequent requests.
Parameters
- $deep : bool = false
-
load all child proeprties for the content object if loading is required.
- $loadsiblings : bool = true
-
load all the siblings for the selected content object at the same time (a preformance optimization)
- $loadall : bool = false
-
If loading siblings, include inactive/disabled pages.
getFlatList()
A function to build an array of cms_tree nodes, containing this node and all of the children.
public
& getFlatList() : array<string|int, mixed>
Return values
array<string|int, mixed> —of cms_tree nodes.
getHierarchy()
Get the hierarchy position of this node
public
getHierarchy() : string
Return values
stringgetId()
Get this nodes id.
public
getId() : int
A backwards compatibility method
Tags
Return values
int —The node id.
getLevel()
Get this nodes depth in the tree
public
getLevel() : int
A backwards compatibility function
Tags
Return values
intgetNodeByAlias()
Retrieve a node by it's alias
public
getNodeByAlias(string $alias) : cms_content_tree
A backwards compatibility method.
Parameters
- $alias : string
Return values
cms_content_treegetNodeByHierarchy()
Retrieve a node by hierarchy position.
public
getNodeByHierarchy(string $position) : cms_content_tree
Parameters
- $position : string
Return values
cms_content_tree —or null.
getNodeById()
Retrieve a node by it's id.
public
getNodeById(int $id) : cms_content_tree
A backwards compatibility method.
Parameters
- $id : int
Return values
cms_content_treegetParent()
Get a reference to the parent node.
public
& getParent() : cms_tree
Return values
cms_tree —Reference to the parent node, or null.
getParentNode()
Get this nodes parent.
public
& getParentNode() : cms_tree
A backwards compatibility method
Tags
Return values
cms_tree —or null.
getSiblingCount()
Count the number of siblings
public
getSiblingCount() : int
A backwards compatibility function
Tags
Return values
intgetTag()
Get a node tag.
public
& getTag([string $key = 'id' ]) : mixed
A backwards compatibility method
Parameters
- $key : string = 'id'
-
Tag name/key
Tags
Return values
mixed —Node value.
has_children()
Test if this node has children.
public
has_children() : bool
Return values
boolhasChildren()
Test if this node has children.
public
hasChildren() : bool
A backwards compatibility method.
Tags
Return values
boolisContentCached()
A method to indicate wether the content object for this node is cached.
public
isContentCached() : bool
Return values
boolremove()
Remove this node
public
remove() : bool
This is a convenience method that calls remove_node on the current object.
Return values
boolset_tag()
Set a tag value into this node
public
set_tag(string $key, mixed $value) : mixed
Parameters
- $key : string
-
Tag name
- $value : mixed
-
Tag value
setTag()
Set a tag value
public
setTag(string $key, mixed $value) : mixed
A backwards compatibility method
Parameters
- $key : string
-
The tag name/key
- $value : mixed
-
The tag value
Tags
sureGetNodeByAlias()
Retrieve a node by it's alias
public
sureGetNodeByAlias(string $alias) : cms_content_tree
A backwards compatibility method.
Parameters
- $alias : string
Return values
cms_content_treesureGetNodeById()
Retrieve a node by it's id.
public
sureGetNodeById(int $id) : cms_content_tree
A backwards compatibility method.
Parameters
- $id : int
Return values
cms_content_treeremove_node()
Remove the specified node from the tree.
protected
remove_node(cms_tree &$node[, bool $search_children = false ]) : bool
Search through the children of this node (and optionally recursively through the tree) for the specified node. If found, remove it.
Use this method with caution, as it is very easy to break your tree, corrupt memory and have tree nodes hanging out there with no parents.
Parameters
- $node : cms_tree
-
Reference to the node to be removed.
- $search_children : bool = false
-
Wether to recursively search children.
Return values
bool_getPeerIndex()
A recursive method to find the (estimated) hierarchy position of this node.
private
_getPeerIndex() : string