]> git.joonet.de Git - adminer.git/commitdiff
Split helper html_radios
authorJakub Vrana <jakub@vrana.cz>
Mon, 10 Mar 2025 10:31:43 +0000 (11:31 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 10 Mar 2025 10:31:43 +0000 (11:31 +0100)
adminer/dump.inc.php
adminer/foreign.inc.php
adminer/include/functions.inc.php
adminer/indexes.inc.php
adminer/select.inc.php

index 28e1f34f45336c017e2a6e8ebad48e8e99fef8fe..d3e2d425e5e12090e72519e2cd4cdcaab8519fbb 100644 (file)
@@ -167,9 +167,9 @@ if (!isset($row["events"])) { // backwards compatibility
        $row["triggers"] = $row["table_style"];
 }
 
-echo "<tr><th>" . lang('Output') . "<td>" . html_select("output", $adminer->dumpOutput(), $row["output"], 0) . "\n"; // 0 - radio
+echo "<tr><th>" . lang('Output') . "<td>" . html_radios("output", $adminer->dumpOutput(), $row["output"]) . "\n";
 
-echo "<tr><th>" . lang('Format') . "<td>" . html_select("format", $adminer->dumpFormat(), $row["format"], 0) . "\n"; // 0 - radio
+echo "<tr><th>" . lang('Format') . "<td>" . html_radios("format", $adminer->dumpFormat(), $row["format"]) . "\n";
 
 echo (JUSH == "sqlite" ? "" : "<tr><th>" . lang('Database') . "<td>" . html_select('db_style', $db_style, $row["db_style"])
        . (support("type") ? checkbox("types", 1, $row["types"], lang('User types')) : "")
index 72ef1f1a96b3eb1b475cbb7701370ee3ca568561..e371b762b8ba6440c21bb2b96e697fa5e43e54ea 100644 (file)
@@ -94,8 +94,8 @@ if (support("scheme")) {
 $j = 0;
 foreach ($row["source"] as $key => $val) {
        echo "<tr>";
-       echo "<td>" . html_select("source[" . (+$key) . "]", array(-1 => "") + $source, $val, ($j == count($row["source"]) - 1 ? "foreignAddRow.call(this);" : 1), "label-source");
-       echo "<td>" . html_select("target[" . (+$key) . "]", $target, $row["target"][$key], 1, "label-target");
+       echo "<td>" . html_select("source[" . (+$key) . "]", array(-1 => "") + $source, $val, ($j == count($row["source"]) - 1 ? "foreignAddRow.call(this);" : ""), "label-source");
+       echo "<td>" . html_select("target[" . (+$key) . "]", $target, $row["target"][$key], "", "label-target");
        $j++;
 }
 ?>
index 0ef1f71c1c27e0a0d8be7208b9d588aa9ca11273..3daa990533f1544c6d968c013b65d3b741c27630 100644 (file)
@@ -217,22 +217,29 @@ function optionlist($options, $selected = null, $use_keys = false) {
        return $return;
 }
 
-/** Generate HTML radio list
+/** Generate HTML <select>
 * @param string
 * @param array
 * @param string
-* @param string true for no onchange, false for radio
+* @param string
 * @param string
 * @return string
 */
-function html_select($name, $options, $value = "", $onchange = true, $labelled_by = "") {
-       if ($onchange) {
-               return "<select name='" . h($name) . "'"
-                       . ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
-                       . ">" . optionlist($options, $value) . "</select>"
-                       . (is_string($onchange) ? script("qsl('select').onchange = function () { $onchange };", "") : "")
-               ;
-       }
+function html_select($name, $options, $value = "", $onchange = "", $labelled_by = "") {
+       return "<select name='" . h($name) . "'"
+               . ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
+               . ">" . optionlist($options, $value) . "</select>"
+               . ($onchange ? script("qsl('select').onchange = function () { $onchange };", "") : "")
+       ;
+}
+
+/** Generate HTML radio list
+* @param string
+* @param array
+* @param string
+* @return string
+*/
+function html_radios($name, $options, $value = "") {
        $return = "";
        foreach ($options as $key => $val) {
                $return .= "<label><input type='radio' name='" . h($name) . "' value='" . h($key) . "'" . ($key == $value ? " checked" : "") . ">" . h($val) . "</label>";
index 84f02257ea3a3144360cd97927c2b389fe5b2aa6..43712d3acade995f2596310a2ea1b64b44994a49 100644 (file)
@@ -126,7 +126,7 @@ if ($primary) {
 $j = 1;
 foreach ($row["indexes"] as $index) {
        if (!$_POST["drop_col"] || $j != key($_POST["drop_col"])) {
-               echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow.call(this);" : 1), "label-type");
+               echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow.call(this);" : ""), "label-type");
 
                echo "<td>";
                ksort($index["columns"]);
index 834a4b41d6f0e58469b7cabaa217dde973f0cd0e..95950d7204f6b47f1980ee84d93266aae11a2b32 100644 (file)
@@ -587,7 +587,7 @@ if (!$columns && support("table")) {
                                echo script("qsl('a').onclick = partial(toggle, 'import');", "");
                                echo "<span id='import'" . ($_POST["import"] ? "" : " class='hidden'") . ">: ";
                                echo "<input type='file' name='csv_file'> ";
-                               echo html_select("separator", array("csv" => "CSV,", "csv;" => "CSV;", "tsv" => "TSV"), $adminer_import["format"], 1); // 1 - select
+                               echo html_select("separator", array("csv" => "CSV,", "csv;" => "CSV;", "tsv" => "TSV"), $adminer_import["format"]);
                                echo " <input type='submit' name='import' value='" . lang('Import') . "'>";
                                echo "</span>";
                                echo "</div>";