]> git.joonet.de Git - adminer.git/commitdiff
Rename functions for settings stored in a cookie
authorPeter Knut <peter@pematon.com>
Wed, 12 Mar 2025 21:32:49 +0000 (22:32 +0100)
committerJakub Vrana <jakub@vrana.cz>
Sun, 16 Mar 2025 16:24:28 +0000 (17:24 +0100)
adminer/create.inc.php
adminer/dump.inc.php
adminer/include/editing.inc.php
adminer/indexes.inc.php
adminer/select.inc.php
adminer/sql.inc.php

index 70c3fc694cd33e74672bd7f5c7cd71419fcdba8c..8a3c8f63762a4237760f941a99016a837792c7eb 100644 (file)
@@ -30,7 +30,7 @@ if ($row["auto_increment_col"]) {
 }
 
 if ($_POST) {
-       set_adminer_settings(array("comments" => $_POST["comments"], "defaults" => $_POST["defaults"]));
+       save_settings(array("comments" => $_POST["comments"], "defaults" => $_POST["defaults"]));
 }
 
 if ($_POST && !process_fields($row["fields"]) && !$error) {
@@ -203,9 +203,9 @@ foreach ($engines as $engine) {
 </div>
 <p>
 <?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" class="size" value="<?php echo h($row["Auto_increment"]); ?>">
-<?php echo checkbox("defaults", 1, ($_POST ? $_POST["defaults"] : adminer_setting("defaults")), lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
+<?php echo checkbox("defaults", 1, ($_POST ? $_POST["defaults"] : get_setting("defaults")), lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
 <?php
-       $comments = ($_POST ? $_POST["comments"] : adminer_setting("comments"));
+       $comments = ($_POST ? $_POST["comments"] : get_setting("comments"));
        echo (support("comment")
                ? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly")
                        . ' ' . (preg_match('~\n~', $row["Comment"])
index bdd31c9e351a5cc98463b21350db05cc6ee6a5c8..366e1e66e03a80c6ea3fadef7844b37829d78097 100644 (file)
@@ -4,7 +4,7 @@ namespace Adminer;
 $TABLE = $_GET["dump"];
 
 if ($_POST && !$error) {
-       set_adminer_settings(
+       save_settings(
                array_intersect_key($_POST, array_flip(array("output", "format", "db_style", "types", "routines", "events", "table_style", "auto_increment", "triggers", "data_style"))),
                "adminer_export"
        );
@@ -155,7 +155,7 @@ $data_style = array('', 'TRUNCATE+INSERT', 'INSERT');
 if (JUSH == "sql") { //! use insertUpdate() in all drivers
        $data_style[] = 'INSERT+UPDATE';
 }
-$row = adminer_settings("adminer_export");
+$row = get_settings("adminer_export");
 if (!$row) {
        $row = array("output" => "text", "format" => "sql", "db_style" => (DB != "" ? "" : "CREATE"), "table_style" => "DROP+CREATE", "data_style" => "INSERT");
 }
index 32a6ee642aba1dc96ba0ab6884a46203222894a4..3c6c36939aac244d2fd9996dca1024394ddc839f 100644 (file)
@@ -124,7 +124,7 @@ function referencable_primary($self) {
 * @param string
 * @return array
 */
-function adminer_settings($cookie) {
+function get_settings($cookie) {
        parse_str($_COOKIE[$cookie], $settings);
        return $settings;
 }
@@ -134,8 +134,8 @@ function adminer_settings($cookie) {
 * @param string
 * @return mixed
 */
-function adminer_setting($key, $cookie = "adminer_settings") {
-       $settings = adminer_settings($cookie);
+function get_setting($key, $cookie = "adminer_settings") {
+       $settings = get_settings($cookie);
        return $settings[$key];
 }
 
@@ -144,8 +144,8 @@ function adminer_setting($key, $cookie = "adminer_settings") {
 * @param string
 * @return bool
 */
-function set_adminer_settings($settings, $cookie = "adminer_settings") {
-       return cookie($cookie, http_build_query($settings + adminer_settings($cookie)));
+function save_settings($settings, $cookie = "adminer_settings") {
+       return cookie($cookie, http_build_query($settings + get_settings($cookie)));
 }
 
 /** Print SQL <textarea> tag
@@ -353,8 +353,8 @@ function type_class($type) {
 function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array()) {
        global $driver;
        $fields = array_values($fields);
-       $default_class = (($_POST ? $_POST["defaults"] : adminer_setting("defaults")) ? "" : " class='hidden'");
-       $comment_class = (($_POST ? $_POST["comments"] : adminer_setting("comments")) ? "" : " class='hidden'");
+       $default_class = (($_POST ? $_POST["defaults"] : get_setting("defaults")) ? "" : " class='hidden'");
+       $comment_class = (($_POST ? $_POST["comments"] : get_setting("comments")) ? "" : " class='hidden'");
        ?>
 <thead><tr>
 <?php echo ($type == "PROCEDURE" ? "<td>" : ""); ?>
index 43712d3acade995f2596310a2ea1b64b44994a49..e96d5a17775d32e44cf713911a04af40fcae7640 100644 (file)
@@ -19,7 +19,7 @@ if (JUSH == "mongo") { // doesn't support primary key
 }
 $row = $_POST;
 if ($row) {
-       set_adminer_settings(array("index_options" => $row["options"]));
+       save_settings(array("index_options" => $row["options"]));
 }
 if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
        $alter = array();
@@ -97,7 +97,7 @@ if (!$row) {
        $row["indexes"] = $indexes;
 }
 $lengths = (JUSH == "sql" || JUSH == "mssql");
-$show_options = ($_POST ? $_POST["options"] : adminer_setting("index_options"));
+$show_options = ($_POST ? $_POST["options"] : get_setting("index_options"));
 ?>
 
 <form action="" method="post">
index ca96cde59ba236200baccad59e2774d078cb6209..c5ad89d8fd1e6ddf85951b7a2ccabb62a6b86c4d 100644 (file)
@@ -7,7 +7,7 @@ $indexes = indexes($TABLE);
 $fields = fields($TABLE);
 $foreign_keys = column_foreign_keys($TABLE);
 $oid = $table_status["Oid"];
-$adminer_import = adminer_settings("adminer_import");
+$adminer_import = get_settings("adminer_import");
 
 $rights = array(); // privilege => 0
 $columns = array(); // selectable columns
@@ -83,7 +83,7 @@ if ($_POST && !$error) {
        }
        $where_check = ($where_check ? "\nWHERE " . implode(" AND ", $where_check) : "");
        if ($_POST["export"]) {
-               set_adminer_settings(array("output" => $_POST["output"], "format" => $_POST["format"]), "adminer_import");
+               save_settings(array("output" => $_POST["output"], "format" => $_POST["format"]), "adminer_import");
                dump_headers($TABLE);
                $adminer->dumpTable($TABLE, "");
                $from = ($select ? implode(", ", $select) : "*")
@@ -195,7 +195,7 @@ if ($_POST && !$error) {
                } elseif (!preg_match('~~u', $file)) {
                        $error = lang('File must be in UTF-8 encoding.');
                } else {
-                       set_adminer_settings(array("output" => $adminer_import["output"], "format" => $_POST["separator"]), "adminer_import");
+                       save_settings(array("output" => $adminer_import["output"], "format" => $_POST["separator"]), "adminer_import");
                        $result = true;
                        $cols = array_keys($fields);
                        preg_match_all('~(?>"[^"]*"|[^"\r\n]+)+~', $file, $matches);
index 8da4a03c18a8d5f6db9a65af287556bfebd5cb20..c36b29a5c5b7e9b1a276ef3b453dd83accf008ab 100644 (file)
@@ -2,7 +2,7 @@
 namespace Adminer;
 
 if (!$error && $_POST["export"]) {
-       set_adminer_settings(array("output" => $_POST["output"], "format" => $_POST["format"]), "adminer_import");
+       save_settings(array("output" => $_POST["output"], "format" => $_POST["format"]), "adminer_import");
        dump_headers("sql");
        $adminer->dumpTable("", "");
        $adminer->dumpData("", "table", $_POST["query"]);
@@ -65,7 +65,7 @@ if (!$error && $_POST) {
                $errors = array();
                $parse = '[\'"' . (JUSH == "sql" ? '`#' : (JUSH == "sqlite" ? '`[' : (JUSH == "mssql" ? '[' : ''))) . ']|/\*|-- |$' . (JUSH == "pgsql" ? '|\$[^$]*\$' : '');
                $total_start = microtime(true);
-               $adminer_export = adminer_settings("adminer_import"); // this doesn't offer SQL export so we match the import/export style at select
+               $adminer_export = get_settings("adminer_import"); // this doesn't offer SQL export so we match the import/export style at select
                $dump_format = $adminer->dumpFormat();
                unset($dump_format["sql"]);