]> git.joonet.de Git - adminer.git/commitdiff
Show references in schema
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 17 Jul 2007 10:47:58 +0000 (10:47 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 17 Jul 2007 10:47:58 +0000 (10:47 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@211 7c3ca157-0c34-0410-bff1-cbf682f78f5c

default.css
schema.inc.php

index 36f7d651c0b0a24e5afb0f0d1a2ec0463ec69a45..09de4b71d2ce381b2eabd3fe1961da10311c6db2 100644 (file)
@@ -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; }
index 72b59318170309bf83846a75577c78a022c438b4..e94a0c48b8b92d9f3b129daf7b85c0a2717dd1ec 100644 (file)
@@ -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>