cms_content_tree View code

Extends \cms_tree

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.

package

CMS

license

GPL

author

Robert Campbell

copyright

Copyright (c) 2010, Robert Campbell calguy1000@cmsmadesimple.org

since 1.9

Methods

find_by_tag(string $tag_name, mixed $value, boolean $case_insensitive = FALSE) : \cms_tree

Find a tree node given a specfied tag and value.

inherited

Arguments

string $tag_name

The tag name to search for

mixed $value

The tag value to search for

boolean $case_insensitive

Wether the value should be treated as case insensitive.

Response

\cms_tree

or null on failure.

sureGetNodeById(integer $id) : \cms_content_tree

Retrieve a node by it's id.

deprecated

A backwards compatibility method.

Arguments

integer $id

Response

\cms_content_tree

getNodeById(integer $id) : \cms_content_tree

Retrieve a node by it's id.

deprecated

A backwards compatibility method.

Arguments

integer $id

Response

\cms_content_tree

sureGetNodeByAlias(string $alias) : \cms_content_tree

Retrieve a node by it's alias

deprecated

A backwards compatibility method.

Arguments

string $alias

Response

\cms_content_tree

getNodeByAlias(string $alias) : \cms_content_tree

Retrieve a node by it's alias

deprecated

A backwards compatibility method.

Arguments

string $alias

Response

\cms_content_tree

getNodeByHierarchy(string $position) : \cms_content_tree

Retrieve a node by hierarchy position.

Arguments

string $position

Response

\cms_content_tree

or null.

hasChildren() : boolean

Test if this node has children.

deprecated

A backwards compatibility method.

Response

boolean

setTag(string $key, mixed $value) 

Set a tag value

deprecated

A backwards compatibility method

Arguments

string $key

The tag name/key

mixed $value

The tag value

getId() : integer

Get this nodes id.

deprecated

A backwards compatibility method

Response

integer

The node id.

getTag(string $key = 'id') : mixed

Get a node tag.

deprecated

A backwards compatibility method

Arguments

string $key

Tag name/key

Response

mixed

Node value.

getParentNode() : \cms_tree

Get this nodes parent.

deprecated

A backwards compatibility method

Response

\cms_tree

or null.

addNode(\cms_content_tree &$node) 

Add a node to the tree

deprecated

A backwards compatibility method.

Arguments

getContent(boolean $deep = false, boolean $loadsiblings = true, boolean $loadall = false) 

Retrieve the content object associated with this node.

This method will return the content object associated with this node, loading it if necessary, and placing it in the cache for subsequent requests.

Arguments

boolean $deep

load all child proeprties for the content object if loading is required.

boolean $loadsiblings

load all the siblings for the selected content object at the same time (a preformance optimization)

boolean $loadall

If loading siblings, include inactive/disabled pages.

getChildrenCount() : integer

Count the number of children

deprecated

A backwards compatibility function

Response

integer

getSiblingCount() : integer

Count the number of siblings

deprecated

A backwards compatibility function

Response

integer

getLevel() : integer

Get this nodes depth in the tree

deprecated

A backwards compatibility function

Response

integer

getChildren(boolean $deep = false, boolean $all = false, boolean $loadcontent = true) : Array

Get the children for this node.

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.

Arguments

boolean $deep

Optionally load the properties of the children (only used when loadcontent is true)

boolean $all

Load all children, including inactive/disabled ones (only used when loadcontent is true)

boolean $loadcontent

Load content objects for children

Response

Array

of cms_tree objects.

getFlatList() : Array

A function to build an array of cms_tree nodes, containing this node and all of the children.

Response

Array

of cms_tree nodes.

isContentCached() : boolean

A method to indicate wether the content object for this node is cached.

Response

boolean

_getPeerIndex() : string

A recursive method to find the (estimated) hierarchy position of this node.

Response

string

getHierarchy() : string

Get the hierarchy position of this node

Response

string

__construct(string $key = '', mixed $value = '') 

Construct a new tree, or node of a tree.

inherited

Arguments

string $key

An optional key for a tag

mixed $value

An optional value for the tag.

has_children() : boolean

Test if this node has children.

inherited

Response

boolean

set_tag(string $key, mixed $value) 

Set a tag value into this node

inherited

Arguments

string $key

Tag name

mixed $value

Tag value

get_tag(string $key) : mixed

Retrieve a tag for this node.

inherited

Arguments

string $key

The tag name

Response

mixed

The tag value, or null

remove_node(\cms_tree &$node, boolean $search_children = false) : boolean

Remove the specified node from the tree.

inherited

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.

Arguments

\cms_tree $node

Reference to the node to be removed.

boolean $search_children

Wether to recursively search children.

Response

boolean

remove() : boolean

Remove this node

inherited

This is a convenience method that calls remove_node on the current object.

Response

boolean

get_parent() : \cms_tree

Get a reference to the parent node.

inherited

Response

\cms_tree

Reference to the parent node, or null.

getParent() : \cms_tree

Get a reference to the parent node.

inherited deprecated

Response

\cms_tree

Reference to the parent node, or null.

add_node(\cms_tree &$node) 

Add the specified node as a child to this node.

inherited

Arguments

\cms_tree $node

The node to add

count_children() : integer

Count the number of direct children to this node.

inherited

Response

integer

count_siblings() : integer

Count the number of siblings that this node has.

inherited

Response

integer

count_nodes() : integer

Count the total number of all nodes, including myself.

inherited

Response

integer

get_level() : integer

Find the depth of the current node.

inherited

This method counts all of the parents in the tree until there are no more parents.

Response

integer

get_children() : \an

Return the children of this node.

inherited

Response

\an

array of cms_tree objects, or null if there are no children.