Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: vrana/adminer
...
head fork: vrana/adminer
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
4 adminer/create.inc.php
@@ -5,7 +5,7 @@
$referencable_primary = referencable_primary($TABLE);
$foreign_keys = array();
foreach ($referencable_primary as $table_name => $field) {
- $foreign_keys[idf_escape($table_name) . "." . idf_escape($field["field"])] = $table_name;
+ $foreign_keys[str_replace("`", "``", $table_name) . "`" . str_replace("`", "``", $field["field"])] = $table_name; // not idf_escape() - used in JS
}
$orig_fields = array();
@@ -44,7 +44,7 @@
$fields[] = array($field["orig"], $process_field, $after);
}
if (!isset($types[$field["type"]])) {
- $foreign[] = ($TABLE != "" ? "ADD " : " ") . "FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")";
+ $foreign[] = ($TABLE != "" ? "ADD " : " ") . "FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")" . (in_array($field["on_delete"], $on_actions) ? " ON DELETE $field[on_delete]" : "");
}
}
$after = "AFTER " . idf_escape($field["field"]);
View
13 adminer/include/adminer.inc.php
@@ -566,11 +566,18 @@ function navigation($missing) {
* @return null
*/
function tablesPrint($tables) {
- echo "<p id='tables'>\n";
+ echo "<ul id='tables'>\n";
+ $i = 1;
foreach ($tables as $table => $type) {
- echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '">' . bold(lang('select'), $_GET["select"] == $table) . '</a> ';
- echo '<a href="' . h(ME) . 'table=' . urlencode($table) . '">' . bold($this->tableName(array("Name" => $table)), $_GET["table"] == $table) . "</a><br>\n"; //! Adminer::tableName may work with full table status
+ echo "<li onmouseover=\"toggle('table-$i');\" onmouseout=\"toggle('table-$i');\"><a href='" . h(ME) . "table=" . urlencode($table) . "'>" . bold($this->tableName(array("Name" => $table)), $_GET["table"] == $table) . "</a>"; //! Adminer::tableName may work with full table status
+ echo "<span id='table-$i' class='hidden'>";
+ echo ' <a href="' . h(ME) . 'select=' . urlencode($table) . '">' . bold(lang('select'), $_GET["select"] == $table) . '</a>';
+ echo ' <a href="' . h(ME) . 'create=' . urlencode($table) . '">' . bold(lang('alter'), $_GET["create"] == $table) . '</a>';
+ echo ' <a href="' . h(ME) . 'edit=' . urlencode($table) . '">' . bold(lang('insert'), $_GET["edit"] == $table) . '</a>';
+ echo "</span>\n";
+ $i++;
}
+ echo "</ul>\n";
}
}
View
5 adminer/include/editing.inc.php
@@ -108,12 +108,13 @@ function referencable_primary($self) {
* @return null
*/
function edit_type($key, $field, $collations, $foreign_keys = array()) {
- global $structured_types, $unsigned, $inout;
+ global $structured_types, $unsigned, $inout, $on_actions;
?>
<td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"><td><?php
echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
- echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select> ' : ' '); // space for IE
+ echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
+ echo ($foreign_keys ? "<select name='$key" . "[on_delete]'" . (ereg("`", $field["type"]) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist($on_actions, $field["on_delete"]) . "</select> " : " "); // space for IE
}
/** Filter length value including enums
View
3  adminer/static/default.css
@@ -18,6 +18,7 @@ td img { max-width: 200px; max-height: 200px; }
code { background: #eee; }
tr:hover td, tr:hover th { background: #ddf; }
pre { margin: 1em 0 0; }
+ul { margin: 1em 0 0; }
.version { color: #777; font-size: 67%; }
.js .hidden { display: none; }
.nowrap td, .nowrap th, td.nowrap { white-space: pre; }
@@ -38,6 +39,8 @@ pre { margin: 1em 0 0; }
.type { width: 15ex; width: auto\9; }
#menu { position: absolute; margin: 10px 0 0; padding: 0 0 30px 0; top: 2em; left: 0; width: 19em; overflow: auto; overflow-y: hidden; white-space: nowrap; }
#menu p { padding: .8em 1em; margin: 0; border-bottom: 1px solid #ccc; }
+#tables { padding: 0 0 0 1em; }
+#tables li { list-style-type: none; }
#content { margin: 2em 0 0 21em; padding: 10px 20px 20px 0; }
#lang { position: absolute; top: 0; left: 0; line-height: 1.8em; padding: .3em 1em; }
#breadcrumb { white-space: nowrap; position: absolute; top: 0; left: 21em; background: #eee; height: 2em; line-height: 1.8em; padding: 0 1em; margin: 0 0 0 -18px; }
View
15 adminer/static/editing.js
@@ -83,7 +83,7 @@ function reEscape(s) {
* @return string
*/
function idfEscape(s) {
- return '`' + s.replace(/`/, '``') + '`';
+ return s.replace(/`/, '``');
}
/** Detect foreign key
@@ -102,14 +102,14 @@ function editingNameChange(field) {
}
var plural = '(?:e?s)?';
var tabCol = table + plural + '_?' + column;
- var re = new RegExp('(^' + idfEscape(table + plural) + '\\.' + idfEscape(column) + '$' // table_column
- + '|^' + idfEscape(tabCol) + '\\.' // table
- + '|^' + idfEscape(column + plural) + '\\.' + idfEscape(table) + '$' // column_table
- + ')|\\.' + idfEscape(tabCol) + '$' // column
+ var re = new RegExp('(^' + idfEscape(table + plural) + '`' + idfEscape(column) + '$' // table_column
+ + '|^' + idfEscape(tabCol) + '`' // table
+ + '|^' + idfEscape(column + plural) + '`' + idfEscape(table) + '$' // column_table
+ + ')|`' + idfEscape(tabCol) + '$' // column
, 'i');
var candidate; // don't select anything with ambiguous match (like column `id`)
for (var i = opts.length; i--; ) {
- if (opts[i].value.substr(0, 1) != '`') { // common type
+ if (!/`/.test(opts[i].value)) { // common type
if (i == opts.length - 2 && candidate && !match[1] && name == 'fields[1]') { // single target table, link to column, first field - probably `id`
return false;
}
@@ -215,6 +215,9 @@ function editingTypeChange(type) {
if (el.name == name + '[unsigned]') {
el.className = (/(int|float|double|decimal)$/.test(text) ? '' : 'hidden');
}
+ if (el.name == name + '[on_delete]') {
+ el.className = (/`/.test(text) ? '' : 'hidden');
+ }
}
}

No commit comments for this range

Something went wrong with that request. Please try again.