From 7ff1d82903087cef8915adc48935d6133769bbab Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sun, 6 Apr 2025 06:25:58 +0200 Subject: [PATCH] New plugin: Configure menu table links --- CHANGELOG.md | 1 + adminer/include/html.inc.php | 4 +- plugins/menu-links.php | 79 ++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 plugins/menu-links.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c6d9f16c..bbd56273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Editor: Move mass sending e-mails to a plugin - Plugins: Allow formatting translations using Adminer\lang_format() - New plugin: Configure options by end-users and store them to a cookie +- New plugin: Configure menu table links - New plugin: Set up driver, server and database in Adminer Editor ## Adminer 5.1.1 (released 2025-04-02) diff --git a/adminer/include/html.inc.php b/adminer/include/html.inc.php index 543bcb4b..9193b5d5 100644 --- a/adminer/include/html.inc.php +++ b/adminer/include/html.inc.php @@ -100,10 +100,10 @@ function html_select(string $name, array $options, ?string $value = "", string $ /** Generate HTML radio list * @param string[] $options */ -function html_radios(string $name, array $options, ?string $value = ""): string { +function html_radios(string $name, array $options, ?string $value = "", string $separator = ""): string { $return = ""; foreach ($options as $key => $val) { - $return .= ""; + $return .= "$separator"; } return $return; } diff --git a/plugins/menu-links.php b/plugins/menu-links.php new file mode 100644 index 00000000..4ba89f0d --- /dev/null +++ b/plugins/menu-links.php @@ -0,0 +1,79 @@ +menu = Adminer\get_setting("menu", "adminer_config") ?: $menu; + } + + function config() { + $options = array( + 'select' => Adminer\lang('Select'), + 'table' => Adminer\lang('Table'), + '' => $this->lang('Both'), + 'auto' => $this->lang('Auto (Select on select page, Table otherwise)'), + ); + return array($this->lang('Menu table links') => Adminer\html_radios('menu', $options, $this->menu, "
")); + } + + function tablesPrint(array $tables) { + $menu = $this->menu; + $titles = array( + 'select' => Adminer\lang('Select data'), + 'table' => Adminer\lang('Show structure'), + ); + // this is copied from Adminer::tablesPrint() + echo "\n"; + return true; + } + + protected function lang($idf, $number = null) { + return Adminer\lang_format(Adminer\idx(self::$translations[Adminer\LANG], $idf) ?: $idf, $number); + } + + protected static $translations = array( + 'cs' => array( + 'Menu table links' => 'Odkazy na tabulky v menu', + 'Both' => 'Oboje', + 'Auto (Select on select page, Table otherwise)' => 'Auto (Vypsat na výpisech, jinak Tabulka)', + ), + ); +}