diff --git a/default.css b/default.css
index d75a15cc..69b3d813 100644
--- a/default.css
+++ b/default.css
@@ -1,4 +1,4 @@
-BODY { color: Black; background-color: White; }
+BODY { color: Black; background-color: White; line-height: 1.25em; }
A { color: Blue; }
A:visited { color: Navy; }
H1 { font-size: 150%; margin-top: 0; }
@@ -18,5 +18,5 @@ IMG { vertical-align: middle; }
#menu { position: absolute; top: 8px; left: 8px; width: 15em; overflow: auto; overflow-y: hidden; white-space: nowrap; }
#content { margin-left: 16em; }
#schema { margin-left: 60px; position: relative; }
-#schema DIV { position: absolute; }
-#schema .table { border: 1px solid Silver; line-height: 1.25em; padding: 0 2px; }
+#schema .table { border: 1px solid Silver; padding: 0 2px; cursor: move; position: absolute; }
+#schema .references { position: absolute; }
diff --git a/design.inc.php b/design.inc.php
index 2978fdd9..32dc5637 100644
--- a/design.inc.php
+++ b/design.inc.php
@@ -25,7 +25,7 @@ function page_header($title, $breadcrumb = array(), $title2 = "") {
' . (isset($_GET["server"]) ? htmlspecialchars($_GET["server"]) : lang('Server')) . ' > ';
+ echo '
' . (isset($_GET["server"]) ? htmlspecialchars($_GET["server"]) : lang('Server')) . ' > ';
if (is_array($breadcrumb)) {
if (strlen($_GET["db"])) {
echo '' . htmlspecialchars($_GET["db"]) . ' > ';
diff --git a/schema.inc.php b/schema.inc.php
index bd3e1fae..2e0d19df 100644
--- a/schema.inc.php
+++ b/schema.inc.php
@@ -1,31 +1,83 @@
$match) {
+ $table_pos[$match[1]] = "$match[2]em; left: $match[3]";
+ $table_pos_js[] = "\n\t'" . addcslashes($match[1], "\r\n'\\") . "': [ $match[2], $match[3] ]";
+}
+
+$top = 0;
+$left = -14;
$schema = array();
+$referenced = array();
$result = $mysql->query("SHOW TABLE STATUS");
while ($row = $result->fetch_assoc()) {
if (!isset($row["Engine"])) { // view
continue;
}
- $schema[$row["Name"]]["fields"] = fields($row["Name"]);
+ $pos = 0;
+ $schema[$row["Name"]]["fields"] = array();
+ foreach (fields($row["Name"]) as $name => $field) {
+ $pos += 1.25;
+ $field["pos"] = $pos;
+ $schema[$row["Name"]]["fields"][$name] = $field;
+ }
+ $schema[$row["Name"]]["pos"] = ($table_pos[$row["Name"]] ? $table_pos[$row["Name"]] : $top);
if ($row["Engine"] == "InnoDB") {
foreach (foreign_keys($row["Name"]) as $val) {
if (!$val["db"]) {
- $schema[$row["Name"]]["references"][$val["table"]][] = array_combine($val["source"], $val["target"]);
+ $schema[$row["Name"]]["references"][$val["table"]][$left] = array_combine($val["source"], $val["target"]);
+ $referenced[$val["table"]][$left] = $val["target"];
+ $left -= 2;
}
}
}
+ $top = max($top, $schema[$row["Name"]]["pos"] + 2.5 + $pos);
}
$result->free();
+
?>
-
+
+
+
$table) {
- echo "
\n";
+ echo "
";
echo '
' . htmlspecialchars($name) . "\n";
- foreach (fields($name) as $field) {
+ foreach ($table["fields"] as $field) {
$val = htmlspecialchars($field["field"]);
if (preg_match('~char|text~', $field["type"])) {
$val = "
$val";
@@ -37,31 +89,35 @@ foreach ($schema as $name => $table) {
$val = "
$val";
}
echo ($field["primary"] ? "
$val" : $val) . "
\n";
- $top += 1.25;
- $positions[$name][$field["field"]] = $top;
+ }
+ foreach ((array) $table["references"] as $target_name => $refs) {
+ foreach ($refs as $left => $columns) {
+ foreach ($columns as $source => $target) {
+ echo "
\n";
+ }
+ }
+ }
+ foreach ((array) $referenced[$name] as $left => $columns) {
+ foreach ($columns as $target) {
+ echo "
\n";
+ }
}
echo "
\n";
- $top += 2.5;
}
-$left = -14;
foreach ($schema as $name => $table) {
foreach ((array) $table["references"] as $target_name => $refs) {
- foreach ($refs as $ref) {
+ foreach ($refs as $left => $ref) {
$min_pos = $top;
- $max_pos = 0;
+ $max_pos = -10;
foreach ($ref as $source => $target) {
- $pos1 = $positions[$name][$source];
- $pos2 = $positions[$target_name][$target];
+ $pos1 = $table["pos"] + $table["fields"][$source]["pos"];
+ $pos2 = $schema[$target_name]["pos"] + $schema[$target_name]["fields"][$target]["pos"];
$min_pos = min($min_pos, $pos1, $pos2);
$max_pos = max($max_pos, $pos1, $pos2);
- echo "
\n";
- echo "
\n";
}
- echo "
\n";
- $left -= 2;
+ echo "
\n";
}
}
}
-//! JavaScript for dragging tables
?>