diff --git a/default.css b/default.css index 36f7d651..09de4b71 100644 --- a/default.css +++ b/default.css @@ -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; } diff --git a/schema.inc.php b/schema.inc.php index 72b59318..e94a0c48 100644 --- a/schema.inc.php +++ b/schema.inc.php @@ -20,10 +20,10 @@ $result->free(); ?>
\n"; +$top = 0; +$positions = array(); +foreach ($schema as $name => $table) { + echo "
\n"; echo '' . htmlspecialchars($name) . "
\n"; foreach (fields($name) as $field) { $val = htmlspecialchars($field["field"]); @@ -38,12 +38,30 @@ function schema_table($name, $table) { } echo ($field["primary"] ? "$val" : $val) . "
\n"; $top += 1.25; + $positions[$name][$field["field"]] = $top; } echo "
\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 "
\n"; + echo "
\n"; + } + echo "
\n"; + $left -= 2; + } + } } +//! JavaScript for dragging tables ?>