diff --git a/CHANGELOG.md b/CHANGELOG.md index d495d0f2..c6d9f16c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - CSS: Add logo - 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: Set up driver, server and database in Adminer Editor ## Adminer 5.1.1 (released 2025-04-02) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 0b62ec42..3fa74ca3 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -300,6 +300,13 @@ class Adminer { return $val; } + /** Get configuration options for AdminerConfig + * @return string[] key is config description, value is HTML + */ + function config(): array { + return array(); + } + /** Print table structure in tabular format * @param Field[] $fields * @param TableStatus $tableStatus diff --git a/adminer/include/html.inc.php b/adminer/include/html.inc.php index 20b86e86..543bcb4b 100644 --- a/adminer/include/html.inc.php +++ b/adminer/include/html.inc.php @@ -100,7 +100,7 @@ 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 { $return = ""; foreach ($options as $key => $val) { $return .= ""; diff --git a/adminer/include/plugins.inc.php b/adminer/include/plugins.inc.php index 6c22dbdb..5523d939 100644 --- a/adminer/include/plugins.inc.php +++ b/adminer/include/plugins.inc.php @@ -2,7 +2,7 @@ namespace Adminer; class Plugins { - /** @var true[] */ private static array $append = array('dumpFormat' => true, 'dumpOutput' => true, 'editRowPrint' => true, 'editFunctions' => true); // these hooks expect the value to be appended to the result + /** @var true[] */ private static array $append = array('dumpFormat' => true, 'dumpOutput' => true, 'editRowPrint' => true, 'editFunctions' => true, 'config' => true); // these hooks expect the value to be appended to the result /** @var list @visibility protected(set) */ public array $plugins; /** @visibility protected(set) */ public string $error = ''; // HTML diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 943e5b68..545baa2d 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -231,6 +231,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row return $val; } + function config() { + return array(); + } + function selectColumnsPrint($select, $columns) { // can allow grouping functions by indexes } diff --git a/plugins/config.php b/plugins/config.php new file mode 100644 index 00000000..a0c060f3 --- /dev/null +++ b/plugins/config.php @@ -0,0 +1,67 @@ +lang('Configuration saved.')); + } + Adminer\page_header($this->lang('Configuration')); + $config = Adminer\adminer()->config(); + if (!$config) { + echo "

" . $this->lang('Only some plugins support configuration, e.g. %s.', 'menu-links') . "\n"; + } else { + echo "

\n"; + echo "\n"; + foreach ($config as $title => $html) { + echo "
$title$html\n"; + } + echo "
\n"; + echo "

\n"; + echo Adminer\input_token(); + echo "

\n"; + } + Adminer\page_footer('db'); + exit; + } + } + + function navigation() { + if (Adminer\connection()) { + $link = substr(preg_replace('~\b(db|ns)=[^&]*&~', '', Adminer\ME), 0, -1); + ?> + +\n"; + } + } + + 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( + 'Configuration' => 'Konfigurace', + 'Configuration saved.' => 'Konfigurace uložena.', + 'Only some plugins support configuration, e.g. %s.' => 'Konfiguraci podporují jen některé pluginy, např. %s.', + ), + ); +}