From 80ebf88293f5c1dcea2d529884e3daa12e5dfedd Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Sat, 27 Sep 2008 01:51:14 +0000 Subject: [PATCH] Clone row git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@501 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- edit.inc.php | 12 ++++++------ index.php | 2 +- lang/cs.inc.php | 2 ++ select.inc.php | 2 +- todo.txt | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/edit.inc.php b/edit.inc.php index 3059bb83..053cb64c 100644 --- a/edit.inc.php +++ b/edit.inc.php @@ -2,12 +2,12 @@ $where = where($_GET); $fields = fields($_GET["edit"]); foreach ($fields as $name => $field) { - if (isset($_GET["default"]) ? $field["auto_increment"] || preg_match('~text|blob~', $field["type"]) : !isset($field["privileges"][$where ? "update" : "insert"])) { + if (isset($_GET["default"]) ? $field["auto_increment"] || preg_match('~text|blob~', $field["type"]) : !isset($field["privileges"][$where && !$_GET["clone"] ? "update" : "insert"])) { unset($fields[$name]); } } if ($_POST && !$error) { - $location = $SELF . (isset($_GET["default"]) ? "table=" : ($_POST["insert"] ? "edit=" : "select=")) . urlencode($_GET["edit"]); + $location = ($_POST["insert"] ? $_SERVER["REQUEST_URI"] : $SELF . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"])); if (isset($_POST["delete"])) { query_redirect("DELETE FROM " . idf_escape($_GET["edit"]) . " WHERE " . implode(" AND ", $where) . " LIMIT 1", $location, lang('Item has been deleted.')); } else { @@ -29,7 +29,7 @@ if ($_POST && !$error) { } if (isset($_GET["default"])) { query_redirect("ALTER TABLE " . idf_escape($_GET["edit"]) . implode(",", $set), $location, lang('Default values has been set.')); - } elseif ($where) { + } elseif ($where && !$_GET["clone"]) { query_redirect("UPDATE " . idf_escape($_GET["edit"]) . " SET " . implode(", ", $set) . " WHERE " . implode(" AND ", $where) . " LIMIT 1", $location, lang('Item has been updated.')); } else { query_redirect("INSERT INTO " . idf_escape($_GET["edit"]) . " SET " . implode(", ", $set), $location, lang('Item has been inserted.')); @@ -47,7 +47,7 @@ if ($_POST) { } elseif ($where) { $select = array(); foreach ($fields as $name => $field) { - if (isset($field["privileges"]["select"]) && !preg_match('~binary|blob~', $field["type"])) { + if (isset($field["privileges"]["select"]) && !preg_match('~binary|blob~', $field["type"]) && (!$_GET["clone"] || !$field["auto_increment"])) { $select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name); } } @@ -94,8 +94,8 @@ if ($fields) { - +" /> - +

diff --git a/index.php b/index.php index dc19619f..fe6f5bfe 100644 --- a/index.php +++ b/index.php @@ -159,7 +159,7 @@ if (isset($_GET["download"])) { while ($row = $result->fetch_assoc()) { echo '' . (isset($row["Rows"]) ? '' . htmlspecialchars($row["Name"]) . "$row[Engine]$row[Collation]" : ' ' . htmlspecialchars($row["Name"]) . '' . lang('View')); $row["count"] = $mysql->result($mysql->query("SELECT COUNT(*) FROM " . idf_escape($row["Name"]))); - foreach ((isset($row["Rows"]) ? array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "", "Auto_increment" => "", "count" => "select") : array("count" => "select")) as $key => $link) { + foreach ((isset($row["Rows"]) ? array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "", "Auto_increment" => "") : array()) + array("count" => "select") as $key => $link) { $num = (strlen($row[$key]) ? number_format($row[$key], 0, '.', lang(',')) : ' '); echo '' . ($link ? '' . "$num" : $num); } diff --git a/lang/cs.inc.php b/lang/cs.inc.php index 0db862c9..269c450b 100644 --- a/lang/cs.inc.php +++ b/lang/cs.inc.php @@ -203,4 +203,6 @@ $translations = array( 'Move to other database' => 'Přesunout do jiné databáze', 'Move' => 'Přesunout', 'Engine' => 'Úložiště', + 'Save and continue edit' => 'Uložit a pokračovat v editaci', + 'clone' => 'klonovat', ); diff --git a/select.inc.php b/select.inc.php index c38a46d4..6c68e072 100644 --- a/select.inc.php +++ b/select.inc.php @@ -236,7 +236,7 @@ for (var i=0; > i; i++) { echo "\n"; } $unique_idf = implode('&', unique_idf($row, $indexes)); - echo '' . (count($select) == count($group) ? ' ' . lang('edit') . '' : ''); + echo '' . (count($select) == count($group) ? ' ' . lang('edit') . ' ' . lang('clone') . '' : ''); foreach ($row as $key => $val) { if (!isset($val)) { $val = "NULL"; diff --git a/todo.txt b/todo.txt index 3e08a4db..caa61fb9 100644 --- a/todo.txt +++ b/todo.txt @@ -1,7 +1,6 @@ Add whisperer to fields with foreign key Highlight found fields MySQL 5 BIT data type -Clone row Input function results in edit Bulk update - leave original, set to value, set to NULL Transactions in export @@ -9,6 +8,7 @@ Compress export and import Partitioning (MySQL 5.1) Create view and routine options Import CSV +Fix database encoding - http://php.vrana.cz/prevod-kodovani-mysql.php ? Execution time in sql.inc.php ? Save token also to cookie - for session expiration and login in other window ? Save uploaded files after error to session variable instead of hidden field