Generate a label from the item type if none is provided
This commit is contained in:
parent
60f3dfe08f
commit
71295a3ec3
2 changed files with 6 additions and 3 deletions
|
@ -11,9 +11,12 @@ class MenuItem extends AbstractItem {
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $label
|
* @param string $label
|
||||||
*/
|
*/
|
||||||
public function __construct(string $type, string $label) {
|
public function __construct(string $type, string $label = '') {
|
||||||
global $INFO;
|
global $INFO;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
if ( empty($label) ) {
|
||||||
|
$label = ucfirst($type);
|
||||||
|
}
|
||||||
$this->label = $label;
|
$this->label = $label;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
// Edit the item to show a link to the requested children page
|
// Edit the item to show a link to the requested children page
|
||||||
|
|
|
@ -60,7 +60,7 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
protected function addMenuItem(Doku_Event $event, string $type, string $name) {
|
protected function addMenuItem(Doku_Event $event, string $type, string $name = '') {
|
||||||
$item = $this->generateMenuItem($type, $name);
|
$item = $this->generateMenuItem($type, $name);
|
||||||
$event->data['items'][] = $item;
|
$event->data['items'][] = $item;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
*/
|
*/
|
||||||
protected function generateMenuItem(string $type, string $name) {
|
protected function generateMenuItem(string $type, string $name = '') {
|
||||||
return new MenuItem($type, $name);
|
return new MenuItem($type, $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue