Show references in schema
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@211 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
4d61cedf46
commit
38cb78af60
|
@ -8,6 +8,7 @@ FIELDSET { float: left; padding: .5em; margin: 0; }
|
|||
PRE { margin: .12em 0 1em; }
|
||||
TABLE { margin-bottom: 1em; }
|
||||
P { margin-top: 0; }
|
||||
IMG { vertical-align: middle; }
|
||||
.error { color: Red; }
|
||||
.message { color: Green; }
|
||||
.char { color: #007F00; }
|
||||
|
@ -17,4 +18,5 @@ P { margin-top: 0; }
|
|||
#menu { position: absolute; top: 8px; left: 8px; width: 15em; overflow: auto; overflow-y: hidden; white-space: nowrap; }
|
||||
#content { margin-left: 16em; }
|
||||
#schema { position: relative; }
|
||||
#schema DIV { position: absolute; border: 1px solid Silver; line-height: 1.25em; padding: 0 2px; }
|
||||
#schema DIV { position: absolute; }
|
||||
#schema .table { left: 60px; border: 1px solid Silver; line-height: 1.25em; padding: 0 2px; }
|
||||
|
|
|
@ -20,10 +20,10 @@ $result->free();
|
|||
?>
|
||||
<div id="schema">
|
||||
<?php
|
||||
function schema_table($name, $table) {
|
||||
global $mysql, $SELF;
|
||||
static $top = 0;
|
||||
echo "<div style='top: $top" . "em;'>\n";
|
||||
$top = 0;
|
||||
$positions = array();
|
||||
foreach ($schema as $name => $table) {
|
||||
echo "<div class='table' style='top: $top" . "em;'>\n";
|
||||
echo '<a href="' . htmlspecialchars($SELF) . 'table=' . urlencode($name) . '"><strong>' . htmlspecialchars($name) . "</strong></a><br />\n";
|
||||
foreach (fields($name) as $field) {
|
||||
$val = htmlspecialchars($field["field"]);
|
||||
|
@ -38,12 +38,30 @@ function schema_table($name, $table) {
|
|||
}
|
||||
echo ($field["primary"] ? "<em>$val</em>" : $val) . "<br />\n";
|
||||
$top += 1.25;
|
||||
$positions[$name][$field["field"]] = $top;
|
||||
}
|
||||
echo "</div>\n";
|
||||
$top += 2.5;
|
||||
}
|
||||
$left = 46;
|
||||
foreach ($schema as $name => $table) {
|
||||
schema_table($name, $table);
|
||||
foreach ((array) $table["referenced"] as $target_name => $refs) {
|
||||
foreach ($refs as $ref) {
|
||||
$min_pos = $top;
|
||||
$max_pos = 0;
|
||||
foreach ($ref as $source => $target) {
|
||||
$pos1 = $positions[$name][$source];
|
||||
$pos2 = $positions[$target_name][$target];
|
||||
$min_pos = min($min_pos, $pos1, $pos2);
|
||||
$max_pos = max($max_pos, $pos1, $pos2);
|
||||
echo "<div style='left: " . ($left+1) . "px; top: $pos1" . "em;'><img src='arrow.gif' width='12' height='9' alt='' /></div>\n";
|
||||
echo "<div style='left: " . ($left+1) . "px; top: $pos2" . "em;'><img src='hline.gif' width='12' height='7' alt='' /></div>\n";
|
||||
}
|
||||
echo "<div style='left: $left" . "px; top: $min_pos" . "em;'><img src='vline.gif' width='1' height='12' alt='' style='padding: .5em 0; height: " . ($max_pos - $min_pos) . "em;' /></div>\n";
|
||||
$left -= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
//! JavaScript for dragging tables
|
||||
?>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue