1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-31 18:11:52 +02:00

Set saving to file as a default export option

This commit is contained in:
Peter Knut
2024-03-17 21:12:35 +01:00
parent 835c10674b
commit f38c0a1f13
5 changed files with 12 additions and 9 deletions

View File

@@ -147,16 +147,14 @@ if ($jush == "sql") { //! use insertUpdate() in all drivers
} }
parse_str($_COOKIE["adminer_export"], $row); parse_str($_COOKIE["adminer_export"], $row);
if (!$row) { if (!$row) {
$row = array("output" => "text", "format" => "sql", "db_style" => (DB != "" ? "" : "CREATE"), "table_style" => "DROP+CREATE", "data_style" => "INSERT"); $row = array("output" => "file", "format" => "sql", "db_style" => (DB != "" ? "" : "CREATE"), "table_style" => "DROP+CREATE", "data_style" => "INSERT");
} }
if (!isset($row["events"])) { // backwards compatibility if (!isset($row["events"])) { // backwards compatibility
$row["routines"] = $row["events"] = ($_GET["dump"] == ""); $row["routines"] = $row["events"] = ($_GET["dump"] == "");
$row["triggers"] = $row["table_style"]; $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('Format') . "<td>" . html_select("format", $adminer->dumpFormat(), $row["format"], false) . "\n"; // false = radio
echo "<tr><th>" . lang('Format') . "<td>" . html_select("format", $adminer->dumpFormat(), $row["format"], 0) . "\n"; // 0 - radio
echo ($jush == "sqlite" ? "" : "<tr><th>" . lang('Database') . "<td>" . html_select('db_style', $db_style, $row["db_style"]) echo ($jush == "sqlite" ? "" : "<tr><th>" . lang('Database') . "<td>" . html_select('db_style', $db_style, $row["db_style"])
. (support("routine") ? checkbox("routines", 1, $row["routines"], lang('Routines')) : "") . (support("routine") ? checkbox("routines", 1, $row["routines"], lang('Routines')) : "")
@@ -169,6 +167,9 @@ echo "<tr><th>" . lang('Tables') . "<td>" . html_select('table_style', $table_st
; ;
echo "<tr><th>" . lang('Data') . "<td>" . html_select('data_style', $data_style, $row["data_style"]); echo "<tr><th>" . lang('Data') . "<td>" . html_select('data_style', $data_style, $row["data_style"]);
echo "<tr><th>" . lang('Output') . "<td>" . html_select("output", $adminer->dumpOutput(), $row["output"], false) . "\n"; // false = radio
?> ?>
</table> </table>
<p><input type="submit" value="<?php echo lang('Export'); ?>"> <p><input type="submit" value="<?php echo lang('Export'); ?>">

View File

@@ -755,10 +755,11 @@ class Adminer {
* @return array * @return array
*/ */
function dumpOutput() { function dumpOutput() {
$return = array('text' => lang('open'), 'file' => lang('save')); $return = array('file' => lang('save'), 'text' => lang('open'));
if (function_exists('gzencode')) { if (function_exists('gzencode')) {
$return['gz'] = 'gzip'; $return['gz'] = 'gzip';
} }
return $return; return $return;
} }

View File

@@ -213,7 +213,7 @@ function optionlist($options, $selected = null, $use_keys = false) {
* @param string * @param string
* @param array * @param array
* @param string * @param string
* @param string true for no onchange, false for radio * @param string|bool true for no onchange, false for radio
* @param string * @param string
* @return string * @return string
*/ */

View File

@@ -568,9 +568,9 @@ if (!$columns && support("table")) {
} }
if ($format) { if ($format) {
print_fieldset("export", lang('Export') . " <span id='selected2'></span>"); print_fieldset("export", lang('Export') . " <span id='selected2'></span>");
$output = $adminer->dumpOutput();
echo ($output ? html_select("output", $output, $adminer_import["output"]) . " " : "");
echo html_select("format", $format, $adminer_import["format"]); echo html_select("format", $format, $adminer_import["format"]);
$output = $adminer->dumpOutput();
echo ($output ? " " . html_select("output", $output, $adminer_import["output"]) : "");
echo " <input type='submit' name='export' value='" . lang('Export') . "'>\n"; echo " <input type='submit' name='export' value='" . lang('Export') . "'>\n";
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
} }
@@ -586,7 +586,7 @@ if (!$columns && support("table")) {
echo script("qsl('a').onclick = partial(toggle, 'import');", ""); echo script("qsl('a').onclick = partial(toggle, 'import');", "");
echo "<span id='import' class='hidden'>: "; echo "<span id='import' class='hidden'>: ";
echo "<input type='file' name='csv_file'> "; 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 " <input type='submit' name='import' value='" . lang('Import') . "'>";
echo "</span>"; echo "</span>";
echo "</div>"; echo "</div>";

View File

@@ -5,6 +5,7 @@ Adminer 4.9.0-dev:
- Update hydra and pepa-lintha-dark themes. - Update hydra and pepa-lintha-dark themes.
- Elasticsearch 5: Make unusable driver usable again, move it to plugins. - Elasticsearch 5: Make unusable driver usable again, move it to plugins.
- Add new Elasticsearch 7 driver. - Add new Elasticsearch 7 driver.
- Set saving to file as a default export option.
Adminer 4.8.2 (released 2024-03-16): Adminer 4.8.2 (released 2024-03-16):
Support multi-line table comments Support multi-line table comments