]> git.joonet.de Git - adminer.git/commitdiff
Remove column or parameter by button
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 26 Jul 2007 09:18:58 +0000 (09:18 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 26 Jul 2007 09:18:58 +0000 (09:18 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@260 7c3ca157-0c34-0410-bff1-cbf682f78f5c

create.inc.php
editing.inc.php
procedure.inc.php

index 06195caa3fcadb2863aafc6d357cac910189bcc0..2ac1a29f0e20bd4db4657fb1f8a3256e0c11b789 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-if ($_POST && !$error && !$_POST["add"]) {
+if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
        if ($_POST["drop"]) {
                $query = "DROP TABLE " . idf_escape($_GET["create"]);
                $message = lang('Table has been dropped.');
@@ -68,11 +68,11 @@ $result->free();
 if ($_POST) {
        $row = $_POST;
        ksort($row["fields"]);
-       if (!$_POST["add"]) {
-               echo "<p class='error'>" . lang('Unable to operate table') . ": " . htmlspecialchars($error) . "</p>\n";
-               $row["fields"] = array_values($row["fields"]);
-       } else {
+       $row["fields"] = array_values($row["fields"]);
+       if ($_POST["add"]) {
                array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
+       } elseif (!$_POST["drop_col"]) {
+               echo "<p class='error'>" . lang('Unable to operate table') . ": " . htmlspecialchars($error) . "</p>\n";
        }
        if ($row["auto_increment_col"]) {
                $row["fields"][$row["auto_increment_col"] - 1]["auto_increment"] = true;
index 34fe6ab3255af4867582593aa3bd4dd3d184821d..ae455c0b85160a10b27912ea759f3798b030bca1 100644 (file)
@@ -102,14 +102,14 @@ function edit_fields($fields, $collations, $type = "TABLE") {
                ?>
 <tr>
 <?php if ($type == "PROCEDURE") { ?><td><select name="fields[<?php echo $i; ?>][inout]"><?php echo optionlist($inout, $field["inout"]); ?></select></td><?php } ?>
-<th><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>" /><input name="fields[<?php echo $i; ?>][field]" value="<?php echo htmlspecialchars($field["field"]); ?>" maxlength="64" /></th>
+<th><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>" /><input name="fields[<?php echo $i; ?>][field]" value="<?php echo ($_POST["drop_col"][$i] ? "" : htmlspecialchars($field["field"])); ?>" maxlength="64" /></th>
 <?php edit_type("fields[$i]", $field, $collations); ?>
 <?php if ($type == "TABLE") { ?>
 <td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked="checked"<?php } ?> /></td>
 <td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
 <td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
 <?php } ?>
-<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /></td>
+<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /> <input type="submit" name="drop_col[<?php echo $i; ?>]" value="<?php echo lang('Remove'); ?>" onclick="return !remove_row(this);" /></td>
 </tr>
 <?php
                if (strlen($field["comment"])) {
@@ -148,6 +148,11 @@ function add_row(button) {
        added += '0';
        return true;
 }
+function remove_row(button) {
+       button.form[button.name.replace(/drop_col(.+)/, 'fields$1[field]')].value = '';
+       button.parentNode.parentNode.style.display = 'none';
+       return true;
+}
 function type_change(type) {
        var name = type.name.substr(0, type.name.length - 6);
        type.form[name + '[collation]'].style.display = (/char|text|enum|set/.test(type.options[type.selectedIndex].text) ? '' : 'none');
index 5f3a081a09a07fc5aa8a105fb6b65482c0ead660..fa006d1836be8a45bf801203ed576424342d9a9e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 $routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
 
-if ($_POST && !$error && !$_POST["add"]) {
+if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
        if (strlen($_GET["procedure"]) && $mysql->query("DROP $routine " . idf_escape($_GET["procedure"])) && $_POST["drop"]) {
                redirect(substr($SELF, 0, -1), lang('Routine has been dropped.'));
        }
@@ -34,11 +34,11 @@ if ($_POST) {
        $row = $_POST;
        $row["fields"] = (array) $row["fields"];
        ksort($row["fields"]);
-       if (!$_POST["add"]) {
-               echo "<p class='error'>" . lang('Unable to operate routine') . ": " . htmlspecialchars($error) . "</p>\n";
-               $row["fields"] = array_values($row["fields"]);
-       } else {
+       $row["fields"] = array_values($row["fields"]);
+       if ($_POST["add"]) {
                array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
+       } elseif (!$_POST["drop_col"]) {
+               echo "<p class='error'>" . lang('Unable to operate routine') . ": " . htmlspecialchars($error) . "</p>\n";
        }
 } elseif (strlen($_GET["procedure"])) {
        $row = routine($_GET["procedure"], $routine);