1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 15:47:00 +02:00

Plugins: Add method dumpFooter()

This commit is contained in:
Jakub Vrana
2025-03-11 08:59:38 +01:00
parent b02c3e1f7f
commit 199edfe11f
10 changed files with 39 additions and 21 deletions

View File

@@ -140,9 +140,7 @@ SET foreign_key_checks = 0;
}
}
if ($is_sql) {
echo "-- " . gmdate("Y-m-d H:i:s e") . "\n";
}
$adminer->dumpFooter();
exit;
}

View File

@@ -945,6 +945,15 @@ class Adminer {
return $ext;
}
/** Print text after export
* @return null prints data
*/
function dumpFooter() {
if ($_POST["format"] == "sql") {
echo "-- " . gmdate("Y-m-d H:i:s e") . "\n";
}
}
/** Set the path of the file for webserver load
* @return string path of the sql dump file
*/

View File

@@ -100,6 +100,7 @@ if ($_POST && !$error) {
$query = implode(" UNION ALL ", $union);
}
$adminer->dumpData($TABLE, "table", $query);
$adminer->dumpFooter();
exit;
}

View File

@@ -5,6 +5,7 @@ if (!$error && $_POST["export"]) {
dump_headers("sql");
$adminer->dumpTable("", "");
$adminer->dumpData("", "table", $_POST["query"]);
$adminer->dumpFooter();
exit;
}

View File

@@ -9,6 +9,7 @@ MariaDB: Fix creating and altering generated columns (bug #897)
SQLite: Fix creating table in compiled version (bug #901, regression from 5.0.0)
Elastic: Do not pass null values on insert (PR #892)
Elastic: Fix displaying sparse rows (PR #893)
Plugins: Add method dumpFooter()
Adminer 5.0.2 (released 2025-03-10):
PostgreSQL: Fix setting NULL and original value on enum (bug #884)

View File

@@ -574,6 +574,9 @@ qsl('div').onclick = whisperClick;", "")
return $ext;
}
function dumpFooter() {
}
function importServerPath() {
}

View File

@@ -19,10 +19,6 @@ class AdminerDumpJson {
}
}
function _database() {
echo "}\n";
}
function dumpData($table, $style, $query) {
if ($_POST["format"] == "json") {
if ($this->database) {
@@ -30,7 +26,6 @@ class AdminerDumpJson {
} else {
$this->database = true;
echo "{\n";
register_shutdown_function(array($this, '_database'));
}
$connection = Adminer\connection();
$result = $connection->query($query, 1);
@@ -57,4 +52,10 @@ class AdminerDumpJson {
return "json";
}
}
function dumpFooter() {
if ($_POST["format"] == "json" && $this->database) {
echo "}\n";
}
}
}

View File

@@ -7,7 +7,6 @@
*/
class AdminerDumpPhp {
protected $output = array();
protected $shutdown_callback = false;
function dumpFormat() {
return array('php' => 'PHP');
@@ -23,10 +22,6 @@ class AdminerDumpPhp {
function dumpTable($table, $style, $is_view = 0) {
if ($_POST['format'] == 'php') {
$this->output[$table] = array();
if (!$this->shutdown_callback) {
$this->shutdown_callback = true;
register_shutdown_function(array($this, '_export'));
}
return true;
}
}
@@ -44,8 +39,11 @@ class AdminerDumpPhp {
}
}
function _export() {
function dumpFooter() {
if ($_POST['format'] == 'php') {
echo "<?php\n";
var_export($this->output);
echo ";\n";
}
}
}

View File

@@ -19,16 +19,11 @@ class AdminerDumpXml {
}
}
function _database() {
echo "</database>\n";
}
function dumpData($table, $style, $query) {
if ($_POST["format"] == "xml") {
if (!$this->database) {
$this->database = true;
echo "<database name='" . Adminer\h(Adminer\DB) . "'>\n";
register_shutdown_function(array($this, '_database'));
}
$connection = Adminer\connection();
$result = $connection->query($query, 1);
@@ -51,4 +46,10 @@ class AdminerDumpXml {
return "xml";
}
}
function dumpFooter() {
if ($_POST["format"] == "xml" && $this->database) {
echo "</database>\n";
}
}
}

View File

@@ -387,6 +387,11 @@ class AdminerPlugin extends Adminer\Adminer {
return $this->applyPlugin(__FUNCTION__, $args);
}
function dumpFooter() {
$args = func_get_args();
return $this->applyPlugin(__FUNCTION__, $args);
}
function importServerPath() {
$args = func_get_args();
return $this->applyPlugin(__FUNCTION__, $args);