Stud.IP  5.4
 All Data Structures Namespaces Files Functions Variables Groups
ActionMenu Class Reference

Public Member Functions

 condition ($state)
 
 conditionAll ($state)
 
 addLink ($url, $label="", Icon $icon=null, array $attributes=[], $index=null, $before=null)
 
 removeLink ($index)
 
 addButton ($name, $label, Icon $icon=null, array $attributes=[])
 
 addMultiPersonSearch (MultiPersonSearch $mp)
 
 addCSSClass ($class)
 
 addAttribute ($key, $value, $append=false)
 
 render ()
 
 __toString ()
 
 setContext (string $context)
 
 setRenderingMode (?string $mode)
 
 getRenderingMode ()
 
 generateTitle ()
 

Static Public Member Functions

static get ()
 

Data Fields

const TEMPLATE_FILE_SINGLE = 'shared/action-menu-single.php'
 
const TEMPLATE_FILE_MULTIPLE = 'shared/action-menu.php'
 
const RENDERING_MODE_ICONS = 'icons'
 
const RENDERING_MODE_MENU = 'menu'
 

Protected Member Functions

 checkCondition ()
 
 getKeyForIndex ($index)
 

Protected Attributes

 $context = ''
 
 $rendering_mode = null
 

Detailed Description

This class represents the action menu used to group actions.

Author
Jan-Hendrik Willms tleil.nosp@m.ax+s.nosp@m.tudip.nosp@m.@gma.nosp@m.il.co.nosp@m.m GPL2 or any later version
Since
Stud.IP 3.5

Member Function Documentation

__toString ( )

Magic method to render the menu as a string.

Returns
String containing the html representation of the action menu
See Also
ActionMenu::render()
addAttribute (   $key,
  $value,
  $append = false 
)

Adds an attribute to the root element in html.

Parameters
string$keyName of the attribute
string$valueValue of the attribute
boolean$appendWhether a current value should be append or not.
addButton (   $name,
  $label,
Icon  $icon = null,
array  $attributes = [] 
)

Adds a button to the list of actions.

Parameters
String$nameButton name
String$labelTextual representation of the name
mixed$iconOptional icon (as Icon object)
array$attributesOptional attributes to add to the tag
Returns
ActionMenu instance to allow chaining
addCSSClass (   $class)

Adds a css classs to the root element in html.

Parameters
string$className of the css class
Returns
ActionMenu instance to allow chaining
addLink (   $url,
  $label = "",
Icon  $icon = null,
array  $attributes = [],
  $index = null,
  $before = null 
)

Adds a link to the list of actions.

Parameters
String | StudipLink$urlLink target, eithe as string or Stud.IP link. In the latter case, all other parameters are ignored.
String | array$labelTextual representation of the link
mixed$iconOptional icon (as Icon object)
array$attributesOptional attributes to add to the tag
mixed$indexOptional index to access this link (remove for example) afterwards
mixed$beforeOptional index to insert this link before the link with given index.
Returns
ActionMenu instance to allow chaining
addMultiPersonSearch ( MultiPersonSearch  $mp)

Adds a MultiPersonSearch object to the list of actions.

Parameters
MultiPersonSearch$mpMultiPersonSearch object
Returns
ActionMenu instance to allow chaining
checkCondition ( )
protected

Checks the condition. Takes global and local (conditionAll() & condition()) conditions into account.

Returns
bool indicating whether the condition is met or not
condition (   $state)

Set condition for the next added item. If condition is false, the item will not be added.

Parameters
bool$stateState of the condition
Returns
ActionMenu instance to allow chaining
conditionAll (   $state)

Set condition for all the next added items. If condition is false, no items will be added.

Parameters
bool$stateState of the condition
Returns
ActionMenu instance to allow chaining
generateTitle ( )

Generates the title of the action menu, including its context, if the context has been set.

Returns
string The title of the action menu.
static get ( )
static

Returns an instance.

Returns
ActionMenu
getKeyForIndex (   $index)
protected
getRenderingMode ( )

Returns the rendering mode for this action menu. This is set by either calling setRenderingMode or automatically determined by the configured threshold.

Returns
string
removeLink (   $index)

Tries to remove the link with the given index and returns true on success (else false)

Parameters
$index: the index of the link. If the link had no special index it's md5($url.json_encode($ttributes)).
Returns
bool : true if link was removed, false if index didn't exist
render ( )

Renders the action menu. If no item was added, an empty string will be returned. If a single item was added, the item itself will be displayed. Otherwise the whole menu will be rendered.

Returns
String containing the html representation of the action menu
setContext ( string  $context)

Sets the context for the menu.

Parameters
string$contextThe context to be set.
Returns
ActionMenu The action menu instance (to allow chaining).
setRenderingMode ( ?string  $mode)

Forces an explicit rendering mode.

Parameters
string | null$modeThe desired rendering mode or null for automatic detection
Returns
ActionMenu The action menu instance to allow chaining
Exceptions
Exception

Field Documentation

$context = ''
protected
$rendering_mode = null
protected
const RENDERING_MODE_ICONS = 'icons'
const RENDERING_MODE_MENU = 'menu'
const TEMPLATE_FILE_MULTIPLE = 'shared/action-menu.php'
const TEMPLATE_FILE_SINGLE = 'shared/action-menu-single.php'

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