From 71295a3ec34502516f5e60507f5994304fecb893 Mon Sep 17 00:00:00 2001 From: vv221 Date: Fri, 3 Apr 2020 02:14:16 +0200 Subject: [PATCH] Generate a label from the item type if none is provided --- MenuItem.php | 5 ++++- action.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/MenuItem.php b/MenuItem.php index 38cf2ca..4a1011b 100644 --- a/MenuItem.php +++ b/MenuItem.php @@ -11,9 +11,12 @@ class MenuItem extends AbstractItem { * @param string $type * @param string $label */ - public function __construct(string $type, string $label) { + public function __construct(string $type, string $label = '') { global $INFO; $this->type = $type; + if ( empty($label) ) { + $label = ucfirst($type); + } $this->label = $label; parent::__construct(); // Edit the item to show a link to the requested children page diff --git a/action.php b/action.php index 2f2705e..e081f7f 100644 --- a/action.php +++ b/action.php @@ -60,7 +60,7 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin { * @param string $type * @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); $event->data['items'][] = $item; } @@ -70,7 +70,7 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin { * * @param string $type */ - protected function generateMenuItem(string $type, string $name) { + protected function generateMenuItem(string $type, string $name = '') { return new MenuItem($type, $name); } }