PHP Class ElggMenuItem, Elgg

To create a menu item that is not a link, pass false for $href. Any undocumented properties set will be passed to the output/url view during rendering. E.g. to give a menu item a "target" attribute, set $item->target, or include a "target" key in the options array for factory().
Since: 1.8.0
Afficher le fichier Open project: elgg/elgg Class Usage Examples

Protected Properties

Свойство Type Description
$confirm The string to display if link is clicked
$data Non-rendered data about the menu item
$href The menu url
$text The menu display string (HTML)
$title Tooltip

Méthodes publiques

Méthode Description
__construct ( string $name, string $text, string $href ) \ElggMenuItem constructor
addChild ( ElggMenuItem $item ) : void Add a child menu item
addDeps ( string[] | string $modules ) : void Add required AMD modules
addItemClass ( mixed $class ) : void Add a li class
addLinkClass ( mixed $class ) : void Add a link class
factory ( array $options ) : ElggMenuItem Create an ElggMenuItem from an associative array. Required keys are name, text, and href.
getChildren ( ) : ElggMenuItem[] Get the children menu items
getConfirmText ( ) : string Get the confirm text
getContext ( ) : array Get an array of context strings
getData ( string $key ) : mixed Get stored data
getDeps ( ) : string[] Get required AMD modules
getHref ( ) : string Get the URL of the menu item
getItemClass ( ) : string Get the li classes as text
getLinkClass ( ) : string Get the anchor classes as text
getName ( ) : string Get the identifier of the menu item
getParent ( ) : ElggMenuItem Get the parent menu item
getParentName ( ) : string Get the parent identifier
getPriority ( ) : integer Get the priority of the menu item
getSection ( ) : string Get the section identifier
getSelected ( ) : boolean Get selected state
getText ( ) : string Get the display text of the menu item
getTooltip ( ) : string Get the tool tip text
getValues ( ) : array Get all the values for this menu item. Useful for rendering.
inContext ( string $context = '' ) : boolean Should this menu item be used given the current context
setChildren ( ElggMenuItem[] $children ) : void Set the menu item's children
setConfirmText ( string $text ) : void Set the confirm text shown when link is clicked
setContext ( array $contexts ) : void Set the contexts that this menu item is available for
setData ( mixed $key, mixed $value = null ) : void Set a data key/value pair or a set of key/value pairs
setDeps ( string[] | string $modules ) : void Set required AMD modules
setHref ( string $href ) : void Set the URL of the menu item
setItemClass ( mixed $class ) : void Set the li classes
setLinkClass ( mixed $class ) : void Set the anchor class
setName ( string $name ) : void Set the identifier of the menu item
setParent ( ElggMenuItem $parent ) : void Set the parent menu item
setParentName ( string $name ) : void Set the parent identifier
setPriority ( integer $priority ) : void Set the priority of the menu item
setSection ( string $section ) : void Set the section identifier
setSelected ( boolean $state = true ) : void Set the selected flag
setText ( string $text ) : void Set the display text of the menu item
setTooltip ( string $text ) : void Set the tool tip text
sortChildren ( string $sortFunction ) : void Sort the children

Méthodes protégées

Méthode Description
addClass ( array &$current, mixed $additional ) : void Add additional classes

Method Details

__construct() public méthode

\ElggMenuItem constructor
public __construct ( string $name, string $text, string $href )
$name string Identifier of the menu item
$text string Display text of the menu item (HTML)
$href string URL of the menu item (false if not a link)

addChild() public méthode

This is reserved for the \ElggMenuBuilder.
public addChild ( ElggMenuItem $item ) : void
$item ElggMenuItem A child menu item
Résultat void

addClass() protected méthode

Add additional classes
protected addClass ( array &$current, mixed $additional ) : void
$current array The current array of classes
$additional mixed Additional classes (either array of string)
Résultat void

addDeps() public méthode

Add required AMD modules
public addDeps ( string[] | string $modules ) : void
$modules string[] | string One or more required AMD modules
Résultat void

addItemClass() public méthode

Add a li class
Since: 1.9.0
public addItemClass ( mixed $class ) : void
$class mixed An array of class names, or a single string class name.
Résultat void

addLinkClass() public méthode

Add a link class
public addLinkClass ( mixed $class ) : void
$class mixed An array of class names, or a single string class name.
Résultat void

getChildren() public méthode

This is reserved for the \ElggMenuBuilder.
public getChildren ( ) : ElggMenuItem[]
Résultat ElggMenuItem[]

getConfirmText() public méthode

Get the confirm text
public getConfirmText ( ) : string
Résultat string

getContext() public méthode

Get an array of context strings
public getContext ( ) : array
Résultat array

getData() public méthode

