Stud.IP  5.4
TOCItem Class Reference

Public Member Functions

 __construct ($title)
 
 getTitle ()
 
 setTitle (string $newTitle)
 
 getIcon ()
 
 setIcon (Icon $icon)
 
 getUrl ()
 
 setUrl (string $newUrl, mixed $parameters=null)
 
 getLinkAttributes ()
 
 setLinkAttributes ($attributes)
 
 getParent ()
 
 setParent (TOCItem $newParent)
 
 getChildren ()
 
 setChildren (array $newChildren)
 
 addChild (TOCItem $newChild, $position=null)
 
 removeChild (TOCItem $child)
 
 hasChildren ()
 
 countAllChildren ()
 
 isActive ()
 
 setActive (bool $state)
 
 getActiveItem ()
 
 isRoot ()
 
 getRoot ()
 
 getPath ($separator='/')
 
 flatten ()
 
 __toString ()
 

Data Fields

 $title = ''
 
 $icon = null
 
 $url = ''
 
 $link_attributes = []
 
 $parent = null
 
 $children = []
 
 $active = false
 

Detailed Description

Class TOCItem A representation of a single entry in a table of contents or breadcrumb. One entry contains all children.

Author
Thomas Hackl hackl.nosp@m.@dat.nosp@m.a-que.nosp@m.st.d.nosp@m.e GPL2 or any later version
Since
Stud.IP 5.0

Constructor & Destructor Documentation

◆ __construct()

__construct (   $title)

Member Function Documentation

◆ __toString()

__toString ( )

String representation of this item.

Returns
string

◆ addChild()

addChild ( TOCItem  $newChild,
  $position = null 
)

Add a new child to this item, optionally at a given position.

Parameters
TOCItem$newChild
null | int$position
Returns
$this

◆ countAllChildren()

countAllChildren ( )

Count the elements in the hierarchy, starting at (and counting in) current item.

Returns
int

◆ flatten()

flatten ( )

Generates a flat representation of the current item and all its children and children's children.

Returns
array|TOCItem[]

◆ getActiveItem()

getActiveItem ( )

◆ getChildren()

getChildren ( )

Gets this item's children as array.

Returns
array

◆ getIcon()

getIcon ( )

Get this item's icon.

Returns
Icon

◆ getLinkAttributes()

getLinkAttributes ( )

Gets the additional link attributes.

Returns
array

◆ getParent()

getParent ( )

Gets this item's parent element.

Returns
null|TOCItem

◆ getPath()

getPath (   $separator = '/')

Get a string representation of the current hierarchy as breadcrumb-like path.

Parameters
string$separatorwhich separator tu use between elements?
Returns
string

◆ getRoot()

getRoot ( )

Get the root element of the current hierarchy (= the element with no parent)

Returns
bool

◆ getTitle()

getTitle ( )

Get the display title.

Returns
string

◆ getUrl()

getUrl ( )

Get this item's URL, with additional parameters if set.

Returns
string

◆ hasChildren()

hasChildren ( )

Does the current item have children?

Returns
bool

◆ isActive()

isActive ( )

Check if current item is active.

Returns
bool

◆ isRoot()

isRoot ( )

Is the current element the root of its hierarchy?

Returns
bool

◆ removeChild()

removeChild ( TOCItem  $child)

Removes the given child.

Parameters
TOCItem$child
Returns
$this

◆ setActive()

setActive ( bool  $state)

Set active status of current item.

Parameters
bool$state
Returns
$this

◆ setChildren()

setChildren ( array  $newChildren)

Sets a new array of child elements.

Parameters
array$newChildren
Returns
$this

◆ setIcon()

setIcon ( Icon  $icon)

Set a new icon.

Parameters
Icon$icon
Returns
$this

◆ setLinkAttributes()

setLinkAttributes (   $attributes)

Sets new additional link attributes.

Parameters
array$attributes
Returns
$this

◆ setParent()

setParent ( TOCItem  $newParent)

Sets a new parent element for this item.

Parameters
TOCItem$newParent
Returns
$this

◆ setTitle()

setTitle ( string  $newTitle)

Set a new display title.

Parameters
string$newTitle
Returns
$this

◆ setUrl()

setUrl ( string  $newUrl,
mixed  $parameters = null 
)

Set a new URL, optionally with additional link parameters.

Parameters
string$newUrl
mixed | null$parameters
Returns
$this

Field Documentation

◆ $active

$active = false

◆ $children

$children = []

◆ $icon

$icon = null

◆ $link_attributes

$link_attributes = []

◆ $parent

$parent = null

◆ $title

$title = ''

◆ $url

$url = ''

The documentation for this class was generated from the following file: