]> git.joonet.de Git - adminer.git/commitdiff
Separate checkbox
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 25 Sep 2009 12:03:30 +0000 (12:03 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 25 Sep 2009 12:03:30 +0000 (12:03 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1147 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/db.inc.php
adminer/dump.inc.php
adminer/event.inc.php
adminer/include/adminer.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php
adminer/processlist.inc.php
adminer/select.inc.php
adminer/sql.inc.php
adminer/user.inc.php

index 58156cde69f1719547c26aae3289d0a836fb76dd..7b8fd599353392eef1b61a1b04a405d2d2429e7b 100644 (file)
@@ -50,7 +50,7 @@ if (!$table_status) {
        echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="form_check(this, /^(tables|views)\[/);"><th>' . lang('Table') . '<td>' . lang('Engine') . '<td>' . lang('Collation') . '<td>' . lang('Data Length') . '<td>' . lang('Index Length') . '<td>' . lang('Data Free') . '<td>' . lang('Auto Increment') . '<td>' . lang('Rows') . '<td>' . lang('Comment') . "</thead>\n";
        foreach ($table_status as $row) {
                $name = $row["Name"];
-               echo '<tr' . odd() . '><td><input type="checkbox" name="' . (isset($row["Rows"]) ? 'tables' : 'views') . '[]" value="' . h($name) . '"' . (in_array($name, $tables_views, true) ? ' checked' : '') . ' onclick="form_uncheck(\'check-all\');">';
+               echo '<tr' . odd() . '><td>' . checkbox((isset($row["Rows"]) ? "tables[]" : "views[]"), $name, in_array($name, $tables_views, true), "", "form_uncheck('check-all');");
                echo '<th><a href="' . h(ME) . 'table=' . urlencode($name) . '">' . h($name) . '</a>';
                if (isset($row["Rows"])) {
                        echo "<td>$row[Engine]<td>$row[Collation]";
index c3c2e80fd70a8955fa3404daed010788e8cc4aa7..c36bfdcf44b2f3480cd42578ad07c84be91d3caa 100644 (file)
@@ -148,12 +148,10 @@ echo "<tr><th>" . lang('Format') . "<td>$dump_format\n";
 echo "<tr><th>" . lang('Compression') . "<td>" . ($dump_compress ? $dump_compress : lang('None of the supported PHP extensions (%s) are available.', 'zlib, bz2')) . "\n";
 echo "<tr><th>" . lang('Database') . "<td><select name='db_style'>" . optionlist($db_style, (strlen(DB) ? '' : 'CREATE')) . "</select>\n";
 if ($connection->server_info >= 5) {
-       $objects = array('routines' => lang('Routines'));
+       $checked = strlen($_GET["dump"]);
+       checkbox("routines", 1, $checked, lang('Routines'));
        if ($connection->server_info >= 5.1) {
-               $objects['events'] = lang('Events');
-       }
-       foreach ($objects as $key => $val) {
-               echo " <label><input type='checkbox' name='$key' value='1'" . (strlen($_GET["dump"]) ? "" : " checked") . ">$val</label>";
+               checkbox("events", 1, $checked, lang('Events'));
        }
 }
 echo "<tr><th>" . lang('Tables') . "<td><select name='table_style'>" . optionlist($table_style, 'DROP+CREATE') . "</select>\n";
@@ -172,12 +170,12 @@ if (strlen(DB)) {
        echo "</thead>\n";
        $views = "";
        foreach (table_status() as $row) {
-               $checked = (strlen($TABLE) && $row["Name"] != $TABLE ? '' : " checked");
-               $print = "<tr><td><label><input type='checkbox' name='tables[]' value='" . h($row["Name"]) . "'$checked onclick=\"form_uncheck('check-tables');\">" . h($row["Name"]) . "</label>";
+               $checked = (strlen($TABLE) && $row["Name"] != $TABLE);
+               $print = "<tr><td>" . checkbox("tables[]", $row["Name"], $checked, $row["Name"], "form_uncheck('check-tables');");
                if (!$row["Engine"]) {
                        $views .= "$print\n";
                } else {
-                       echo "$print<td align='right'><label>" . ($row["Engine"] == "InnoDB" && $row["Rows"] ? lang('~ %s', $row["Rows"]) : $row["Rows"]) . "<input type='checkbox' name='data[]' value='" . h($row["Name"]) . "'$checked onclick=\"form_uncheck('check-data');\"></label>\n";
+                       echo "$print<td align='right'><label>" . ($row["Engine"] == "InnoDB" && $row["Rows"] ? lang('~ %s', $row["Rows"]) : $row["Rows"]) . checkbox("data[]", $row["Name"], $checked, "", "form_uncheck('check-data');") . "</label>\n";
                }
        }
        echo $views;
@@ -185,7 +183,7 @@ if (strlen(DB)) {
        echo "<thead><tr><th style='text-align: left;'><label><input type='checkbox' id='check-databases' checked onclick='form_check(this, /^databases\\[/);'>" . lang('Database') . "</label></thead>\n";
        foreach (get_databases() as $db) {
                if (!information_schema($db)) {
-                       echo '<tr><td><label><input type="checkbox" name="databases[]" value="' . h($db) . '" checked onclick="form_uncheck(\'check-databases\');">' . h($db) . "</label>\n";
+                       echo "<tr><td>" . checkbox("databases[]", $db, 1, $db, "form_uncheck('check-databases');") . "</label>\n";
                }
        }
 }
index e00cfc50d6ab6758320444ed27c2e97d6e62c1b3..4a35f804c39c1243c48f2b3b2ac25ee2d25c532a 100644 (file)
@@ -43,7 +43,7 @@ if ($_POST) {
 <tr><th><?php echo lang('Every'); ?><td><input name="INTERVAL_VALUE" value="<?php echo h($row["INTERVAL_VALUE"]); ?>" size="6"> <select name="INTERVAL_FIELD"><?php echo optionlist($intervals, $row["INTERVAL_FIELD"]); ?></select>
 <tr><th><?php echo lang('Status'); ?><td><select name="STATUS"><?php echo optionlist($statuses, $row["STATUS"]); ?></select>
 <tr><th><?php echo lang('Comment'); ?><td><input name="EVENT_COMMENT" value="<?php echo h($row["EVENT_COMMENT"]); ?>" maxlength="64">
-<tr><th>&nbsp;<td><label><input type="checkbox" name="ON_COMPLETION" value="PRESERVE"<?php echo ($row["ON_COMPLETION"] == "PRESERVE" ? " checked" : ""); ?>><?php echo lang('On completion preserve'); ?></label>
+<tr><th>&nbsp;<td><?php echo checkbox("ON_COMPLETION", "PRESERVE", $row["ON_COMPLETION"] == "PRESERVE", lang('On completion preserve')); ?>
 </table>
 <p><textarea name="EVENT_DEFINITION" rows="10" cols="80" style="width: 98%;"><?php echo h($row["EVENT_DEFINITION"]); ?></textarea>
 <p>
index 6372dde1ebcaf04321fd604ee88b7a26bdea81bc..1cc9b96244d2c65b81b6202efc4a33aa96807447 100644 (file)
@@ -183,7 +183,7 @@ class Adminer {
                        if ($index["type"] == "FULLTEXT") {
                                echo "(<i>" . implode("</i>, <i>", array_map('h', $index["columns"])) . "</i>) AGAINST";
                                echo " <input name='fulltext[$i]' value='" . h($_GET["fulltext"][$i]) . "'>";
-                               echo "<label><input type='checkbox' name='boolean[$i]' value='1'" . (isset($_GET["boolean"][$i]) ? " checked" : "") . ">BOOL</label>";
+                               echo checkbox("boolean[$i]", 1, isset($_GET["boolean"][$i]), "BOOL");
                                echo "<br>\n";
                        }
                }
@@ -214,12 +214,12 @@ class Adminer {
                foreach ((array) $_GET["order"] as $key => $val) {
                        if (isset($columns[$val])) {
                                echo "<div><select name='order[$i]'><option>" . optionlist($columns, $val, true) . "</select>";
-                               echo "<label><input type='checkbox' name='desc[$i]' value='1'" . (isset($_GET["desc"][$key]) ? " checked" : "") . ">" . lang('descending') . "</label></div>\n";
+                               echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending')) . "</div>\n";
                                $i++;
                        }
                }
                echo "<div><select name='order[$i]' onchange='select_add_row(this);'><option>" . optionlist($columns, null, true) . "</select>";
-               echo "<label><input type='checkbox' name='desc[$i]' value='1'>" . lang('descending') . "</label></div>\n";
+               echo checkbox("desc[$i]", 1, 0, lang('descending')) . "</div>\n";
                echo "</div></fieldset>\n";
        }
        
index 88a8f1ff90760dd855fc8c432d0ff026cc3602ae..6b22e0a69e46b14abb84d97d64f780464f2d1522 100644 (file)
@@ -176,9 +176,9 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $forei
 <th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="<?php echo (strlen($field["field"]) || count($fields) > 1 ? "" : "editing_add_row(this, $allowed); "); ?>editing_name_change(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($field[($_POST ? "orig" : "field")]); ?>">
 <?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
 <?php if ($type == "TABLE") { ?>
-<td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked<?php } ?>>
+<td><?php echo checkbox("fields[$i][null]", 1, $field["null"]); ?>
 <td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?>>
-<td class="nowrap hidden"><input type="checkbox" name="fields[<?php echo $i; ?>][has_default]" value="1"<?php echo ($field["has_default"] ? " checked" : ""); ?>><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" onchange="this.previousSibling.checked = true;">
+<td class="nowrap hidden"><?php echo checkbox("fields[$i][has_default]", 1, $field["has_default"]); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" onchange="this.previousSibling.checked = true;">
 <td<?php echo ($column_comments ? "" : " class='hidden'"); ?>><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo h($field["comment"]); ?>" maxlength="255">
 <?php } ?>
 <?php
index 007ecf13335538993728286f9de2608a8b91d098..14eef590479cd9b8b65fa0337ea4f8553ffb4fdb 100644 (file)
@@ -59,6 +59,19 @@ function nbsp($string) {
        return (strlen(trim($string)) ? h($string) : "&nbsp;");
 }
 
+/** Generate HTML checkbox
+* @param string
+* @param string
+* @param bool
+* @param string
+* @param string
+* @return string
+*/
+function checkbox($name, $value, $checked, $label = "", $onclick = "") {
+       $return = "<input type='checkbox' name='$name' value='" . h($value) . "'" . ($checked ? " checked" : "") . ($onclick ? " onclick=\"$onclick\"" : "") . ">";
+       return (strlen($label) ? "<label>$return" . h($label) . "</label>" : $return);
+}
+
 /** Generate list of HTML options
 * @param array array of strings or arrays (creates optgroup)
 * @param mixed
index 1be05d02380f8446f12863c3aedd76a0bcb71829..d2e368f5437d479433e91fd33e2317c9c863b772 100644 (file)
@@ -20,7 +20,7 @@ for ($i=0; $row = $result->fetch_assoc(); $i++) {
        if (!$i) {
                echo "<thead><tr lang='en'><th>&nbsp;<th>" . implode("<th>", array_keys($row)) . "</thead>\n";
        }
-       echo "<tr" . odd() . "><td><input type='checkbox' name='kill[]' value='$row[Id]'><td>" . implode("<td>", array_map('nbsp', $row)) . "\n";
+       echo "<tr" . odd() . "><td>" . checkbox("kill[]", $row["Id"], 0) . "<td>" . implode("<td>", array_map('nbsp', $row)) . "\n";
 }
 ?>
 </table>
index ad77fdb66ff6240f0101ef51fc06aa5da5725079..2cc6db67e9301daa91386c236f70b15f030f2890 100644 (file)
@@ -194,8 +194,8 @@ if (!$columns) {
                        }
                        echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
                        foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
-                               $unique_idf = implode('&amp;', unique_idf($rows[$n], $indexes));
-                               echo "<tr" . odd() . "><td><input type='checkbox' name='check[]' value='$unique_idf'" . (in_array(str_replace("&amp;", "&", $unique_idf), (array) $_POST["check"]) ? " checked" : "") . " onclick=\"this.form['all'].checked = false; form_uncheck('all-page');\">" . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME) . "edit=" . urlencode($TABLE) . "&amp;$unique_idf'>" . lang('edit') . "</a>");
+                               $unique_idf = implode('&', unique_idf($rows[$n], $indexes));
+                               echo "<tr" . odd() . "><td>" . checkbox("check[]", $unique_idf, in_array($unique_idf, (array) $_POST["check"]), "", "this.form['all'].checked = false; form_uncheck('all-page');") . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . "&$unique_idf") . "'>" . lang('edit') . "</a>");
                                foreach ($row as $key => $val) {
                                        if (isset($names[$key])) {
                                                if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) {
@@ -207,7 +207,7 @@ if (!$columns) {
                                                        $val = "<i>NULL</i>";
                                                } else {
                                                        if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) {
-                                                               $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . '&') . $unique_idf;
+                                                               $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . "&$unique_idf");
                                                        }
                                                        if (!strlen($val)) {
                                                                $val = "&nbsp;";
@@ -257,7 +257,7 @@ if (!$columns) {
                                }
                                echo ($_GET["page"] + 3 < $max_page ? " ..." : "") . pagination($max_page);
                        }
-                       echo " (" . lang('%d row(s)', $found_rows) . ') <label><input type="checkbox" name="all" value="1">' . lang('whole result') . "</label>\n";
+                       echo " (" . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\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'));
index ef30a8318ead392a6e7e7f2dd2e9169d55ad7e60..5fdf40af7b1eae398ae26c126a841179975e1407 100644 (file)
@@ -129,7 +129,7 @@ echo h($q);
 <p>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 <input type="submit" value="<?php echo lang('Execute'); ?>">
-<label><input type="checkbox" name="error_stops" value="1"<?php echo ($_POST["error_stops"] ? " checked" : ""); ?>><?php echo lang('Stop on error'); ?></label>
+<?php echo checkbox("error_stops", 1, $_POST["error_stops"], lang('Stop on error')); ?>
 
 <p>
 <?php
index 163c51bba8b185cf22d2b3b8f6571816d37cd607..42da4b4faedea02c1cd2ce5de8f5932d1d1e7243 100644 (file)
@@ -118,7 +118,9 @@ if ($_POST) {
 <table cellspacing="0">
 <tr><th><?php echo lang('Username'); ?><td><input name="user" maxlength="16" value="<?php echo h($row["user"]); ?>">
 <tr><th><?php echo lang('Server'); ?><td><input name="host" maxlength="60" value="<?php echo h($row["host"]); ?>">
-<tr><th><?php echo lang('Password'); ?><td><input id="pass" name="pass" value="<?php echo h($row["pass"]); ?>"><?php if (!$row["hashed"]) { ?><script type="text/javascript">type_password(document.getElementById('pass'));</script><?php } ?> <label><input type="checkbox" name="hashed" value="1"<?php if ($row["hashed"]) { ?> checked<?php } ?> onclick="type_password(this.form['pass'], this.checked);"><?php echo lang('Hashed'); ?></label>
+<tr><th><?php echo lang('Password'); ?><td><input id="pass" name="pass" value="<?php echo h($row["pass"]); ?>">
+<?php if (!$row["hashed"]) { ?><script type="text/javascript">type_password(document.getElementById('pass'));</script><?php } ?>
+<?php echo checkbox("hashed", 1, $row["hashed"], lang('Hashed'), "type_password(this.form['pass'], this.checked);"); ?>
 </table>
 
 <?php