Get stored data
public getData ( string $key ) : mixed
$key string The key for the requested key/value pair
Résultat mixed

getDeps() public méthode

Get required AMD modules
public getDeps ( ) : string[]
Résultat string[]

getHref() public méthode

Get the URL of the menu item
public getHref ( ) : string
Résultat string

getItemClass() public méthode

Get the li classes as text
public getItemClass ( ) : string
Résultat string

getLinkClass() public méthode

Get the anchor classes as text
public getLinkClass ( ) : string
Résultat string

getName() public méthode

Get the identifier of the menu item
public getName ( ) : string
Résultat string

getParent() public méthode

This is reserved for the \ElggMenuBuilder.
public getParent ( ) : ElggMenuItem
Résultat ElggMenuItem or null

getParentName() public méthode

Get the parent identifier
public getParentName ( ) : string
Résultat string

getPriority() public méthode

Get the priority of the menu item
public getPriority ( ) : integer
Résultat integer

getSection() public méthode

Get the section identifier
public getSection ( ) : string
Résultat string

getSelected() public méthode

Get selected state
public getSelected ( ) : boolean
Résultat boolean

getText() public méthode

Get the display text of the menu item
public getText ( ) : string
Résultat string The display text as HTML

getTooltip() public méthode

Get the tool tip text
public getTooltip ( ) : string
Résultat string

getValues() public méthode

Get all the values for this menu item. Useful for rendering.
Since: 1.9.0
public getValues ( ) : array
Résultat array

inContext() public méthode

Should this menu item be used given the current context
public inContext ( string $context = '' ) : boolean
$context string A context string (default is empty string for current context stack).
Résultat boolean

setChildren() public méthode

This is reserved for the \ElggMenuBuilder.
public setChildren ( ElggMenuItem[] $children ) : void
$children ElggMenuItem[] Array of items
Résultat void

setConfirmText() public méthode

Set the confirm text shown when link is clicked
public setConfirmText ( string $text ) : void
$text string The text to show
Résultat void

setContext() public méthode

Set the contexts that this menu item is available for
public setContext ( array $contexts ) : void
$contexts array An array of context strings. Use 'all' to match all contexts.
Résultat void

setData() public méthode

This method allows storage of arbitrary data with this menu item. The data can be used for sorting, custom rendering, or any other use.
public setData ( mixed $key, mixed $value = null ) : void
$key mixed String key or an associative array of key/value pairs
$value mixed The value if $key is a string
Résultat void

setDeps() public méthode

Set required AMD modules
public setDeps ( string[] | string $modules ) : void
$modules string[] | string One or more required AMD modules
Résultat void

setHref() public méthode

Set the URL of the menu item
public setHref ( string $href ) : void
$href string URL or false if not a link
Résultat void

setItemClass() public méthode

Set the li classes
public setItemClass ( mixed $class ) : void
$class mixed An array of class names, or a single string class name.
Résultat void

setLinkClass() public méthode

Set the anchor class
public setLinkClass ( mixed $class ) : void
$class mixed An array of class names, or a single string class name.
Résultat void

setName() public méthode

Set the identifier of the menu item
public setName ( string $name ) : void
$name string Unique identifier
Résultat void

setParent() public méthode

This is reserved for the \ElggMenuBuilder.
public setParent ( ElggMenuItem $parent ) : void
$parent ElggMenuItem The parent of this menu item
Résultat void

setParentName() public méthode

Set the parent identifier
public setParentName ( string $name ) : void
$name string The identifier of the parent \ElggMenuItem
Résultat void

setPriority() public méthode

Set the priority of the menu item
public setPriority ( integer $priority ) : void
$priority integer The smaller numbers mean higher priority (1 before 100)
Résultat void

setSection() public méthode

Set the section identifier
public setSection ( string $section ) : void
$section string The identifier of the section
Résultat void

setSelected() public méthode

Set the selected flag
public setSelected ( boolean $state = true ) : void
$state boolean Selected state (default is true)
Résultat void

setText() public méthode

Set the display text of the menu item
public setText ( string $text ) : void
$text string The display text as HTML
Résultat void

setTooltip() public méthode

Set the tool tip text
public setTooltip ( string $text ) : void
$text string The text of the tool tip
Résultat void

sortChildren() public méthode

This is reserved for the \ElggMenuBuilder.
public sortChildren ( string $sortFunction ) : void
$sortFunction string A function that is passed to usort()
Résultat void

Property Details

$confirm protected_oe property

The string to display if link is clicked
protected $confirm

$data protected_oe property

Non-rendered data about the menu item
protected $data

$href protected_oe property

The menu url
protected $href

$text protected_oe property

The menu display string (HTML)
protected $text

$title protected_oe property

Tooltip
protected $title