Skip to content
Snippets Groups Projects
Commit 50ca245c authored by Andreas Gohr's avatar Andreas Gohr
Browse files

MenuItems: add possibility to set a different title attribute

parent c084674a
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,8 @@ abstract class AbstractItem { ...@@ -44,6 +44,8 @@ abstract class AbstractItem {
protected $svg = DOKU_INC . 'lib/images/menu/00-default_checkbox-blank-circle-outline.svg'; protected $svg = DOKU_INC . 'lib/images/menu/00-default_checkbox-blank-circle-outline.svg';
/** @var string can be set to overwrite the default lookup in $lang.btn_* */ /** @var string can be set to overwrite the default lookup in $lang.btn_* */
protected $label = ''; protected $label = '';
/** @var string the tooltip title, defaults to $label */
protected $title = '';
/** @var int the context this titme is shown in */ /** @var int the context this titme is shown in */
protected $context = self::CTX_ALL; protected $context = self::CTX_ALL;
...@@ -87,6 +89,19 @@ abstract class AbstractItem { ...@@ -87,6 +89,19 @@ abstract class AbstractItem {
return $label; return $label;
} }
/**
* 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
*/
public function getTitle() {
if($this->title === '') return $this->getLabel();
return $this->title;
}
/** /**
* Return the link this item links to * Return the link this item links to
* *
...@@ -116,7 +131,7 @@ abstract class AbstractItem { ...@@ -116,7 +131,7 @@ abstract class AbstractItem {
public function getLinkAttributes($classprefix = 'menuitem ') { public function getLinkAttributes($classprefix = 'menuitem ') {
$attr = array( $attr = array(
'href' => $this->getLink(), 'href' => $this->getLink(),
'title' => $this->getLabel(), 'title' => $this->getTitle(),
); );
if($this->isNofollow()) $attr['rel'] = 'nofollow'; if($this->isNofollow()) $attr['rel'] = 'nofollow';
if($this->getAccesskey()) { if($this->getAccesskey()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment