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; }
#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; }
?>
<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"]);
}
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>