diff options
5 files changed, 93 insertions, 217 deletions
diff --git a/libraries/plugins/schema/RelationStats.class.php b/libraries/plugins/schema/RelationStats.class.php index a79facf200..b61020609e 100644 --- a/libraries/plugins/schema/RelationStats.class.php +++ b/libraries/plugins/schema/RelationStats.class.php @@ -21,6 +21,88 @@ if (! defined('PHPMYADMIN')) { */ abstract class RealtionStats { + /** + * Defines properties + */ + public $xSrc, $ySrc; + public $srcDir ; + public $destDir; + public $xDest, $yDest; + public $wTick; + /** + * The constructor + * + * @param string $master_table The master table name + * @param string $master_field The relation field in the master table + * @param string $foreign_table The foreign table name + * @param string $foreign_field The relation field in the foreign table + */ + function __construct( + $master_table, $master_field, $foreign_table, $foreign_field + ) { + $src_pos = $this->_getXy($master_table, $master_field); + $dest_pos = $this->_getXy($foreign_table, $foreign_field); + /* + * [0] is x-left + * [1] is x-right + * [2] is y + */ + $src_left = $src_pos[0] - $this->wTick; + $src_right = $src_pos[1] + $this->wTick; + $dest_left = $dest_pos[0] - $this->wTick; + $dest_right = $dest_pos[1] + $this->wTick; + + $d1 = abs($src_left - $dest_left); + $d2 = abs($src_right - $dest_left); + $d3 = abs($src_left - $dest_right); + $d4 = abs($src_right - $dest_right); + $d = min($d1, $d2, $d3, $d4); + + if ($d == $d1) { + $this->xSrc = $src_pos[0]; + $this->srcDir = -1; + $this->xDest = $dest_pos[0]; + $this->destDir = -1; + } elseif ($d == $d2) { + $this->xSrc = $src_pos[1]; + $this->srcDir = 1; + $this->xDest = $dest_pos[0]; + $this->destDir = -1; + } elseif ($d == $d3) { + $this->xSrc = $src_pos[0]; + $this->srcDir = -1; + $this->xDest = $dest_pos[1]; + $this->destDir = 1; + } else { + $this->xSrc = $src_pos[1]; + $this->srcDir = 1; + $this->xDest = $dest_pos[1]; + $this->destDir = 1; + } + $this->ySrc = $src_pos[2]; + $this->yDest = $dest_pos[2]; + } + + /** + * Gets arrows coordinates + * + * @param string $table The current table name + * @param string $column The relation column name + * + * @return array Arrows coordinates + * + * @access private + */ + private function _getXy($table, $column) + { + $pos = array_search($column, $table->fields); + // x_left, x_right, y + return array( + $table->x, + $table->x + $table->width, + $table->y + ($pos + 1.5) * $table->heightCell + ); + } } ?>
\ No newline at end of file diff --git a/libraries/plugins/schema/dia/RelationStatsDia.class.php b/libraries/plugins/schema/dia/RelationStatsDia.class.php index 772257ed7f..04438d55e8 100644 --- a/libraries/plugins/schema/dia/RelationStatsDia.class.php +++ b/libraries/plugins/schema/dia/RelationStatsDia.class.php @@ -9,8 +9,6 @@ if (! defined('PHPMYADMIN')) { exit; } -require_once 'libraries/plugins/schema/RelationStats.class.php'; - /** * Relation preferences/statistics * @@ -23,7 +21,7 @@ require_once 'libraries/plugins/schema/RelationStats.class.php'; * @name Relation_Stats_Dia * @see PMA_DIA */ -class Relation_Stats_Dia extends RealtionStats +class Relation_Stats_Dia { /** * Defines properties diff --git a/libraries/plugins/schema/eps/RelationStatsEps.class.php b/libraries/plugins/schema/eps/RelationStatsEps.class.php index 65ff70f8d2..916cafda6f 100644 --- a/libraries/plugins/schema/eps/RelationStatsEps.class.php +++ b/libraries/plugins/schema/eps/RelationStatsEps.class.php @@ -26,92 +26,25 @@ require_once 'libraries/plugins/schema/RelationStats.class.php'; class Relation_Stats_Eps extends RealtionStats { /** - * Defines properties - */ - public $xSrc, $ySrc; - public $srcDir ; - public $destDir; - public $xDest, $yDest; - public $wTick = 10; - - /** * The "Relation_Stats_Eps" constructor * * @param string $master_table The master table name * @param string $master_field The relation field in the master table * @param string $foreign_table The foreign table name * @param string $foreign_field The relation field in the foreign table - * - * @see Relation_Stats_Eps::_getXy */ function __construct( $master_table, $master_field, $foreign_table, $foreign_field ) { - $src_pos = $this->_getXy($master_table, $master_field); - $dest_pos = $this->_getXy($foreign_table, $foreign_field); - /* - * [0] is x-left - * [1] is x-right - * [2] is y - */ - $src_left = $src_pos[0] - $this->wTick; - $src_right = $src_pos[1] + $this->wTick; - $dest_left = $dest_pos[0] - $this->wTick; - $dest_right = $dest_pos[1] + $this->wTick; - - $d1 = abs($src_left - $dest_left); - $d2 = abs($src_right - $dest_left); - $d3 = abs($src_left - $dest_right); - $d4 = abs($src_right - $dest_right); - $d = min($d1, $d2, $d3, $d4); - - if ($d == $d1) { - $this->xSrc = $src_pos[0]; - $this->srcDir = -1; - $this->xDest = $dest_pos[0]; - $this->destDir = -1; - } elseif ($d == $d2) { - $this->xSrc = $src_pos[1]; - $this->srcDir = 1; - $this->xDest = $dest_pos[0]; - $this->destDir = -1; - } elseif ($d == $d3) { - $this->xSrc = $src_pos[0]; - $this->srcDir = -1; - $this->xDest = $dest_pos[1]; - $this->destDir = 1; - } else { - $this->xSrc = $src_pos[1]; - $this->srcDir = 1; - $this->xDest = $dest_pos[1]; - $this->destDir = 1; - } + $this->wTick = 10; + parent::__construct( + $master_table, $master_field, $foreign_table, $foreign_field + ); $this->ySrc = $src_pos[2] + 10; $this->yDest = $dest_pos[2] + 10; } /** - * Gets arrows coordinates - * - * @param string $table The current table name - * @param string $column The relation column name - * - * @return array Arrows coordinates - * - * @access private - */ - private function _getXy($table, $column) - { - $pos = array_search($column, $table->fields); - // x_left, x_right, y - return array( - $table->x, - $table->x + $table->width, - $table->y + ($pos + 1.5) * $table->heightCell - ); - } - - /** * draws relation links and arrows * shows foreign key relations * diff --git a/libraries/plugins/schema/pdf/RelationStatsPdf.class.php b/libraries/plugins/schema/pdf/RelationStatsPdf.class.php index 1d0e02d951..cbb7fc22f4 100644 --- a/libraries/plugins/schema/pdf/RelationStatsPdf.class.php +++ b/libraries/plugins/schema/pdf/RelationStatsPdf.class.php @@ -27,88 +27,19 @@ require_once 'libraries/plugins/schema/RelationStats.class.php'; class Relation_Stats_Pdf extends RealtionStats { /** - * Defines properties - */ - public $xSrc, $ySrc; - public $srcDir; - public $destDir; - public $xDest, $yDest; - public $wTick = 5; - - /** * The "Relation_Stats_Pdf" constructor * * @param string $master_table The master table name * @param string $master_field The relation field in the master table * @param string $foreign_table The foreign table name * @param string $foreign_field The relation field in the foreign table - * - * @see Relation_Stats_Pdf::_getXy */ function __construct($master_table, $master_field, $foreign_table, $foreign_field ) { - $src_pos = $this->_getXy($master_table, $master_field); - $dest_pos = $this->_getXy($foreign_table, $foreign_field); - /* - * [0] is x-left - * [1] is x-right - * [2] is y - */ - $src_left = $src_pos[0] - $this->wTick; - $src_right = $src_pos[1] + $this->wTick; - $dest_left = $dest_pos[0] - $this->wTick; - $dest_right = $dest_pos[1] + $this->wTick; - - $d1 = abs($src_left - $dest_left); - $d2 = abs($src_right - $dest_left); - $d3 = abs($src_left - $dest_right); - $d4 = abs($src_right - $dest_right); - $d = min($d1, $d2, $d3, $d4); - - if ($d == $d1) { - $this->xSrc = $src_pos[0]; - $this->srcDir = -1; - $this->xDest = $dest_pos[0]; - $this->destDir = -1; - } elseif ($d == $d2) { - $this->xSrc = $src_pos[1]; - $this->srcDir = 1; - $this->xDest = $dest_pos[0]; - $this->destDir = -1; - } elseif ($d == $d3) { - $this->xSrc = $src_pos[0]; - $this->srcDir = -1; - $this->xDest = $dest_pos[1]; - $this->destDir = 1; - } else { - $this->xSrc = $src_pos[1]; - $this->srcDir = 1; - $this->xDest = $dest_pos[1]; - $this->destDir = 1; - } - $this->ySrc = $src_pos[2]; - $this->yDest = $dest_pos[2]; - } - - /** - * Gets arrows coordinates - * - * @param string $table The current table name - * @param string $column The relation column name - * - * @return array Arrows coordinates - * - * @access private - */ - private function _getXy($table, $column) - { - $pos = array_search($column, $table->fields); - // x_left, x_right, y - return array( - $table->x, - $table->x + $table->width, - $table->y + ($pos + 1.5) * $table->heightCell + $this->wTick = 5; + parent::__construct( + $master_table, $master_field, $foreign_table, $foreign_field ); } diff --git a/libraries/plugins/schema/svg/RelationStatsSvg.class.php b/libraries/plugins/schema/svg/RelationStatsSvg.class.php index b8ec990c05..aebb3c6410 100644 --- a/libraries/plugins/schema/svg/RelationStatsSvg.class.php +++ b/libraries/plugins/schema/svg/RelationStatsSvg.class.php @@ -26,87 +26,19 @@ require_once 'libraries/plugins/schema/RelationStats.class.php'; class Relation_Stats_Svg extends RealtionStats { /** - * Defines properties - */ - public $xSrc, $ySrc; - public $srcDir ; - public $destDir; - public $xDest, $yDest; - public $wTick = 10; - - /** * The "Relation_Stats_Svg" constructor * * @param string $master_table The master table name * @param string $master_field The relation field in the master table * @param string $foreign_table The foreign table name * @param string $foreign_field The relation field in the foreign table - * - * @see Relation_Stats_Svg::_getXy */ function __construct($master_table, $master_field, $foreign_table, $foreign_field ) { - $src_pos = $this->_getXy($master_table, $master_field); - $dest_pos = $this->_getXy($foreign_table, $foreign_field); - /* - * [0] is x-left - * [1] is x-right - * [2] is y - */ - $src_left = $src_pos[0] - $this->wTick; - $src_right = $src_pos[1] + $this->wTick; - $dest_left = $dest_pos[0] - $this->wTick; - $dest_right = $dest_pos[1] + $this->wTick; - - $d1 = abs($src_left - $dest_left); - $d2 = abs($src_right - $dest_left); - $d3 = abs($src_left - $dest_right); - $d4 = abs($src_right - $dest_right); - $d = min($d1, $d2, $d3, $d4); - - if ($d == $d1) { - $this->xSrc = $src_pos[0]; - $this->srcDir = -1; - $this->xDest = $dest_pos[0]; - $this->destDir = -1; - } elseif ($d == $d2) { - $this->xSrc = $src_pos[1]; - $this->srcDir = 1; - $this->xDest = $dest_pos[0]; - $this->destDir = -1; - } elseif ($d == $d3) { - $this->xSrc = $src_pos[0]; - $this->srcDir = -1; - $this->xDest = $dest_pos[1]; - $this->destDir = 1; - } else { - $this->xSrc = $src_pos[1]; - $this->srcDir = 1; - $this->xDest = $dest_pos[1]; - $this->destDir = 1; - } - $this->ySrc = $src_pos[2]; - $this->yDest = $dest_pos[2]; - } - - /** - * Gets arrows coordinates - * - * @param string $table The current table name - * @param string $column The relation column name - * - * @return array Arrows coordinates - * @access private - */ - function _getXy($table, $column) - { - $pos = array_search($column, $table->fields); - // x_left, x_right, y - return array( - $table->x, - $table->x + $table->width, - $table->y + ($pos + 1.5) * $table->heightCell + $this->wTick = 10; + parent::__construct( + $master_table, $master_field, $foreign_table, $foreign_field ); } |