Maintain insert prefill value
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@957 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
1589362522
commit
db46fc24cb
|
@ -8,10 +8,16 @@ foreach ($fields as $name => $field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_POST && !$error && !isset($_GET["select"])) {
|
if ($_POST && !$error && !isset($_GET["select"])) {
|
||||||
$location = ($_POST["insert"] // continue edit or insert
|
$location = $_SERVER["REQUEST_URI"]; // continue edit or insert
|
||||||
? $_SERVER["REQUEST_URI"]
|
if (!$_POST["insert"]) {
|
||||||
: ME . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]) //! append &set converted to &where
|
$location = ME . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]);
|
||||||
);
|
$i = 0; // append &set converted to &where
|
||||||
|
foreach ((array) $_GET["set"] as $key => $val) {
|
||||||
|
if ($val == $_POST["fields"][$key]) {
|
||||||
|
$location .= where_link($i++, bracket_escape($key, "back"), $val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$set = array();
|
$set = array();
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
$val = process_input($field);
|
$val = process_input($field);
|
||||||
|
|
|
@ -94,7 +94,7 @@ function where_check($val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function where_link($i, $column, $value) {
|
function where_link($i, $column, $value) {
|
||||||
return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($value);
|
return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect($location, $message = null) {
|
function redirect($location, $message = null) {
|
||||||
|
|
|
@ -220,17 +220,18 @@ if (!$columns) {
|
||||||
$val = nl2br(h($val));
|
$val = nl2br(h($val));
|
||||||
}
|
}
|
||||||
|
|
||||||
// link related items
|
if (!$link) { // link related items
|
||||||
foreach ((array) $foreign_keys[$key] as $foreign_key) {
|
foreach ((array) $foreign_keys[$key] as $foreign_key) {
|
||||||
if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
|
if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
|
||||||
foreach ($foreign_key["source"] as $i => $source) {
|
foreach ($foreign_key["source"] as $i => $source) {
|
||||||
$link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]);
|
$link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]);
|
||||||
}
|
}
|
||||||
$link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"])) . $link; // InnoDB supports non-UNIQUE keys
|
$link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link); // InnoDB supports non-UNIQUE keys
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!$link && is_email($val)) {
|
if (!$link && is_email($val)) {
|
||||||
$link = "mailto:$val";
|
$link = "mailto:$val";
|
||||||
}
|
}
|
||||||
|
@ -242,13 +243,12 @@ if (!$columns) {
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
foreach ($table_names as $table => $name) {
|
foreach ($table_names as $table => $name) {
|
||||||
foreach ($backward_keys[$table] as $columns) {
|
foreach ($backward_keys[$table] as $columns) {
|
||||||
echo " <a href='" . h(ME) . 'select=' . urlencode($table);
|
$link = ME . 'select=' . urlencode($table);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($columns as $column => $val) {
|
foreach ($columns as $column => $val) {
|
||||||
echo where_link($i, $column, $rows[$n][$val]);
|
$link .= where_link($i++, $column, $rows[$n][$val]);
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
echo "'>$name</a>";
|
echo " <a href='" . h($link) . "'>$name</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue