diff --git a/resources/templates/menu/breadcrumbs.twig b/resources/templates/menu/main.twig similarity index 62% rename from resources/templates/menu/breadcrumbs.twig rename to resources/templates/menu/main.twig index 997692aace..1fa9dd8d2b 100644 --- a/resources/templates/menu/breadcrumbs.twig +++ b/resources/templates/menu/main.twig @@ -42,3 +42,26 @@ {% endif %} + +
diff --git a/resources/templates/top_menu.twig b/resources/templates/top_menu.twig deleted file mode 100644 index a49aff5fc8..0000000000 --- a/resources/templates/top_menu.twig +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/src/Menu.php b/src/Menu.php index 056f31379a..ae9375309d 100644 --- a/src/Menu.php +++ b/src/Menu.php @@ -50,18 +50,20 @@ class Menu */ public function getDisplay(): string { - $retval = $this->getBreadcrumbs(); - $retval .= $this->getMenu(); + $breadcrumbs = $this->getBreadcrumbs(); + $menu = $this->getMenu(); - return $retval; + return $this->template->render('menu/main', [ + 'server' => $breadcrumbs['server'], + 'database' => $breadcrumbs['database'], + 'table' => $breadcrumbs['table'], + 'tabs' => $menu['tabs'], + 'url_params' => $menu['url_params'], + ]); } - /** - * Returns the menu as HTML - * - * @return string HTML formatted menubar - */ - private function getMenu(): string + /** @return array{tabs: mixed[], url_params: mixed[]} */ + private function getMenu(): array { $urlParams = []; @@ -84,7 +86,7 @@ class Menu // Filter out any tabs that are not allowed $tabs = array_intersect_key($tabs, $allowedTabs); - return $this->template->render('top_menu', ['tabs' => $tabs, 'url_params' => $urlParams]); + return ['tabs' => $tabs, 'url_params' => $urlParams]; } /** @@ -135,12 +137,8 @@ class Menu return $allowedTabs; } - /** - * Returns the breadcrumbs as HTML - * - * @return string HTML formatted breadcrumbs - */ - private function getBreadcrumbs(): string + /** @return array{server: mixed[], database: mixed[], table: mixed[]} */ + private function getBreadcrumbs(): array { $server = []; $database = []; @@ -171,7 +169,7 @@ class Menu } if (mb_strstr($table['comment'], '; InnoDB free')) { - $table['comment'] = preg_replace('@; InnoDB free:.*?$@', '', $table['comment']); + $table['comment'] = (string) preg_replace('@; InnoDB free:.*?$@', '', $table['comment']); } } else { // no table selected, display database comment if present @@ -185,11 +183,7 @@ class Menu } } - return $this->template->render('menu/breadcrumbs', [ - 'server' => $server, - 'database' => $database, - 'table' => $table, - ]); + return ['server' => $server, 'database' => $database, 'table' => $table]; } /**