]> git.joonet.de Git - adminer.git/commitdiff
Display number of manipulated rows in JS confirm
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 23 Sep 2009 12:21:14 +0000 (12:21 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 23 Sep 2009 12:21:14 +0000 (12:21 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1133 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/db.inc.php
adminer/select.inc.php
adminer/static/functions.js
changes.txt
editor/include/adminer.inc.php

index 6e45de49ea0ecf84498f066caaa5a80e9f0fea5c..58156cde69f1719547c26aae3289d0a836fb76dd 100644 (file)
@@ -8,15 +8,13 @@ if ($tables_views && !$error) {
                queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once
        }
        if (isset($_POST["truncate"])) {
-               if ($_POST["tables"]) {
-                       foreach ($_POST["tables"] as $table) {
-                               if (!queries("TRUNCATE " . idf_escape($table))) {
-                                       $result = false;
-                                       break;
-                               }
+               foreach ((array) $_POST["tables"] as $table) {
+                       if (!queries("TRUNCATE " . idf_escape($table))) {
+                               $result = false;
+                               break;
                        }
-                       $message = lang('Tables have been truncated.');
                }
+               $message = lang('Tables have been truncated.');
        } elseif (isset($_POST["move"])) {
                $rename = array();
                foreach ($tables_views as $table) {
@@ -66,7 +64,7 @@ if (!$table_status) {
                }
        }
        echo "</table>\n";
-       echo "<p><input type='hidden' name='token' value='$token'><input type='submit' value='" . lang('Analyze') . "'> <input type='submit' name='optimize' value='" . lang('Optimize') . "'> <input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> <input type='submit' name='truncate' value='" . lang('Truncate') . "'$confirm> <input type='submit' name='drop' value='" . lang('Drop') . "'$confirm>\n";
+       echo "<p><input type='hidden' name='token' value='$token'><input type='submit' value='" . lang('Analyze') . "'> <input type='submit' name='optimize' value='" . lang('Optimize') . "'> <input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> <input type='submit' name='truncate' value='" . lang('Truncate') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + form_checked(this, /tables/) + ')');\"> <input type='submit' name='drop' value='" . lang('Drop') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + form_checked(this, /tables|views/) + ')');\">\n";
        $dbs = get_databases();
        if (count($dbs) != 1) {
                $db = (isset($_POST["target"]) ? $_POST["target"] : DB);
index e942653729e7df70c80db5b9c2ef2034ceae7570..a698e16dd75f8ce53db660dc1e6bfde1d7aa7706 100644 (file)
@@ -280,7 +280,7 @@ if (!$columns) {
                        }
                        echo " (" . lang('%d row(s)', $found_rows) . ') <label><input type="checkbox" name="all" value="1">' . lang('whole result') . "</label>\n";
                        
-                       echo (information_schema(DB) ? "" : "<fieldset><legend>" . lang('Edit') . "</legend><div><input type='submit' name='edit' value='" . lang('Edit') . "'> <input type='submit' name='clone' value='" . lang('Clone') . "'> <input type='submit' name='delete' value='" . lang('Delete') . "'$confirm></div></fieldset>\n");
+                       echo (information_schema(DB) ? "" : "<fieldset><legend>" . lang('Edit') . "</legend><div><input type='submit' name='edit' value='" . lang('Edit') . "'> <input type='submit' name='clone' value='" . lang('Clone') . "'> <input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + (this.form['all'].checked ? $found_rows : form_checked(this, /check/)) + ')');\"></div></fieldset>\n");
                        print_fieldset("export", lang('Export'));
                        echo "$dump_output $dump_format $dump_compress <input type='submit' name='export' value='" . lang('Export') . "'>\n";
                        echo "</div></fieldset>\n";
index 5b882b96ccd25921efbc4c78049132ed7b3e3ee7..4a3b3fe363dcaf09430379366a8a012b585c2770 100644 (file)
@@ -26,6 +26,17 @@ function form_uncheck(id) {
        document.getElementById(id).checked = false;
 }
 
+function form_checked(el, name) {
+       var checked = 0;
+       var elems = el.form.elements;
+       for (var i=0; i < elems.length; i++) {
+               if (name.test(elems[i].name) && elems[i].checked) {
+                       checked++;
+               }
+       }
+       return checked;
+}
+
 function table_click(event) {
        var el = event.target || event.srcElement;
        while (!/^tr$/i.test(el.tagName)) {
index cad43e08f6d57a3ade84707881d22f13cd8c48a1..ee1dbca811a8bc2c65b0afeb8dbf949afa563a24 100644 (file)
@@ -2,6 +2,7 @@ Adminer 2.1.1-dev:
 Display table links above table structure
 Fix removed default in ALTER
 Display whitespace in texts (bug #2858042)
+Display number of manipulated rows in JS confirm
 E-mail attachments (Editor)
 Move <h1> to $adminer->navigation (customization)
 Rename get_dbh to connection (customization)
index 60fb4ad6be033744000894d20c0a4859645fd7ac..aebe2920e1915f2bf0f065bb5d1589cc0e9785ee 100644 (file)
@@ -185,7 +185,6 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
        }
        
        function selectEmailPrint($emailFields, $columns) {
-               global $confirm;
                if ($emailFields) {
                        echo '<fieldset><legend><a href="#fieldset-email" onclick="return !toggle(\'fieldset-email\');">' . lang('E-mail') . "</a></legend><div id='fieldset-email'" . ($_POST["email_append"] ? "" : " class='hidden'") . ">\n";
                        echo "<p>" . lang('From') . ": <input name='email_from' value='" . h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
@@ -194,7 +193,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
                        echo "<select name='email_addition'>" . optionlist($columns, $_POST["email_addition"]) . "</select> <input type='submit' name='email_append' value='" . lang('Insert') . "'>\n"; //! JavaScript
                        echo "<p><input type='file' name='email_files[]' onchange=\"var el = this.cloneNode(true); el.value = ''; this.parentNode.appendChild(el);\">";
                        echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : '<select name="email_field">' . optionlist($emailFields) . '</select> ');
-                       echo "<input type='submit' name='email' value='" . lang('Send') . "'$confirm>\n";
+                       echo "<input type='submit' name='email' value='" . lang('Send') . "' onclick=\"return this.form['delete'].onclick();\">\n";
                        echo "</div></fieldset>\n";
                }
        }