Fixed: Not selecting a datalabel used to issue a notice(undefined offset)
[phpmyadmin/ammaryasirr.git] / libraries / schema / Eps_Relation_Schema.class.php
blob367b8c28bee17eec69a0845a55541f1283fcdd05
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 include_once("Export_Relation_Schema.class.php");
10 /**
11 * This Class is EPS Library and
12 * helps in developing structure of EPS Schema Export
14 * @access public
15 * @see http://php.net/manual/en/book.xmlwriter.php
18 class PMA_EPS
20 public $font;
21 public $fontSize;
22 public $stringCommands;
24 /**
25 * The "PMA_EPS" constructor
27 * Upon instantiation This starts writing the EPS Document.
28 * %!PS-Adobe-3.0 EPSF-3.0 This is the MUST first comment to include
29 * it shows/tells that the Post Script document is purely under
30 * Document Structuring Convention [DSC] and is Compliant
31 * Encapsulated Post Script Document
33 * @return void
34 * @access public
36 function __construct()
38 $this->stringCommands = "";
39 $this->stringCommands .= "%!PS-Adobe-3.0 EPSF-3.0 \n";
42 /**
43 * Set document title
45 * @param string value sets the title text
46 * @return void
47 * @access public
49 function setTitle($value)
51 $this->stringCommands .= '%%Title: ' . $value . "\n";
54 /**
55 * Set document author
57 * @param string value sets the author
58 * @return void
59 * @access public
61 function setAuthor($value)
63 $this->stringCommands .= '%%Creator: ' . $value . "\n";
66 /**
67 * Set document creation date
69 * @param string value sets the date
70 * @return void
71 * @access public
73 function setDate($value)
75 $this->stringCommands .= '%%CreationDate: ' . $value . "\n";
78 /**
79 * Set document orientation
81 * @param string value sets the author
82 * @return void
83 * @access public
85 function setOrientation($value)
87 $this->stringCommands .= "%%PageOrder: Ascend \n";
88 if($value == "L"){
89 $value = "Landscape";
90 $this->stringCommands .= '%%Orientation: ' . $value . "\n";
91 }else{
92 $value = "Portrait";
93 $this->stringCommands .= '%%Orientation: ' . $value . "\n";
95 $this->stringCommands .= "%%EndComments \n";
96 $this->stringCommands .= "%%Pages 1 \n";
97 $this->stringCommands .= "%%BoundingBox: 72 150 144 170 \n";
101 * Set the font and size
103 * font can be set whenever needed in EPS
105 * @param string value sets the font name e.g Arial
106 * @param integer value sets the size of the font e.g 10
107 * @return void
108 * @access public
110 function setFont($value,$size)
112 $this->font = $value;
113 $this->fontSize = $size;
114 $this->stringCommands .= "/".$value." findfont % Get the basic font\n";
115 $this->stringCommands .= "".$size." scalefont % Scale the font to $size points\n";
116 $this->stringCommands .= "setfont % Make it the current font\n";
120 * Get the font
122 * @return string return the font name e.g Arial
123 * @access public
125 function getFont()
127 return $this->font;
131 * Get the font Size
133 * @return string return the size of the font e.g 10
134 * @access public
136 function getFontSize()
138 return $this->fontSize;
142 * Draw the line
144 * drawing the lines from x,y source to x,y destination and set the
145 * width of the line. lines helps in showing relationships of tables
147 * @param integer x_from The x_from attribute defines the start
148 left position of the element
149 * @param integer y_from The y_from attribute defines the start
150 right position of the element
151 * @param integer x_to The x_to attribute defines the end
152 left position of the element
153 * @param integer y_to The y_to attribute defines the end
154 right position of the element
155 * @param integer lineWidth sets the width of the line e.g 2
156 * @return void
157 * @access public
159 function line($x_from=0, $y_from=0, $x_to=0, $y_to=0, $lineWidth=0)
161 $this->stringCommands .= $lineWidth . " setlinewidth \n";
162 $this->stringCommands .= $x_from . ' ' . $y_from . " moveto \n";
163 $this->stringCommands .= $x_to . ' ' . $y_to . " lineto \n";
164 $this->stringCommands .= "stroke \n";
168 * Draw the rectangle
170 * drawing the rectangle from x,y source to x,y destination and set the
171 * width of the line. rectangles drawn around the text shown of fields
173 * @param integer x_from The x_from attribute defines the start
174 left position of the element
175 * @param integer y_from The y_from attribute defines the start
176 right position of the element
177 * @param integer x_to The x_to attribute defines the end
178 left position of the element
179 * @param integer y_to The y_to attribute defines the end
180 right position of the element
181 * @param integer lineWidth sets the width of the line e.g 2
182 * @return void
183 * @access public
185 function rect($x_from, $y_from, $x_to, $y_to, $lineWidth)
187 $this->stringCommands .= $lineWidth . " setlinewidth \n";
188 $this->stringCommands .= "newpath \n";
189 $this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
190 $this->stringCommands .= "0 " . $y_to . " rlineto \n";
191 $this->stringCommands .= $x_to . " 0 rlineto \n";
192 $this->stringCommands .= "0 -" . $y_to . " rlineto \n";
193 $this->stringCommands .= "closepath \n";
194 $this->stringCommands .= "stroke \n";
198 * Set the current point
200 * The moveto operator takes two numbers off the stack and treats
201 * them as x and y coordinates to which to move. The coordinates
202 * specified become the current point.
204 * @param integer x The x attribute defines the
205 left position of the element
206 * @param integer y The y attribute defines the
207 right position of the element
208 * @return void
209 * @access public
211 function moveTo($x, $y)
213 $this->stringCommands .= $x . ' ' . $y . " moveto \n";
217 * Output/Display the text
219 * @param string text The string to be displayed
220 * @return void
221 * @access public
223 function show($text)
225 $this->stringCommands .= '(' . $text . ") show \n";
229 * Output the text at specified co-ordinates
231 * @param string text The string to be displayed
232 * @param integer x The x attribute defines the
233 left position of the element
234 * @param integer y The y attribute defines the
235 right position of the element
236 * @return void
237 * @access public
239 function showXY($text, $x, $y)
241 $this->moveTo($x, $y);
242 $this->show($text);
246 * get width of string/text
248 * EPS text width is calcualted depending on font name
249 * and font size. It is very important to know the width of text
250 * because rectangle is drawn around it.
252 * This is a bit hardcore method. I didn't found any other better than this.
253 * if someone found better than this. would love to hear that method
255 * @param string text string that width will be calculated
256 * @param integer font name of the font like Arial,sans-serif etc
257 * @param integer fontSize size of font
258 * @return integer width of the text
259 * @access public
261 function getStringWidth($text,$font,$fontSize)
264 * Start by counting the width, giving each character a modifying value
266 $count = 0;
267 $count = $count + ((strlen($text) - strlen(str_replace(array("i","j","l"),"",$text)))*0.23);//ijl
268 $count = $count + ((strlen($text) - strlen(str_replace(array("f"),"",$text)))*0.27);//f
269 $count = $count + ((strlen($text) - strlen(str_replace(array("t","I"),"",$text)))*0.28);//tI
270 $count = $count + ((strlen($text) - strlen(str_replace(array("r"),"",$text)))*0.34);//r
271 $count = $count + ((strlen($text) - strlen(str_replace(array("1"),"",$text)))*0.49);//1
272 $count = $count + ((strlen($text) - strlen(str_replace(array("c","k","s","v","x","y","z","J"),"",$text)))*0.5);//cksvxyzJ
273 $count = $count + ((strlen($text) - strlen(str_replace(array("a","b","d","e","g","h","n","o","p","q","u","L","0","2","3","4","5","6","7","8","9"),"",$text)))*0.56);//abdeghnopquL023456789
274 $count = $count + ((strlen($text) - strlen(str_replace(array("F","T","Z"),"",$text)))*0.61);//FTZ
275 $count = $count + ((strlen($text) - strlen(str_replace(array("A","B","E","K","P","S","V","X","Y"),"",$text)))*0.67);//ABEKPSVXY
276 $count = $count + ((strlen($text) - strlen(str_replace(array("w","C","D","H","N","R","U"),"",$text)))*0.73);//wCDHNRU
277 $count = $count + ((strlen($text) - strlen(str_replace(array("G","O","Q"),"",$text)))*0.78);//GOQ
278 $count = $count + ((strlen($text) - strlen(str_replace(array("m","M"),"",$text)))*0.84);//mM
279 $count = $count + ((strlen($text) - strlen(str_replace("W","",$text)))*.95);//W
280 $count = $count + ((strlen($text) - strlen(str_replace(" ","",$text)))*.28);//" "
281 $text = str_replace(" ","",$text);//remove the " "'s
282 $count = $count + (strlen(preg_replace("/[a-z0-9]/i","",$text))*0.3); //all other chrs
284 $modifier = 1;
285 $font = strtolower($font);
286 switch($font){
288 * no modifier for arial and sans-serif
290 case 'arial':
291 case 'sans-serif':
292 break;
294 * .92 modifer for time, serif, brushscriptstd, and californian fb
296 case 'times':
297 case 'serif':
298 case 'brushscriptstd':
299 case 'californian fb':
300 $modifier = .92;
301 break;
303 * 1.23 modifier for broadway
305 case 'broadway':
306 $modifier = 1.23;
307 break;
309 $textWidth = $count*$fontSize;
310 return ceil($textWidth*$modifier);
314 * Ends EPS Document
316 * @return void
317 * @access public
319 function endEpsDoc()
321 $this->stringCommands .= "showpage \n";
325 * Output EPS Document for download
327 * @param string fileName name of the eps document
328 * @return void
329 * @access public
331 function showOutput($fileName)
333 // if(ob_get_clean()){
334 //ob_end_clean();
336 $output = $this->stringCommands;
337 PMA_download_header($fileName . '.eps', 'image/x-eps', strlen($output));
338 print $output;
343 * Table preferences/statistics
345 * This class preserves the table co-ordinates,fields
346 * and helps in drawing/generating the Tables in EPS.
348 * @name Table_Stats
349 * @see PMA_EPS
351 class Table_Stats
354 * Defines properties
357 private $_tableName;
358 private $_showInfo = false;
360 public $width = 0;
361 public $height;
362 public $fields = array();
363 public $heightCell = 0;
364 public $currentCell = 0;
365 public $x, $y;
366 public $primary = array();
369 * The "Table_Stats" constructor
371 * @param string tableName The table name
372 * @param string font The font name
373 * @param integer fontSize The font size
374 * @param integer same_wide_width The max width among tables
375 * @param boolean showKeys Whether to display keys or not
376 * @param boolean showInfo Whether to display table position or not
377 * @global object The current eps document
378 * @global integer The current page number (from the
379 * $cfg['Servers'][$i]['table_coords'] table)
380 * @global array The relations settings
381 * @global string The current db name
382 * @access private
383 * @see PMA_EPS, Table_Stats::Table_Stats_setWidth,
384 Table_Stats::Table_Stats_setHeight
386 function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false)
388 global $eps, $cfgRelation, $db;
390 $this->_tableName = $tableName;
391 $sql = 'DESCRIBE ' . PMA_backquote($tableName);
392 $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
393 if (!$result || !PMA_DBI_num_rows($result)) {
394 $eps->dieSchema($pageNumber,"EPS",sprintf(__('The %s table doesn\'t exist!'), $tableName));
398 * load fields
399 * check to see if it will load all fields or only the foreign keys
401 if ($showKeys) {
402 $indexes = PMA_Index::getFromTable($this->_tableName, $db);
403 $all_columns = array();
404 foreach ($indexes as $index) {
405 $all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
407 $this->fields = array_keys($all_columns);
408 } else {
409 while ($row = PMA_DBI_fetch_row($result)) {
410 $this->fields[] = $row[0];
414 $this->_showInfo = $showInfo;
416 // height and width
417 $this->_setHeightTable($fontSize);
419 // setWidth must me after setHeight, because title
420 // can include table height which changes table width
421 $this->_setWidthTable($font,$fontSize);
422 if ($same_wide_width < $this->width) {
423 $same_wide_width = $this->width;
426 // x and y
427 $sql = 'SELECT x, y FROM '
428 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
429 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
430 . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
431 . ' AND pdf_page_number = ' . $pageNumber;
432 $result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
434 if (!$result || !PMA_DBI_num_rows($result)) {
435 $eps->dieSchema($pageNumber,"EPS",sprintf(__('Please configure the coordinates for table %s'), $tableName));
437 list($this->x, $this->y) = PMA_DBI_fetch_row($result);
438 $this->x = (double) $this->x;
439 $this->y = (double) $this->y;
440 // displayfield
441 $this->displayfield = PMA_getDisplayField($db, $tableName);
442 // index
443 $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
444 if (PMA_DBI_num_rows($result) > 0) {
445 while ($row = PMA_DBI_fetch_assoc($result)) {
446 if ($row['Key_name'] == 'PRIMARY') {
447 $this->primary[] = $row['Column_name'];
454 * Returns title of the current table,
455 * title can have the dimensions/co-ordinates of the table
457 * @return string The relation/table name
458 * @access private
460 private function _getTitle()
462 return ($this->_showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '') . ' ' . $this->_tableName;
466 * Sets the width of the table
468 * @param string font The font name
469 * @param integer fontSize The font size
470 * @global object The current eps document
471 * @return void
472 * @access private
473 * @see PMA_EPS
475 private function _setWidthTable($font,$fontSize)
477 global $eps;
479 foreach ($this->fields as $field) {
480 $this->width = max($this->width, $eps->getStringWidth($field,$font,$fontSize));
482 $this->width += $eps->getStringWidth(' ',$font,$fontSize);
484 * it is unknown what value must be added, because
485 * table title is affected by the tabe width value
487 while ($this->width < $eps->getStringWidth($this->_getTitle(),$font,$fontSize)) {
488 $this->width += 7;
493 * Sets the height of the table
495 * @param integer fontSize The font size
496 * @return void
497 * @access private
499 private function _setHeightTable($fontSize)
501 $this->heightCell = $fontSize + 4;
502 $this->height = (count($this->fields) + 1) * $this->heightCell;
506 * Draw the table
508 * @param boolean showColor Whether to display color
509 * @global object The current eps document
510 * @return void
511 * @access public
512 * @see PMA_EPS,PMA_EPS::line,PMA_EPS::rect
514 public function tableDraw($showColor)
516 global $eps;
517 //echo $this->_tableName.'<br />';
518 $eps->rect($this->x,$this->y + 12,
519 $this->width,$this->heightCell,
522 $eps->showXY($this->_getTitle(),$this->x + 5,$this->y + 14);
523 foreach ($this->fields as $field) {
524 $this->currentCell += $this->heightCell;
525 $showColor = 'none';
526 if ($showColor) {
527 if (in_array($field, $this->primary)) {
528 $showColor = '#0c0';
530 if ($field == $this->displayfield) {
531 $showColor = 'none';
534 $eps->rect($this->x,$this->y + 12 + $this->currentCell,
535 $this->width, $this->heightCell,1);
536 $eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
542 * Relation preferences/statistics
544 * This class fetches the table master and foreign fields positions
545 * and helps in generating the Table references and then connects
546 * master table's master field to foreign table's foreign key
547 * in EPS document.
549 * @name Relation_Stats
550 * @see PMA_EPS
552 class Relation_Stats
555 * Defines properties
557 public $xSrc, $ySrc;
558 public $srcDir ;
559 public $destDir;
560 public $xDest, $yDest;
561 public $wTick = 10;
564 * The "Relation_Stats" constructor
566 * @param string master_table The master table name
567 * @param string master_field The relation field in the master table
568 * @param string foreign_table The foreign table name
569 * @param string foreigh_field The relation field in the foreign table
570 * @see Relation_Stats::_getXy
572 function __construct($master_table, $master_field, $foreign_table, $foreign_field)
574 $src_pos = $this->_getXy($master_table, $master_field);
575 $dest_pos = $this->_getXy($foreign_table, $foreign_field);
577 * [0] is x-left
578 * [1] is x-right
579 * [2] is y
581 $src_left = $src_pos[0] - $this->wTick;
582 $src_right = $src_pos[1] + $this->wTick;
583 $dest_left = $dest_pos[0] - $this->wTick;
584 $dest_right = $dest_pos[1] + $this->wTick;
586 $d1 = abs($src_left - $dest_left);
587 $d2 = abs($src_right - $dest_left);
588 $d3 = abs($src_left - $dest_right);
589 $d4 = abs($src_right - $dest_right);
590 $d = min($d1, $d2, $d3, $d4);
592 if ($d == $d1) {
593 $this->xSrc = $src_pos[0];
594 $this->srcDir = -1;
595 $this->xDest = $dest_pos[0];
596 $this->destDir = -1;
597 } elseif ($d == $d2) {
598 $this->xSrc = $src_pos[1];
599 $this->srcDir = 1;
600 $this->xDest = $dest_pos[0];
601 $this->destDir = -1;
602 } elseif ($d == $d3) {
603 $this->xSrc = $src_pos[0];
604 $this->srcDir = -1;
605 $this->xDest = $dest_pos[1];
606 $this->destDir = 1;
607 } else {
608 $this->xSrc = $src_pos[1];
609 $this->srcDir = 1;
610 $this->xDest = $dest_pos[1];
611 $this->destDir = 1;
613 $this->ySrc = $src_pos[2] + 10;
614 $this->yDest = $dest_pos[2] + 10;
618 * Gets arrows coordinates
620 * @param string table The current table name
621 * @param string column The relation column name
622 * @return array Arrows coordinates
623 * @access private
625 private function _getXy($table, $column)
627 $pos = array_search($column, $table->fields);
628 // x_left, x_right, y
629 return array($table->x, $table->x + $table->width, $table->y + ($pos + 1.5) * $table->heightCell);
633 * draws relation links and arrows
634 * shows foreign key relations
636 * @param boolean changeColor Whether to use one color per relation or not
637 * @global object The current EPS document
638 * @access public
639 * @see PMA_EPS
641 public function relationDraw($changeColor)
643 global $eps;
645 if ($changeColor) {
646 $listOfColors = array(
647 'red',
648 'grey',
649 'black',
650 'yellow',
651 'green',
652 'cyan',
653 ' orange'
655 shuffle($listOfColors);
656 $color = $listOfColors[0];
657 } else {
658 $color = 'black';
660 // draw a line like -- to foreign field
661 $eps->line($this->xSrc,$this->ySrc,
662 $this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
665 // draw a line like -- to master field
666 $eps->line($this->xDest + $this->destDir * $this->wTick, $this->yDest,
667 $this->xDest, $this->yDest,
670 // draw a line that connects to master field line and foreign field line
671 $eps->line($this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
672 $this->xDest + $this->destDir * $this->wTick, $this->yDest,
675 $root2 = 2 * sqrt(2);
676 $eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
677 $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
678 $this->ySrc + $this->wTick / $root2 ,
681 $eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
682 $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
683 $this->ySrc - $this->wTick / $root2 ,
686 $eps->line($this->xDest + $this->destDir * $this->wTick / 2 , $this->yDest ,
687 $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
688 $this->yDest + $this->wTick / $root2 ,
690 $eps->line($this->xDest + $this->destDir * $this->wTick / 2 ,
691 $this->yDest , $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick ,
692 $this->yDest - $this->wTick / $root2 ,
698 * end of the "Relation_Stats" class
702 * EPS Relation Schema Class
704 * Purpose of this class is to generate the EPS Document
705 * which is used for representing the database diagrams.
706 * This class uses post script commands and with
707 * the combination of these commands actually helps in preparing EPS Document.
709 * This class inherits Export_Relation_Schema class has common functionality added
710 * to this class
712 * @name Eps_Relation_Schema
714 class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
716 private $tables = array();
717 private $_relations = array();
720 * The "PMA_EPS_Relation_Schema" constructor
722 * Upon instantiation This starts writing the EPS document
723 * user will be prompted for download as .eps extension
725 * @return void
726 * @see PMA_EPS
728 function __construct()
730 global $eps,$db;
732 $this->setPageNumber($_POST['pdf_page_number']);
733 $this->setShowColor(isset($_POST['show_color']));
734 $this->setShowKeys(isset($_POST['show_keys']));
735 $this->setTableDimension(isset($_POST['show_table_dimension']));
736 $this->setAllTableSameWidth(isset($_POST['all_table_same_wide']));
737 $this->setOrientation($_POST['orientation']);
738 $this->setExportType($_POST['export_type']);
740 $eps = new PMA_EPS();
741 $eps->setTitle(sprintf(__('Schema of the %s database - Page %s'), $db, $this->pageNumber));
742 $eps->setAuthor('phpMyAdmin ' . PMA_VERSION);
743 $eps->setDate(date("j F Y, g:i a"));
744 $eps->setOrientation($this->orientation);
745 $eps->setFont('Verdana','10');
749 $alltables = $this->getAllTables($db,$this->pageNumber);
751 foreach ($alltables AS $table) {
752 if (! isset($this->tables[$table])) {
753 $this->tables[$table] = new Table_Stats($table,$eps->getFont(),$eps->getFontSize(), $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension);
756 if ($this->sameWide) {
757 $this->tables[$table]->width = $this->_tablewidth;
761 $seen_a_relation = false;
762 foreach ($alltables as $one_table) {
763 $exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
764 if ($exist_rel) {
765 $seen_a_relation = true;
766 foreach ($exist_rel as $master_field => $rel) {
767 /* put the foreign table on the schema only if selected
768 * by the user
769 * (do not use array_search() because we would have to
770 * to do a === false and this is not PHP3 compatible)
772 if (in_array($rel['foreign_table'], $alltables)) {
773 $this->_addRelation($one_table,$eps->getFont(),$eps->getFontSize(), $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->tableDimension);
778 if ($seen_a_relation) {
779 $this->_drawRelations($this->showColor);
782 $this->_drawTables($this->showColor);
783 $eps->endEpsDoc();
784 $eps->showOutput($db.'-'.$this->pageNumber);
785 exit();
789 * Defines relation objects
791 * @param string masterTable The master table name
792 * @param string masterField The relation field in the master table
793 * @param string foreignTable The foreign table name
794 * @param string foreignField The relation field in the foreign table
795 * @param boolean showInfo Whether to display table position or not
796 * @return void
797 * @access private
798 * @see _setMinMax,Table_Stats::__construct(),Relation_Stats::__construct()
800 private function _addRelation($masterTable,$font,$fontSize, $masterField, $foreignTable, $foreignField, $showInfo)
802 if (! isset($this->tables[$masterTable])) {
803 $this->tables[$masterTable] = new Table_Stats($masterTable, $font, $fontSize, $this->pageNumber, $this->_tablewidth, false, $showInfo);
805 if (! isset($this->tables[$foreignTable])) {
806 $this->tables[$foreignTable] = new Table_Stats($foreignTable,$font,$fontSize,$this->pageNumber, $this->_tablewidth, false, $showInfo);
808 $this->_relations[] = new Relation_Stats($this->tables[$masterTable], $masterField, $this->tables[$foreignTable], $foreignField);
812 * Draws relation arrows and lines
813 * connects master table's master field to
814 * foreign table's forein field
816 * @param boolean changeColor Whether to use one color per relation or not
817 * @return void
818 * @access private
819 * @see Relation_Stats::relationDraw()
821 private function _drawRelations($changeColor)
823 foreach ($this->_relations as $relation) {
824 $relation->relationDraw($changeColor);
829 * Draws tables
831 * @param boolean changeColor Whether to show color for primary fields or not
832 * @return void
833 * @access private
834 * @see Table_Stats::Table_Stats_tableDraw()
836 private function _drawTables($changeColor)
838 foreach ($this->tables as $table) {
839 $table->tableDraw($changeColor);