From 21f0481a1d9bf161d5006acdca5dd8788efec9db Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 22 Jan 2019 13:13:27 +0100 Subject: [PATCH] Remember visible columns in Create Table form (bug #493) --- adminer/create.inc.php | 25 +++++++++---------------- adminer/include/editing.inc.php | 32 ++++++++++++++++++++++++++++---- adminer/static/editing.js | 20 ++++++-------------- changes.txt | 1 + 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/adminer/create.inc.php b/adminer/create.inc.php index 6ebff59e..0b34a90f 100644 --- a/adminer/create.inc.php +++ b/adminer/create.inc.php @@ -27,6 +27,10 @@ if ($row["auto_increment_col"]) { $row["fields"][$row["auto_increment_col"]]["auto_increment"] = true; } +if ($_POST) { + set_adminer_settings(array("comments" => $_POST["comments"], "defaults" => $_POST["defaults"])); +} + if ($_POST && !process_fields($row["fields"]) && !$error) { if ($_POST["drop"]) { queries_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE))); @@ -173,27 +177,16 @@ foreach ($engines as $engine) {

: "> - - + " . lang('Comment') . "" - . script("qsl('input').onclick = partial(editingCommentsClick, true);") - . ' ' + ? checkbox("comments", 1, ($_POST ? $_POST["comments"] : adminer_setting("comments")), lang('Comment'), "editingCommentsClick(this, true);", "jsonly") + . ' ' : '') ; ?>

@@ -227,4 +220,4 @@ foreach ($row["partition_names"] as $key => $val) { ?> - + diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 9e3a9beb..59af7386 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -112,6 +112,31 @@ function referencable_primary($self) { return $return; } +/** Get settings stored in a cookie +* @return array +*/ +function adminer_settings() { + parse_str($_COOKIE["adminer_settings"], $settings); + return $settings; +} + +/** Get setting stored in a cookie +* @param string +* @return array +*/ +function adminer_setting($key) { + $settings = adminer_settings(); + return $settings[$key]; +} + +/** Store settings to a cookie +* @param array +* @return bool +*/ +function set_adminer_settings($settings) { + return cookie("adminer_settings", http_build_query($settings + adminer_settings())); +} + /** Print SQL