diff --git a/schema.inc.php b/schema.inc.php index 2e0d19df..1f0f36f1 100644 --- a/schema.inc.php +++ b/schema.inc.php @@ -5,12 +5,12 @@ $table_pos = array(); $table_pos_js = array(); preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~', $_COOKIE["schema"], $matches, PREG_SET_ORDER); //! ':' in table name foreach ($matches as $i => $match) { - $table_pos[$match[1]] = "$match[2]em; left: $match[3]"; + $table_pos[$match[1]] = array($match[2], $match[3]); $table_pos_js[] = "\n\t'" . addcslashes($match[1], "\r\n'\\") . "': [ $match[2], $match[3] ]"; } $top = 0; -$left = -14; +$base_left = -.9; $schema = array(); $referenced = array(); $result = $mysql->query("SHOW TABLE STATUS"); @@ -25,17 +25,22 @@ while ($row = $result->fetch_assoc()) { $field["pos"] = $pos; $schema[$row["Name"]]["fields"][$name] = $field; } - $schema[$row["Name"]]["pos"] = ($table_pos[$row["Name"]] ? $table_pos[$row["Name"]] : $top); + $schema[$row["Name"]]["pos"] = ($table_pos[$row["Name"]] ? $table_pos[$row["Name"]] : array($top, 0)); if ($row["Engine"] == "InnoDB") { foreach (foreign_keys($row["Name"]) as $val) { if (!$val["db"]) { - $schema[$row["Name"]]["references"][$val["table"]][$left] = array_combine($val["source"], $val["target"]); - $referenced[$val["table"]][$left] = $val["target"]; - $left -= 2; + if ($table_pos[$row["Name"]][1] || $table_pos[$row["Name"]][1]) { + $left = min($table_pos[$row["Name"]][1], $table_pos[$val["table"]][1]) - .9; + } else { + $left = $base_left; + $base_left -= .1; + } + $schema[$row["Name"]]["references"][$val["table"]][10000 * $left] = array_combine($val["source"], $val["target"]); + $referenced[$val["table"]][10000 * $left] = $val["target"]; } } } - $top = max($top, $schema[$row["Name"]]["pos"] + 2.5 + $pos); + $top = max($top, $schema[$row["Name"]]["pos"][0] + 2.5 + $pos); } $result->free(); @@ -46,7 +51,7 @@ var table_pos = {}; function mousedown(el, event) { that = el; - em = document.getElementById('breadcrumb').offsetHeight / 1.25; + em = document.getElementById('schema').offsetHeight / ; x = event.clientX - el.offsetLeft; y = event.clientY - el.offsetTop; } @@ -75,7 +80,7 @@ function mouseup(event) {