Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / schema / Eps_Relation_Schema.class.php
blob57a91c04e6911fda0a7506ff27c6d97b57894b13
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
7 if (! defined('PHPMYADMIN')) {
8 exit;
11 require_once 'Export_Relation_Schema.class.php';
13 /**
14 * This Class is EPS Library and
15 * helps in developing structure of EPS Schema Export
17 * @access public
18 * @see http://php.net/manual/en/book.xmlwriter.php
21 class PMA_EPS
23 public $font;
24 public $fontSize;
25 public $stringCommands;
27 /**
28 * The "PMA_EPS" constructor
30 * Upon instantiation This starts writing the EPS Document.
31 * %!PS-Adobe-3.0 EPSF-3.0 This is the MUST first comment to include
32 * it shows/tells that the Post Script document is purely under
33 * Document Structuring Convention [DSC] and is Compliant
34 * Encapsulated Post Script Document
36 * @return void
37 * @access public
39 function __construct()
41 $this->stringCommands = "";
42 $this->stringCommands .= "%!PS-Adobe-3.0 EPSF-3.0 \n";
45 /**
46 * Set document title
48 * @param string $value sets the title text
50 * @return void
52 * @access public
54 function setTitle($value)
56 $this->stringCommands .= '%%Title: ' . $value . "\n";
59 /**
60 * Set document author
62 * @param string $value sets the author
64 * @return void
66 * @access public
68 function setAuthor($value)
70 $this->stringCommands .= '%%Creator: ' . $value . "\n";
73 /**
74 * Set document creation date
76 * @param string $value sets the date
78 * @return void
80 * @access public
82 function setDate($value)
84 $this->stringCommands .= '%%CreationDate: ' . $value . "\n";
87 /**
88 * Set document orientation
90 * @param string $value sets the author
92 * @return void
94 * @access public
96 function setOrientation($value)
98 $this->stringCommands .= "%%PageOrder: Ascend \n";
99 if ($value == "L") {
100 $value = "Landscape";
101 $this->stringCommands .= '%%Orientation: ' . $value . "\n";
102 } else {
103 $value = "Portrait";
104 $this->stringCommands .= '%%Orientation: ' . $value . "\n";
106 $this->stringCommands .= "%%EndComments \n";
107 $this->stringCommands .= "%%Pages 1 \n";
108 $this->stringCommands .= "%%BoundingBox: 72 150 144 170 \n";
112 * Set the font and size
114 * font can be set whenever needed in EPS
116 * @param string $value sets the font name e.g Arial
117 * @param integer $size sets the size of the font e.g 10
119 * @return void
121 * @access public
123 function setFont($value, $size)
125 $this->font = $value;
126 $this->fontSize = $size;
127 $this->stringCommands .= "/" . $value . " findfont % Get the basic font\n";
128 $this->stringCommands .= "" . $size . " scalefont % Scale the font to $size points\n";
129 $this->stringCommands .= "setfont % Make it the current font\n";
133 * Get the font
135 * @return string return the font name e.g Arial
136 * @access public
138 function getFont()
140 return $this->font;
144 * Get the font Size
146 * @return string return the size of the font e.g 10
147 * @access public
149 function getFontSize()
151 return $this->fontSize;
155 * Draw the line
157 * drawing the lines from x,y source to x,y destination and set the
158 * width of the line. lines helps in showing relationships of tables
160 * @param integer $x_from The x_from attribute defines the start
161 * left position of the element
162 * @param integer $y_from The y_from attribute defines the start
163 * right position of the element
164 * @param integer $x_to The x_to attribute defines the end
165 * left position of the element
166 * @param integer $y_to The y_to attribute defines the end
167 * right position of the element
168 * @param integer $lineWidth Sets the width of the line e.g 2
170 * @return void
172 * @access public
174 function line($x_from = 0, $y_from = 0, $x_to = 0, $y_to = 0, $lineWidth = 0)
176 $this->stringCommands .= $lineWidth . " setlinewidth \n";
177 $this->stringCommands .= $x_from . ' ' . $y_from . " moveto \n";
178 $this->stringCommands .= $x_to . ' ' . $y_to . " lineto \n";
179 $this->stringCommands .= "stroke \n";
183 * Draw the rectangle
185 * drawing the rectangle from x,y source to x,y destination and set the
186 * width of the line. rectangles drawn around the text shown of fields
188 * @param integer $x_from The x_from attribute defines the start
189 left position of the element
190 * @param integer $y_from The y_from attribute defines the start
191 right position of the element
192 * @param integer $x_to The x_to attribute defines the end
193 left position of the element
194 * @param integer $y_to The y_to attribute defines the end
195 right position of the element
196 * @param integer $lineWidth Sets the width of the line e.g 2
198 * @return void
200 * @access public
202 function rect($x_from, $y_from, $x_to, $y_to, $lineWidth)
204 $this->stringCommands .= $lineWidth . " setlinewidth \n";
205 $this->stringCommands .= "newpath \n";
206 $this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
207 $this->stringCommands .= "0 " . $y_to . " rlineto \n";
208 $this->stringCommands .= $x_to . " 0 rlineto \n";
209 $this->stringCommands .= "0 -" . $y_to . " rlineto \n";
210 $this->stringCommands .= "closepath \n";
211 $this->stringCommands .= "stroke \n";
215 * Set the current point
217 * The moveto operator takes two numbers off the stack and treats
218 * them as x and y coordinates to which to move. The coordinates
219 * specified become the current point.
221 * @param integer $x The x attribute defines the left position of the element
222 * @param integer $y The y attribute defines the right position of the element
224 * @return void
226 * @access public
228 function moveTo($x, $y)
230 $this->stringCommands .= $x . ' ' . $y . " moveto \n";
234 * Output/Display the text
236 * @param string $text The string to be displayed
238 * @return void
240 * @access public
242 function show($text)
244 $this->stringCommands .= '(' . $text . ") show \n";
248 * Output the text at specified co-ordinates
250 * @param string $text String to be displayed
251 * @param integer $x X attribute defines the left position of the element
252 * @param integer $y Y attribute defines the right position of the element
254 * @return void
256 * @access public
258 function showXY($text, $x, $y)
260 $this->moveTo($x, $y);
261 $this->show($text);
265 * get width of string/text
267 * EPS text width is calcualted depending on font name
268 * and font size. It is very important to know the width of text
269 * because rectangle is drawn around it.
271 * This is a bit hardcore method. I didn't found any other better than this.
272 * if someone found better than this. would love to hear that method
274 * @param string $text string that width will be calculated
275 * @param integer $font name of the font like Arial,sans-serif etc
276 * @param integer $fontSize size of font
278 * @return integer width of the text
280 * @access public
282 function getStringWidth($text,$font,$fontSize)
285 * Start by counting the width, giving each character a modifying value
287 $count = 0;
288 $count = $count + ((strlen($text) - strlen(str_replace(array("i", "j", "l"), "", $text))) * 0.23);//ijl
289 $count = $count + ((strlen($text) - strlen(str_replace(array("f"), "", $text))) * 0.27);//f
290 $count = $count + ((strlen($text) - strlen(str_replace(array("t", "I"), "", $text))) * 0.28);//tI
291 $count = $count + ((strlen($text) - strlen(str_replace(array("r"), "", $text))) * 0.34);//r
292 $count = $count + ((strlen($text) - strlen(str_replace(array("1"), "", $text))) * 0.49);//1
293 $count = $count + ((strlen($text) - strlen(str_replace(array("c", "k", "s", "v", "x", "y", "z", "J"), "", $text))) * 0.5);//cksvxyzJ
294 $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
295 $count = $count + ((strlen($text) - strlen(str_replace(array("F", "T", "Z"), "", $text))) * 0.61);//FTZ
296 $count = $count + ((strlen($text) - strlen(str_replace(array("A", "B", "E", "K", "P", "S", "V", "X", "Y"), "", $text))) * 0.67);//ABEKPSVXY
297 $count = $count + ((strlen($text) - strlen(str_replace(array("w", "C", "D", "H", "N", "R", "U"), "", $text))) * 0.73);//wCDHNRU
298 $count = $count + ((strlen($text) - strlen(str_replace(array("G", "O", "Q"), "", $text))) * 0.78);//GOQ
299 $count = $count + ((strlen($text) - strlen(str_replace(array("m", "M"), "", $text))) * 0.84);//mM
300 $count = $count + ((strlen($text) - strlen(str_replace("W", "", $text))) * .95);//W
301 $count = $count + ((strlen($text) - strlen(str_replace(" ", "", $text))) * .28);//" "
302 $text = str_replace(" ", "", $text);//remove the " "'s
303 $count = $count + (strlen(preg_replace("/[a-z0-9]/i", "", $text)) * 0.3); //all other chrs
305 $modifier = 1;
306 $font = strtolower($font);
307 switch ($font) {
309 * no modifier for arial and sans-serif
311 case 'arial':
312 case 'sans-serif':
313 break;
315 * .92 modifer for time, serif, brushscriptstd, and californian fb
317 case 'times':
318 case 'serif':
319 case 'brushscriptstd':
320 case 'californian fb':
321 $modifier = .92;
322 break;
324 * 1.23 modifier for broadway
326 case 'broadway':
327 $modifier = 1.23;
328 break;
330 $textWidth = $count*$fontSize;
331 return ceil($textWidth*$modifier);
335 * Ends EPS Document
337 * @return void
338 * @access public
340 function endEpsDoc()
342 $this->stringCommands .= "showpage \n";
346 * Output EPS Document for download
348 * @param string $fileName name of the eps document
350 * @return void
352 * @access public
354 function showOutput($fileName)
356 // if(ob_get_clean()){
357 //ob_end_clean();
359 $output = $this->stringCommands;
360 PMA_Response::getInstance()->disable();
361 PMA_downloadHeader($fileName . '.eps', 'image/x-eps', strlen($output));
362 print $output;
367 * Table preferences/statistics
369 * This class preserves the table co-ordinates,fields
370 * and helps in drawing/generating the Tables in EPS.
372 * @name Table_Stats
373 * @see PMA_EPS
375 class Table_Stats
378 * Defines properties
381 private $_tableName;
382 private $_showInfo = false;
384 public $width = 0;
385 public $height;
386 public $fields = array();
387 public $heightCell = 0;
388 public $currentCell = 0;
389 public $x, $y;
390 public $primary = array();
393 * The "Table_Stats" constructor
395 * @param string $tableName The table name
396 * @param string $font The font name
397 * @param integer $fontSize The font size
398 * @param integer $pageNumber Page number
399 * @param integer &$same_wide_width The max width among tables
400 * @param boolean $showKeys Whether to display keys or not
401 * @param boolean $showInfo Whether to display table position or not
403 * @global object The current eps document
404 * @global integer The current page number (from the
405 * $cfg['Servers'][$i]['table_coords'] table)
406 * @global array The relations settings
407 * @global string The current db name
409 * @access private
410 * @see PMA_EPS, Table_Stats::Table_Stats_setWidth,
411 * Table_Stats::Table_Stats_setHeight
413 function __construct(
414 $tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
415 $showKeys = false, $showInfo = false
417 global $eps, $cfgRelation, $db;
419 $this->_tableName = $tableName;
420 $sql = 'DESCRIBE ' . PMA_Util::backquote($tableName);
421 $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
422 if (! $result || ! PMA_DBI_num_rows($result)) {
423 $eps->dieSchema(
424 $pageNumber, "EPS",
425 sprintf(__('The %s table doesn\'t exist!'), $tableName)
430 * load fields
431 * check to see if it will load all fields or only the foreign keys
433 if ($showKeys) {
434 $indexes = PMA_Index::getFromTable($this->_tableName, $db);
435 $all_columns = array();
436 foreach ($indexes as $index) {
437 $all_columns = array_merge(
438 $all_columns,
439 array_flip(array_keys($index->getColumns()))
442 $this->fields = array_keys($all_columns);
443 } else {
444 while ($row = PMA_DBI_fetch_row($result)) {
445 $this->fields[] = $row[0];
449 $this->_showInfo = $showInfo;
451 // height and width
452 $this->_setHeightTable($fontSize);
454 // setWidth must me after setHeight, because title
455 // can include table height which changes table width
456 $this->_setWidthTable($font, $fontSize);
457 if ($same_wide_width < $this->width) {
458 $same_wide_width = $this->width;
461 // x and y
462 $sql = 'SELECT x, y FROM '
463 . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
464 . PMA_Util::backquote($cfgRelation['table_coords'])
465 . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
466 . ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\''
467 . ' AND pdf_page_number = ' . $pageNumber;
468 $result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
470 if (! $result || ! PMA_DBI_num_rows($result)) {
471 $eps->dieSchema(
472 $pageNumber, "EPS",
473 sprintf(
474 __('Please configure the coordinates for table %s'),
475 $tableName
479 list($this->x, $this->y) = PMA_DBI_fetch_row($result);
480 $this->x = (double) $this->x;
481 $this->y = (double) $this->y;
482 // displayfield
483 $this->displayfield = PMA_getDisplayField($db, $tableName);
484 // index
485 $result = PMA_DBI_query(
486 'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';',
487 null, PMA_DBI_QUERY_STORE
489 if (PMA_DBI_num_rows($result) > 0) {
490 while ($row = PMA_DBI_fetch_assoc($result)) {
491 if ($row['Key_name'] == 'PRIMARY') {
492 $this->primary[] = $row['Column_name'];
499 * Returns title of the current table,
500 * title can have the dimensions/co-ordinates of the table
502 * @return string The relation/table name
503 * @access private
505 private function _getTitle()
507 return ($this->_showInfo
508 ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell)
509 : '') . ' ' . $this->_tableName;
513 * Sets the width of the table
515 * @param string $font The font name
516 * @param integer $fontSize The font size
518 * @global object The current eps document
520 * @return void
522 * @access private
523 * @see PMA_EPS
525 private function _setWidthTable($font,$fontSize)
527 global $eps;
529 foreach ($this->fields as $field) {
530 $this->width = max(
531 $this->width,
532 $eps->getStringWidth($field, $font, $fontSize)
535 $this->width += $eps->getStringWidth(' ', $font, $fontSize);
537 * it is unknown what value must be added, because
538 * table title is affected by the tabe width value
540 while ($this->width < $eps->getStringWidth($this->_getTitle(), $font, $fontSize)) {
541 $this->width += 7;
546 * Sets the height of the table
548 * @param integer $fontSize The font size
550 * @return void
551 * @access private
553 private function _setHeightTable($fontSize)
555 $this->heightCell = $fontSize + 4;
556 $this->height = (count($this->fields) + 1) * $this->heightCell;
560 * Draw the table
562 * @param boolean $showColor Whether to display color
564 * @global object The current eps document
566 * @return void
568 * @access public
569 * @see PMA_EPS,PMA_EPS::line,PMA_EPS::rect
571 public function tableDraw($showColor)
573 global $eps;
574 //echo $this->_tableName.'<br />';
575 $eps->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1);
576 $eps->showXY($this->_getTitle(), $this->x + 5, $this->y + 14);
577 foreach ($this->fields as $field) {
578 $this->currentCell += $this->heightCell;
579 $showColor = 'none';
580 if ($showColor) {
581 if (in_array($field, $this->primary)) {
582 $showColor = '#0c0';
584 if ($field == $this->displayfield) {
585 $showColor = 'none';
588 $eps->rect(
589 $this->x, $this->y + 12 + $this->currentCell,
590 $this->width, $this->heightCell, 1
592 $eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
598 * Relation preferences/statistics
600 * This class fetches the table master and foreign fields positions
601 * and helps in generating the Table references and then connects
602 * master table's master field to foreign table's foreign key
603 * in EPS document.
605 * @name Relation_Stats
606 * @see PMA_EPS
608 class Relation_Stats
611 * Defines properties
613 public $xSrc, $ySrc;
614 public $srcDir ;
615 public $destDir;
616 public $xDest, $yDest;
617 public $wTick = 10;
620 * The "Relation_Stats" constructor
622 * @param string $master_table The master table name
623 * @param string $master_field The relation field in the master table
624 * @param string $foreign_table The foreign table name
625 * @param string $foreign_field The relation field in the foreign table
627 * @see Relation_Stats::_getXy
629 function __construct($master_table, $master_field, $foreign_table, $foreign_field)
631 $src_pos = $this->_getXy($master_table, $master_field);
632 $dest_pos = $this->_getXy($foreign_table, $foreign_field);
634 * [0] is x-left
635 * [1] is x-right
636 * [2] is y
638 $src_left = $src_pos[0] - $this->wTick;
639 $src_right = $src_pos[1] + $this->wTick;
640 $dest_left = $dest_pos[0] - $this->wTick;
641 $dest_right = $dest_pos[1] + $this->wTick;
643 $d1 = abs($src_left - $dest_left);
644 $d2 = abs($src_right - $dest_left);
645 $d3 = abs($src_left - $dest_right);
646 $d4 = abs($src_right - $dest_right);
647 $d = min($d1, $d2, $d3, $d4);
649 if ($d == $d1) {
650 $this->xSrc = $src_pos[0];
651 $this->srcDir = -1;
652 $this->xDest = $dest_pos[0];
653 $this->destDir = -1;
654 } elseif ($d == $d2) {
655 $this->xSrc = $src_pos[1];
656 $this->srcDir = 1;
657 $this->xDest = $dest_pos[0];
658 $this->destDir = -1;
659 } elseif ($d == $d3) {
660 $this->xSrc = $src_pos[0];
661 $this->srcDir = -1;
662 $this->xDest = $dest_pos[1];
663 $this->destDir = 1;
664 } else {
665 $this->xSrc = $src_pos[1];
666 $this->srcDir = 1;
667 $this->xDest = $dest_pos[1];
668 $this->destDir = 1;
670 $this->ySrc = $src_pos[2] + 10;
671 $this->yDest = $dest_pos[2] + 10;
675 * Gets arrows coordinates
677 * @param string $table The current table name
678 * @param string $column The relation column name
680 * @return array Arrows coordinates
682 * @access private
684 private function _getXy($table, $column)
686 $pos = array_search($column, $table->fields);
687 // x_left, x_right, y
688 return array(
689 $table->x,
690 $table->x + $table->width,
691 $table->y + ($pos + 1.5) * $table->heightCell
696 * draws relation links and arrows
697 * shows foreign key relations
699 * @param boolean $changeColor Whether to use one color per relation or not
701 * @global object The current EPS document
703 * @access public
704 * @see PMA_EPS
706 * @return void
708 public function relationDraw($changeColor)
710 global $eps;
712 if ($changeColor) {
713 $listOfColors = array(
714 'red',
715 'grey',
716 'black',
717 'yellow',
718 'green',
719 'cyan',
720 ' orange'
722 shuffle($listOfColors);
723 $color = $listOfColors[0];
724 } else {
725 $color = 'black';
727 // draw a line like -- to foreign field
728 $eps->line(
729 $this->xSrc,
730 $this->ySrc,
731 $this->xSrc + $this->srcDir * $this->wTick,
732 $this->ySrc,
735 // draw a line like -- to master field
736 $eps->line(
737 $this->xDest + $this->destDir * $this->wTick,
738 $this->yDest,
739 $this->xDest,
740 $this->yDest,
743 // draw a line that connects to master field line and foreign field line
744 $eps->line(
745 $this->xSrc + $this->srcDir * $this->wTick,
746 $this->ySrc,
747 $this->xDest + $this->destDir * $this->wTick,
748 $this->yDest,
751 $root2 = 2 * sqrt(2);
752 $eps->line(
753 $this->xSrc + $this->srcDir * $this->wTick * 0.75,
754 $this->ySrc,
755 $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
756 $this->ySrc + $this->wTick / $root2,
759 $eps->line(
760 $this->xSrc + $this->srcDir * $this->wTick * 0.75,
761 $this->ySrc,
762 $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
763 $this->ySrc - $this->wTick / $root2,
766 $eps->line(
767 $this->xDest + $this->destDir * $this->wTick / 2,
768 $this->yDest,
769 $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
770 $this->yDest + $this->wTick / $root2,
773 $eps->line(
774 $this->xDest + $this->destDir * $this->wTick / 2,
775 $this->yDest,
776 $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
777 $this->yDest - $this->wTick / $root2,
783 * end of the "Relation_Stats" class
787 * EPS Relation Schema Class
789 * Purpose of this class is to generate the EPS Document
790 * which is used for representing the database diagrams.
791 * This class uses post script commands and with
792 * the combination of these commands actually helps in preparing EPS Document.
794 * This class inherits Export_Relation_Schema class has common functionality added
795 * to this class
797 * @name Eps_Relation_Schema
799 class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
801 private $_tables = array();
802 private $_relations = array();
805 * The "PMA_EPS_Relation_Schema" constructor
807 * Upon instantiation This starts writing the EPS document
808 * user will be prompted for download as .eps extension
810 * @return void
811 * @see PMA_EPS
813 function __construct()
815 global $eps,$db;
817 $this->setPageNumber($_POST['pdf_page_number']);
818 $this->setShowColor(isset($_POST['show_color']));
819 $this->setShowKeys(isset($_POST['show_keys']));
820 $this->setTableDimension(isset($_POST['show_table_dimension']));
821 $this->setAllTablesSameWidth(isset($_POST['all_tables_same_width']));
822 $this->setOrientation($_POST['orientation']);
823 $this->setExportType($_POST['export_type']);
825 $eps = new PMA_EPS();
826 $eps->setTitle(
827 sprintf(
828 __('Schema of the %s database - Page %s'),
829 $db,
830 $this->pageNumber
833 $eps->setAuthor('phpMyAdmin ' . PMA_VERSION);
834 $eps->setDate(date("j F Y, g:i a"));
835 $eps->setOrientation($this->orientation);
836 $eps->setFont('Verdana', '10');
838 $alltables = $this->getAllTables($db, $this->pageNumber);
840 foreach ($alltables AS $table) {
841 if (! isset($this->_tables[$table])) {
842 $this->_tables[$table] = new Table_Stats(
843 $table, $eps->getFont(), $eps->getFontSize(), $this->pageNumber,
844 $this->_tablewidth, $this->showKeys, $this->tableDimension
848 if ($this->sameWide) {
849 $this->_tables[$table]->width = $this->_tablewidth;
853 $seen_a_relation = false;
854 foreach ($alltables as $one_table) {
855 $exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
856 if ($exist_rel) {
857 $seen_a_relation = true;
858 foreach ($exist_rel as $master_field => $rel) {
859 /* put the foreign table on the schema only if selected
860 * by the user
861 * (do not use array_search() because we would have to
862 * to do a === false and this is not PHP3 compatible)
864 if (in_array($rel['foreign_table'], $alltables)) {
865 $this->_addRelation(
866 $one_table, $eps->getFont(), $eps->getFontSize(),
867 $master_field, $rel['foreign_table'],
868 $rel['foreign_field'], $this->tableDimension
874 if ($seen_a_relation) {
875 $this->_drawRelations($this->showColor);
878 $this->_drawTables($this->showColor);
879 $eps->endEpsDoc();
880 $eps->showOutput($db.'-'.$this->pageNumber);
881 exit();
885 * Defines relation objects
887 * @param string $masterTable The master table name
888 * @param string $font The font
889 * @param int $fontSize The font size
890 * @param string $masterField The relation field in the master table
891 * @param string $foreignTable The foreign table name
892 * @param string $foreignField The relation field in the foreign table
893 * @param boolean $showInfo Whether to display table position or not
895 * @return void
897 * @access private
898 * @see _setMinMax,Table_Stats::__construct(),Relation_Stats::__construct()
900 private function _addRelation(
901 $masterTable, $font, $fontSize, $masterField,
902 $foreignTable, $foreignField, $showInfo
904 if (! isset($this->_tables[$masterTable])) {
905 $this->_tables[$masterTable] = new Table_Stats(
906 $masterTable, $font, $fontSize, $this->pageNumber,
907 $this->_tablewidth, false, $showInfo
910 if (! isset($this->_tables[$foreignTable])) {
911 $this->_tables[$foreignTable] = new Table_Stats(
912 $foreignTable, $font, $fontSize, $this->pageNumber,
913 $this->_tablewidth, false, $showInfo
916 $this->_relations[] = new Relation_Stats(
917 $this->_tables[$masterTable], $masterField,
918 $this->_tables[$foreignTable], $foreignField
923 * Draws relation arrows and lines connects master table's master field to
924 * foreign table's forein field
926 * @param boolean $changeColor Whether to use one color per relation or not
928 * @return void
930 * @access private
931 * @see Relation_Stats::relationDraw()
933 private function _drawRelations($changeColor)
935 foreach ($this->_relations as $relation) {
936 $relation->relationDraw($changeColor);
941 * Draws tables
943 * @param boolean $changeColor Whether to show color for primary fields or not
945 * @return void
947 * @access private
948 * @see Table_Stats::Table_Stats_tableDraw()
950 private function _drawTables($changeColor)
952 foreach ($this->_tables as $table) {
953 $table->tableDraw($changeColor);