Show table links if driver supports indexes
This commit is contained in:
parent
1c0c335d38
commit
4b6d02cdf8
|
@ -80,7 +80,7 @@ if ($adminer->homepage()) {
|
||||||
foreach ($tables_list as $name => $type) {
|
foreach ($tables_list as $name => $type) {
|
||||||
$view = ($type !== null && !preg_match('~table~i', $type));
|
$view = ($type !== null && !preg_match('~table~i', $type));
|
||||||
echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
|
echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
|
||||||
echo '<th>' . (support("table") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name));
|
echo '<th>' . (support("table") || support("indexes") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name));
|
||||||
if ($view) {
|
if ($view) {
|
||||||
echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '" title="' . lang('Alter view') . '">' . lang('View') . '</a>';
|
echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '" title="' . lang('Alter view') . '">' . lang('View') . '</a>';
|
||||||
echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '" title="' . lang('Select data') . '">?</a>';
|
echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '" title="' . lang('Select data') . '">?</a>';
|
||||||
|
@ -95,7 +95,7 @@ if ($adminer->homepage()) {
|
||||||
"Rows" => array("select", lang('Select data')),
|
"Rows" => array("select", lang('Select data')),
|
||||||
) as $key => $link) {
|
) as $key => $link) {
|
||||||
$id = " id='$key-" . h($name) . "'";
|
$id = " id='$key-" . h($name) . "'";
|
||||||
echo ($link ? "<td align='right'>" . (support("table") || $key == "Rows"
|
echo ($link ? "<td align='right'>" . (support("table") || $key == "Rows" || (support("indexes") && $key != "Data_length")
|
||||||
? "<a href='" . h(ME . "$link[0]=") . urlencode($name) . "'$id title='$link[1]'>?</a>"
|
? "<a href='" . h(ME . "$link[0]=") . urlencode($name) . "'$id title='$link[1]'>?</a>"
|
||||||
: "<span$id>?</span>"
|
: "<span$id>?</span>"
|
||||||
) : "<td id='$key-" . h($name) . "'> ");
|
) : "<td id='$key-" . h($name) . "'> ");
|
||||||
|
|
|
@ -128,8 +128,10 @@ username.form['auth[driver]'].onchange();
|
||||||
function selectLinks($tableStatus, $set = "") {
|
function selectLinks($tableStatus, $set = "") {
|
||||||
echo '<p class="links">';
|
echo '<p class="links">';
|
||||||
$links = array("select" => lang('Select data'));
|
$links = array("select" => lang('Select data'));
|
||||||
if (support("table")) {
|
if (support("table") || support("indexes")) {
|
||||||
$links["table"] = lang('Show structure');
|
$links["table"] = lang('Show structure');
|
||||||
|
}
|
||||||
|
if (support("table")) {
|
||||||
if (is_view($tableStatus)) {
|
if (is_view($tableStatus)) {
|
||||||
$links["view"] = lang('Alter view');
|
$links["view"] = lang('Alter view');
|
||||||
} else {
|
} else {
|
||||||
|
@ -854,7 +856,7 @@ username.form['auth[driver]'].onchange();
|
||||||
foreach ($tables as $table => $status) {
|
foreach ($tables as $table => $status) {
|
||||||
echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '"' . bold($_GET["select"] == $table || $_GET["edit"] == $table) . ">" . lang('select') . "</a> ";
|
echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '"' . bold($_GET["select"] == $table || $_GET["edit"] == $table) . ">" . lang('select') . "</a> ";
|
||||||
$name = $this->tableName($status);
|
$name = $this->tableName($status);
|
||||||
echo (support("table")
|
echo (support("table") || support("indexes")
|
||||||
? '<a href="' . h(ME) . 'table=' . urlencode($table) . '"' . bold(in_array($table, array($_GET["table"], $_GET["create"], $_GET["indexes"], $_GET["foreign"], $_GET["trigger"])), (is_view($status) ? "view" : "")) . " title='" . lang('Show structure') . "'>$name</a>"
|
? '<a href="' . h(ME) . 'table=' . urlencode($table) . '"' . bold(in_array($table, array($_GET["table"], $_GET["create"], $_GET["indexes"], $_GET["foreign"], $_GET["trigger"])), (is_view($status) ? "view" : "")) . " title='" . lang('Show structure') . "'>$name</a>"
|
||||||
: "<span>$name</span>"
|
: "<span>$name</span>"
|
||||||
) . "<br>\n";
|
) . "<br>\n";
|
||||||
|
|
|
@ -448,7 +448,7 @@ if (!$columns && support("table")) {
|
||||||
? $page + (count($rows) >= $limit ? 2 : 1)
|
? $page + (count($rows) >= $limit ? 2 : 1)
|
||||||
: floor(($found_rows - 1) / $limit)
|
: floor(($found_rows - 1) / $limit)
|
||||||
);
|
);
|
||||||
if (support("table")) {
|
if ($jush != "simpledb") {
|
||||||
echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "'), event); return false;\">" . lang('Page') . "</a>:";
|
echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "'), event); return false;\">" . lang('Page') . "</a>:";
|
||||||
echo pagination(0, $page) . ($page > 5 ? " ..." : "");
|
echo pagination(0, $page) . ($page > 5 ? " ..." : "");
|
||||||
for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
|
for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
|
||||||
|
|
|
@ -25,64 +25,63 @@ if ($fields) {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_view($table_status)) {
|
if (!is_view($table_status)) {
|
||||||
if (support("indexes")) {
|
if (support("indexes")) {
|
||||||
echo "<h3 id='indexes'>" . lang('Indexes') . "</h3>\n";
|
echo "<h3 id='indexes'>" . lang('Indexes') . "</h3>\n";
|
||||||
$indexes = indexes($TABLE);
|
$indexes = indexes($TABLE);
|
||||||
if ($indexes) {
|
if ($indexes) {
|
||||||
echo "<table cellspacing='0'>\n";
|
|
||||||
foreach ($indexes as $name => $index) {
|
|
||||||
ksort($index["columns"]); // enforce correct columns order
|
|
||||||
$print = array();
|
|
||||||
foreach ($index["columns"] as $key => $val) {
|
|
||||||
$print[] = "<i>" . h($val) . "</i>"
|
|
||||||
. ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
|
|
||||||
. ($index["descs"][$key] ? " DESC" : "")
|
|
||||||
;
|
|
||||||
}
|
|
||||||
echo "<tr title='" . h($name) . "'><th>$index[type]<td>" . implode(", ", $print) . "\n";
|
|
||||||
}
|
|
||||||
echo "</table>\n";
|
|
||||||
}
|
|
||||||
echo '<p class="links"><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fk_support($table_status)) {
|
|
||||||
echo "<h3 id='foreign-keys'>" . lang('Foreign keys') . "</h3>\n";
|
|
||||||
$foreign_keys = foreign_keys($TABLE);
|
|
||||||
if ($foreign_keys) {
|
|
||||||
echo "<table cellspacing='0'>\n";
|
|
||||||
echo "<thead><tr><th>" . lang('Source') . "<td>" . lang('Target') . "<td>" . lang('ON DELETE') . "<td>" . lang('ON UPDATE') . "<td> </thead>\n";
|
|
||||||
foreach ($foreign_keys as $name => $foreign_key) {
|
|
||||||
echo "<tr title='" . h($name) . "'>";
|
|
||||||
echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>";
|
|
||||||
echo "<td><a href='" . h($foreign_key["db"] != "" ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ($foreign_key["ns"] != "" ? preg_replace('~ns=[^&]*~', "ns=" . urlencode($foreign_key["ns"]), ME) : ME)) . "table=" . urlencode($foreign_key["table"]) . "'>"
|
|
||||||
. ($foreign_key["db"] != "" ? "<b>" . h($foreign_key["db"]) . "</b>." : "") . ($foreign_key["ns"] != "" ? "<b>" . h($foreign_key["ns"]) . "</b>." : "") . h($foreign_key["table"])
|
|
||||||
. "</a>"
|
|
||||||
;
|
|
||||||
echo "(<i>" . implode("</i>, <i>", array_map('h', $foreign_key["target"])) . "</i>)";
|
|
||||||
echo "<td>" . nbsp($foreign_key["on_delete"]) . "\n";
|
|
||||||
echo "<td>" . nbsp($foreign_key["on_update"]) . "\n";
|
|
||||||
echo '<td><a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>';
|
|
||||||
}
|
|
||||||
echo "</table>\n";
|
|
||||||
}
|
|
||||||
echo '<p class="links"><a href="' . h(ME) . 'foreign=' . urlencode($TABLE) . '">' . lang('Add foreign key') . "</a>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (support(is_view($table_status) ? "view_trigger" : "trigger")) {
|
|
||||||
echo "<h3 id='triggers'>" . lang('Triggers') . "</h3>\n";
|
|
||||||
$triggers = triggers($TABLE);
|
|
||||||
if ($triggers) {
|
|
||||||
echo "<table cellspacing='0'>\n";
|
echo "<table cellspacing='0'>\n";
|
||||||
foreach ($triggers as $key => $val) {
|
foreach ($indexes as $name => $index) {
|
||||||
echo "<tr valign='top'><td>$val[0]<td>$val[1]<th>" . h($key) . "<td><a href='" . h(ME . 'trigger=' . urlencode($TABLE) . '&name=' . urlencode($key)) . "'>" . lang('Alter') . "</a>\n";
|
ksort($index["columns"]); // enforce correct columns order
|
||||||
|
$print = array();
|
||||||
|
foreach ($index["columns"] as $key => $val) {
|
||||||
|
$print[] = "<i>" . h($val) . "</i>"
|
||||||
|
. ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
|
||||||
|
. ($index["descs"][$key] ? " DESC" : "")
|
||||||
|
;
|
||||||
|
}
|
||||||
|
echo "<tr title='" . h($name) . "'><th>$index[type]<td>" . implode(", ", $print) . "\n";
|
||||||
}
|
}
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
}
|
}
|
||||||
echo '<p class="links"><a href="' . h(ME) . 'trigger=' . urlencode($TABLE) . '">' . lang('Add trigger') . "</a>\n";
|
echo '<p class="links"><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fk_support($table_status)) {
|
||||||
|
echo "<h3 id='foreign-keys'>" . lang('Foreign keys') . "</h3>\n";
|
||||||
|
$foreign_keys = foreign_keys($TABLE);
|
||||||
|
if ($foreign_keys) {
|
||||||
|
echo "<table cellspacing='0'>\n";
|
||||||
|
echo "<thead><tr><th>" . lang('Source') . "<td>" . lang('Target') . "<td>" . lang('ON DELETE') . "<td>" . lang('ON UPDATE') . "<td> </thead>\n";
|
||||||
|
foreach ($foreign_keys as $name => $foreign_key) {
|
||||||
|
echo "<tr title='" . h($name) . "'>";
|
||||||
|
echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>";
|
||||||
|
echo "<td><a href='" . h($foreign_key["db"] != "" ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ($foreign_key["ns"] != "" ? preg_replace('~ns=[^&]*~', "ns=" . urlencode($foreign_key["ns"]), ME) : ME)) . "table=" . urlencode($foreign_key["table"]) . "'>"
|
||||||
|
. ($foreign_key["db"] != "" ? "<b>" . h($foreign_key["db"]) . "</b>." : "") . ($foreign_key["ns"] != "" ? "<b>" . h($foreign_key["ns"]) . "</b>." : "") . h($foreign_key["table"])
|
||||||
|
. "</a>"
|
||||||
|
;
|
||||||
|
echo "(<i>" . implode("</i>, <i>", array_map('h', $foreign_key["target"])) . "</i>)";
|
||||||
|
echo "<td>" . nbsp($foreign_key["on_delete"]) . "\n";
|
||||||
|
echo "<td>" . nbsp($foreign_key["on_update"]) . "\n";
|
||||||
|
echo '<td><a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>';
|
||||||
|
}
|
||||||
|
echo "</table>\n";
|
||||||
|
}
|
||||||
|
echo '<p class="links"><a href="' . h(ME) . 'foreign=' . urlencode($TABLE) . '">' . lang('Add foreign key') . "</a>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (support(is_view($table_status) ? "view_trigger" : "trigger")) {
|
||||||
|
echo "<h3 id='triggers'>" . lang('Triggers') . "</h3>\n";
|
||||||
|
$triggers = triggers($TABLE);
|
||||||
|
if ($triggers) {
|
||||||
|
echo "<table cellspacing='0'>\n";
|
||||||
|
foreach ($triggers as $key => $val) {
|
||||||
|
echo "<tr valign='top'><td>$val[0]<td>$val[1]<th>" . h($key) . "<td><a href='" . h(ME . 'trigger=' . urlencode($TABLE) . '&name=' . urlencode($key)) . "'>" . lang('Alter') . "</a>\n";
|
||||||
|
}
|
||||||
|
echo "</table>\n";
|
||||||
|
}
|
||||||
|
echo '<p class="links"><a href="' . h(ME) . 'trigger=' . urlencode($TABLE) . '">' . lang('Add trigger') . "</a>\n";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue