[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Menu/Item/ -> AbstractItem.php (summary)

(no description)

File Size: 253 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

AbstractItem:: (14 methods):
  __construct()
  getLabel()
  getTitle()
  getLink()
  getLinkAttributes()
  asHtmlLink()
  asHtmlButton()
  visibleInContext()
  getType()
  getAccesskey()
  getParams()
  isNofollow()
  getSvg()
  getLegacyData()


Class: AbstractItem  - X-Ref

Class AbstractItem

This class defines a single Item to be displayed in one of DokuWiki's menus. Plugins
can extend those menus through action plugins and add their own instances of this class,
overwriting some of its properties.

Items may be shown multiple times in different contexts. Eg. for the default template
all menus are shown in a Dropdown list on mobile, but are split into several places on
desktop. The item's $context property can be used to hide the item depending on the current
context.

Children usually just need to overwrite the different properties, but for complex things
the accessors may be overwritten instead.
__construct()   X-Ref
AbstractItem constructor.

Sets the dynamic properties

Children should always call the parent constructor!


getLabel()   X-Ref
Return this item's label

When the label property was set, it is simply returned. Otherwise, the action's type
is used to look up the translation in the main language file and, if used, the replacement
is applied.

return: string

getTitle()   X-Ref
Return this item's title

This title should be used to display a tooltip (using the HTML title attribute). If
a title property was not explicitly set, the label will be returned.

return: string

getLink()   X-Ref
Return the link this item links to

Basically runs wl() on $id and $params. However if the ID is a hash it is used directly
as the link

Please note that the generated URL is *not* XML escaped.

see: wl()
return: string

getLinkAttributes($classprefix = 'menuitem ')   X-Ref
Convenience method to get the attributes for constructing an <a> element

see: buildAttributes()
return: array
param: string|false $classprefix create a class from type with this prefix, false for no class

asHtmlLink($classprefix = 'menuitem ', $svg = true)   X-Ref
Convenience method to create a full <a> element

Wraps around the label and SVG image

return: string
param: string|false $classprefix create a class from type with this prefix, false for no class
param: bool $svg add SVG icon to the link

asHtmlButton()   X-Ref
Convenience method to create a <button> element inside it's own form element

Uses html_btn()

return: string

visibleInContext($ctx)   X-Ref
Should this item be shown in the given context

return: bool
param: int $ctx the current context

getType()   X-Ref

return: string the name of this item

getAccesskey()   X-Ref

return: string

getParams()   X-Ref

return: array

isNofollow()   X-Ref

return: bool

getSvg()   X-Ref

return: string

getLegacyData()   X-Ref
Return this Item's settings as an array as used in tpl_get_action()

return: array