mirror of
https://github.com/vrana/adminer.git
synced 2025-08-07 23:27:17 +02:00
AdminerConfig: Support permalinks
This commit is contained in:
@@ -348,7 +348,9 @@ function get_setting(string $key, string $cookie = "adminer_settings") {
|
||||
* @param mixed[] $settings
|
||||
*/
|
||||
function save_settings(array $settings, string $cookie = "adminer_settings"): void {
|
||||
cookie($cookie, http_build_query($settings + get_settings($cookie)));
|
||||
$value = http_build_query($settings + get_settings($cookie));
|
||||
cookie($cookie, $value);
|
||||
$_COOKIE[$cookie] = $value;
|
||||
}
|
||||
|
||||
/** Restart stopped session */
|
||||
|
@@ -12,10 +12,9 @@ class AdminerConfig extends Adminer\Plugin {
|
||||
static $called; // this function is called from page_header() and it also calls page_header()
|
||||
if (isset($_GET["config"]) && !$called && Adminer\connection()) {
|
||||
$called = true;
|
||||
if ($_POST) { //! check $error
|
||||
unset($_POST["token"]);
|
||||
Adminer\save_settings($_POST, "adminer_config");
|
||||
Adminer\redirect($_SERVER["REQUEST_URI"], $this->lang('Configuration saved.'));
|
||||
if ($_GET["config"]) { // using $_GET allows sharing links between devices but doesn't protect against CSRF
|
||||
Adminer\save_settings($_GET["config"], "adminer_config");
|
||||
Adminer\redirect(null, $this->lang('Configuration saved.'));
|
||||
}
|
||||
Adminer\page_header($this->lang('Configuration'));
|
||||
$config = Adminer\adminer()->config();
|
||||
@@ -23,14 +22,14 @@ class AdminerConfig extends Adminer\Plugin {
|
||||
// this plugin itself defines config() so this branch is not currently used
|
||||
echo "<p>" . $this->lang('Only some plugins support configuration, e.g. %s.', '<a href="https://github.com/vrana/adminer/blob/master/plugins/menu-links.php"' . Adminer\target_blank() . '>menu-links</a>') . "\n";
|
||||
} else {
|
||||
echo "<form action='' method='post'>\n";
|
||||
echo "<form action=''>\n";
|
||||
Adminer\hidden_fields_get();
|
||||
echo "<table>\n";
|
||||
foreach (array_reverse($config) as $title => $html) { // Plugins::$append actually prepends
|
||||
echo "<tr><th>$title<td>$html\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo "<p><input type='submit' value='" . Adminer\lang('Save') . "'>\n";
|
||||
echo Adminer\input_token();
|
||||
echo "</form>\n";
|
||||
}
|
||||
Adminer\page_footer('db');
|
||||
@@ -43,7 +42,7 @@ class AdminerConfig extends Adminer\Plugin {
|
||||
'' => $this->lang('Use %s if exists', "adminer.css"),
|
||||
'builtin' => $this->lang('Use builtin design'),
|
||||
);
|
||||
return array($this->lang('Design') => Adminer\html_radios('design', $options, Adminer\get_setting("design", "adminer_config"), "<br>"));
|
||||
return array($this->lang('Design') => Adminer\html_radios('config[design]', $options, Adminer\get_setting("design", "adminer_config"), "<br>"));
|
||||
}
|
||||
|
||||
function css() {
|
||||
|
@@ -11,7 +11,7 @@ class AdminerMenuLinks extends Adminer\Plugin {
|
||||
|
||||
/** @param ''|'table'|'select'|'auto' $menu see config() for explanation */
|
||||
function __construct($menu = '') {
|
||||
$this->menu = Adminer\get_setting("menu", "adminer_config") ?: $menu;
|
||||
$this->menu = $menu;
|
||||
}
|
||||
|
||||
function config() {
|
||||
@@ -21,11 +21,12 @@ class AdminerMenuLinks extends Adminer\Plugin {
|
||||
'' => $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, "<br>"));
|
||||
$menu = Adminer\get_setting("menu", "adminer_config") ?: $this->menu;
|
||||
return array($this->lang('Menu table links') => Adminer\html_radios('config[menu]', $options, $menu, "<br>"));
|
||||
}
|
||||
|
||||
function tablesPrint(array $tables) {
|
||||
$menu = $this->menu;
|
||||
$menu = Adminer\get_setting("menu", "adminer_config") ?: $this->menu;
|
||||
$titles = array(
|
||||
'select' => Adminer\lang('Select data'),
|
||||
'table' => Adminer\lang('Show structure'),
|
||||
|
Reference in New Issue
Block a user