Navigation

Summary
Navigation
AuthorRich Joslin
Licensehttp://communit.as/docs/license
See Also
Instance Variables
$_nameThe name of the table or view to interact with in the data source.
$_primaryThe primary key of the table or view to interact with in the data source.
$role_id
Constructors
NavigationCalls the parent’s constructor and sets the private role_id variable.
Instance Methods
getNavTreeReturns a full tree (very jagged multidimensional array) of all navigation items that apply to the given role.
buildRecursiveNavThis is a recursive function that iterates through the supplied array, figures out if there are children, and either continues parsing the children (recursively), or assigns the results to the supplied parent (if the current recursion is complete).
getNavArrayByParentId
hasChildrenDetermines if a nav item has children.

Author

Rich Joslin

Instance Variables

$_name

protected $_name

The name of the table or view to interact with in the data source.

$_primary

protected $_primary

The primary key of the table or view to interact with in the data source.

$role_id

public $role_id

Constructors

Navigation

function Navigation($role_id,  
$config =  null)

Calls the parent’s constructor and sets the private role_id variable.  Role ID is required in order to create a Navigation object.

Arguments

role_idNone of these methods will work without a role ID.
config (optional)Required by parent constructor

Instance Methods

getNavTree

function getNavTree()

Returns a full tree (very jagged multidimensional array) of all navigation items that apply to the given role.

Returns: array

buildRecursiveNav

private function buildRecursiveNav($parent_item,
$nav_items)

This is a recursive function that iterates through the supplied array, figures out if there are children, and either continues parsing the children (recursively), or assigns the results to the supplied parent (if the current recursion is complete).

Arguments

nav_itemsAn array of nav items as pulled from the database using getNavArrayByParentId.
parent_itemThe item to which to add children if any are found.

Returns: An array of nav items along with any descendants they have (i.e.: a tree, or multidimensional array).

getNavArrayByParentId

function getNavArrayByParentId($parent_id)

Arguments

parent_idThe ID of the nav item for which to get children.

Returns: array of nav items (as pulled from default_navigation table)

hasChildren

function hasChildren($nav_id)

Determines if a nav item has children.

Arguments

nav_id: The ID of the nav item for which to determine whether it has children.

Returns: boolean

protected $_name
The name of the table or view to interact with in the data source.
protected $_primary
The primary key of the table or view to interact with in the data source.
public $role_id
function Navigation($role_id,  
$config =  null)
Calls the parent’s constructor and sets the private role_id variable.
function getNavTree()
Returns a full tree (very jagged multidimensional array) of all navigation items that apply to the given role.
private function buildRecursiveNav($parent_item,
$nav_items)
This is a recursive function that iterates through the supplied array, figures out if there are children, and either continues parsing the children (recursively), or assigns the results to the supplied parent (if the current recursion is complete).
function getNavArrayByParentId($parent_id)
function hasChildren($nav_id)
Determines if a nav item has children.
Close