Coding style improvements to Eps_Relation_Schema

This commit is contained in:
Madhura Jayaratne 2011-08-20 07:30:11 +05:30
parent c5b108b716
commit 249a1d5c8c

View File

@ -5,7 +5,7 @@
* @package phpMyAdmin
*/
include_once("Export_Relation_Schema.class.php");
include_once "Export_Relation_Schema.class.php";
/**
* This Class is EPS Library and
@ -42,8 +42,10 @@ class PMA_EPS
/**
* Set document title
*
* @param string value sets the title text
* @param string $value sets the title text
*
* @return void
*
* @access public
*/
function setTitle($value)
@ -54,8 +56,10 @@ class PMA_EPS
/**
* Set document author
*
* @param string value sets the author
* @param string $value sets the author
*
* @return void
*
* @access public
*/
function setAuthor($value)
@ -66,8 +70,10 @@ class PMA_EPS
/**
* Set document creation date
*
* @param string value sets the date
* @param string $value sets the date
*
* @return void
*
* @access public
*/
function setDate($value)
@ -78,17 +84,19 @@ class PMA_EPS
/**
* Set document orientation
*
* @param string value sets the author
* @param string $value sets the author
*
* @return void
*
* @access public
*/
function setOrientation($value)
{
$this->stringCommands .= "%%PageOrder: Ascend \n";
if($value == "L"){
if ($value == "L") {
$value = "Landscape";
$this->stringCommands .= '%%Orientation: ' . $value . "\n";
}else{
} else {
$value = "Portrait";
$this->stringCommands .= '%%Orientation: ' . $value . "\n";
}
@ -102,17 +110,19 @@ class PMA_EPS
*
* font can be set whenever needed in EPS
*
* @param string value sets the font name e.g Arial
* @param integer value sets the size of the font e.g 10
* @param string $value sets the font name e.g Arial
* @param integer $value sets the size of the font e.g 10
*
* @return void
*
* @access public
*/
function setFont($value,$size)
{
$this->font = $value;
$this->fontSize = $size;
$this->stringCommands .= "/".$value." findfont % Get the basic font\n";
$this->stringCommands .= "".$size." scalefont % Scale the font to $size points\n";
$this->stringCommands .= "/" . $value . " findfont % Get the basic font\n";
$this->stringCommands .= "" . $size . " scalefont % Scale the font to $size points\n";
$this->stringCommands .= "setfont % Make it the current font\n";
}
@ -144,19 +154,21 @@ class PMA_EPS
* drawing the lines from x,y source to x,y destination and set the
* width of the line. lines helps in showing relationships of tables
*
* @param integer x_from The x_from attribute defines the start
left position of the element
* @param integer y_from The y_from attribute defines the start
right position of the element
* @param integer x_to The x_to attribute defines the end
left position of the element
* @param integer y_to The y_to attribute defines the end
right position of the element
* @param integer lineWidth sets the width of the line e.g 2
* @param integer $x_from The x_from attribute defines the start
* left position of the element
* @param integer $y_from The y_from attribute defines the start
* right position of the element
* @param integer $x_to The x_to attribute defines the end
* left position of the element
* @param integer $y_to The y_to attribute defines the end
* right position of the element
* @param integer $lineWidth Sets the width of the line e.g 2
*
* @return void
*
* @access public
*/
function line($x_from=0, $y_from=0, $x_to=0, $y_to=0, $lineWidth=0)
function line($x_from = 0, $y_from = 0, $x_to = 0, $y_to = 0, $lineWidth = 0)
{
$this->stringCommands .= $lineWidth . " setlinewidth \n";
$this->stringCommands .= $x_from . ' ' . $y_from . " moveto \n";
@ -170,28 +182,30 @@ class PMA_EPS
* drawing the rectangle from x,y source to x,y destination and set the
* width of the line. rectangles drawn around the text shown of fields
*
* @param integer x_from The x_from attribute defines the start
left position of the element
* @param integer y_from The y_from attribute defines the start
right position of the element
* @param integer x_to The x_to attribute defines the end
left position of the element
* @param integer y_to The y_to attribute defines the end
right position of the element
* @param integer lineWidth sets the width of the line e.g 2
* @param integer $x_from The x_from attribute defines the start
left position of the element
* @param integer $y_from The y_from attribute defines the start
right position of the element
* @param integer $x_to The x_to attribute defines the end
left position of the element
* @param integer $y_to The y_to attribute defines the end
right position of the element
* @param integer $lineWidth Sets the width of the line e.g 2
*
* @return void
*
* @access public
*/
function rect($x_from, $y_from, $x_to, $y_to, $lineWidth)
{
$this->stringCommands .= $lineWidth . " setlinewidth \n";
$this->stringCommands .= "newpath \n";
$this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
$this->stringCommands .= "0 " . $y_to . " rlineto \n";
$this->stringCommands .= $x_to . " 0 rlineto \n";
$this->stringCommands .= "0 -" . $y_to . " rlineto \n";
$this->stringCommands .= "closepath \n";
$this->stringCommands .= "stroke \n";
$this->stringCommands .= $lineWidth . " setlinewidth \n";
$this->stringCommands .= "newpath \n";
$this->stringCommands .= $x_from . " " . $y_from . " moveto \n";
$this->stringCommands .= "0 " . $y_to . " rlineto \n";
$this->stringCommands .= $x_to . " 0 rlineto \n";
$this->stringCommands .= "0 -" . $y_to . " rlineto \n";
$this->stringCommands .= "closepath \n";
$this->stringCommands .= "stroke \n";
}
/**
@ -201,11 +215,11 @@ class PMA_EPS
* them as x and y coordinates to which to move. The coordinates
* specified become the current point.
*
* @param integer x The x attribute defines the
left position of the element
* @param integer y The y attribute defines the
right position of the element
* @param integer $x The x attribute defines the left position of the element
* @param integer $y The y attribute defines the right position of the element
*
* @return void
*
* @access public
*/
function moveTo($x, $y)
@ -216,31 +230,33 @@ class PMA_EPS
/**
* Output/Display the text
*
* @param string text The string to be displayed
* @param string $text The string to be displayed
*
* @return void
*
* @access public
*/
function show($text)
{
$this->stringCommands .= '(' . $text . ") show \n";
}
function show($text)
{
$this->stringCommands .= '(' . $text . ") show \n";
}
/**
* Output the text at specified co-ordinates
*
* @param string text The string to be displayed
* @param integer x The x attribute defines the
left position of the element
* @param integer y The y attribute defines the
right position of the element
* @param string $text String to be displayed
* @param integer $x X attribute defines the left position of the element
* @param integer $y Y attribute defines the right position of the element
*
* @return void
*
* @access public
*/
function showXY($text, $x, $y)
{
$this->moveTo($x, $y);
$this->show($text);
}
function showXY($text, $x, $y)
{
$this->moveTo($x, $y);
$this->show($text);
}
/**
* get width of string/text
@ -252,10 +268,12 @@ class PMA_EPS
* This is a bit hardcore method. I didn't found any other better than this.
* if someone found better than this. would love to hear that method
*
* @param string text string that width will be calculated
* @param integer font name of the font like Arial,sans-serif etc
* @param integer fontSize size of font
* @param string $text string that width will be calculated
* @param integer $font name of the font like Arial,sans-serif etc
* @param integer $fontSize size of font
*
* @return integer width of the text
*
* @access public
*/
function getStringWidth($text,$font,$fontSize)
@ -264,22 +282,22 @@ class PMA_EPS
* Start by counting the width, giving each character a modifying value
*/
$count = 0;
$count = $count + ((strlen($text) - strlen(str_replace(array("i","j","l"),"",$text)))*0.23);//ijl
$count = $count + ((strlen($text) - strlen(str_replace(array("f"),"",$text)))*0.27);//f
$count = $count + ((strlen($text) - strlen(str_replace(array("t","I"),"",$text)))*0.28);//tI
$count = $count + ((strlen($text) - strlen(str_replace(array("r"),"",$text)))*0.34);//r
$count = $count + ((strlen($text) - strlen(str_replace(array("1"),"",$text)))*0.49);//1
$count = $count + ((strlen($text) - strlen(str_replace(array("c","k","s","v","x","y","z","J"),"",$text)))*0.5);//cksvxyzJ
$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
$count = $count + ((strlen($text) - strlen(str_replace(array("F","T","Z"),"",$text)))*0.61);//FTZ
$count = $count + ((strlen($text) - strlen(str_replace(array("A","B","E","K","P","S","V","X","Y"),"",$text)))*0.67);//ABEKPSVXY
$count = $count + ((strlen($text) - strlen(str_replace(array("w","C","D","H","N","R","U"),"",$text)))*0.73);//wCDHNRU
$count = $count + ((strlen($text) - strlen(str_replace(array("G","O","Q"),"",$text)))*0.78);//GOQ
$count = $count + ((strlen($text) - strlen(str_replace(array("m","M"),"",$text)))*0.84);//mM
$count = $count + ((strlen($text) - strlen(str_replace("W","",$text)))*.95);//W
$count = $count + ((strlen($text) - strlen(str_replace(" ","",$text)))*.28);//" "
$text = str_replace(" ","",$text);//remove the " "'s
$count = $count + (strlen(preg_replace("/[a-z0-9]/i","",$text))*0.3); //all other chrs
$count = $count + ((strlen($text) - strlen(str_replace(array("i", "j", "l"), "", $text))) * 0.23);//ijl
$count = $count + ((strlen($text) - strlen(str_replace(array("f"), "", $text))) * 0.27);//f
$count = $count + ((strlen($text) - strlen(str_replace(array("t", "I"), "", $text))) * 0.28);//tI
$count = $count + ((strlen($text) - strlen(str_replace(array("r"), "", $text))) * 0.34);//r
$count = $count + ((strlen($text) - strlen(str_replace(array("1"), "", $text))) * 0.49);//1
$count = $count + ((strlen($text) - strlen(str_replace(array("c", "k", "s", "v", "x", "y", "z", "J"), "", $text))) * 0.5);//cksvxyzJ
$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
$count = $count + ((strlen($text) - strlen(str_replace(array("F", "T", "Z"), "", $text))) * 0.61);//FTZ
$count = $count + ((strlen($text) - strlen(str_replace(array("A", "B", "E", "K", "P", "S", "V", "X", "Y"), "", $text))) * 0.67);//ABEKPSVXY
$count = $count + ((strlen($text) - strlen(str_replace(array("w", "C", "D", "H", "N", "R", "U"), "", $text))) * 0.73);//wCDHNRU
$count = $count + ((strlen($text) - strlen(str_replace(array("G", "O", "Q"), "", $text))) * 0.78);//GOQ
$count = $count + ((strlen($text) - strlen(str_replace(array("m", "M"), "", $text))) * 0.84);//mM
$count = $count + ((strlen($text) - strlen(str_replace("W", "", $text))) * .95);//W
$count = $count + ((strlen($text) - strlen(str_replace(" ", "", $text))) * .28);//" "
$text = str_replace(" ", "", $text);//remove the " "'s
$count = $count + (strlen(preg_replace("/[a-z0-9]/i", "", $text)) * 0.3); //all other chrs
$modifier = 1;
$font = strtolower($font);
@ -289,7 +307,7 @@ class PMA_EPS
*/
case 'arial':
case 'sans-serif':
break;
break;
/*
* .92 modifer for time, serif, brushscriptstd, and californian fb
*/
@ -298,13 +316,13 @@ class PMA_EPS
case 'brushscriptstd':
case 'californian fb':
$modifier = .92;
break;
break;
/*
* 1.23 modifier for broadway
*/
case 'broadway':
$modifier = 1.23;
break;
break;
}
$textWidth = $count*$fontSize;
return ceil($textWidth*$modifier);
@ -324,8 +342,10 @@ class PMA_EPS
/**
* Output EPS Document for download
*
* @param string fileName name of the eps document
* @param string $fileName name of the eps document
*
* @return void
*
* @access public
*/
function showOutput($fileName)
@ -368,30 +388,37 @@ class Table_Stats
/**
* The "Table_Stats" constructor
*
* @param string tableName The table name
* @param string font The font name
* @param integer fontSize The font size
* @param integer same_wide_width The max width among tables
* @param boolean showKeys Whether to display keys or not
* @param boolean showInfo Whether to display table position or not
* @param string $tableName The table name
* @param string $font The font name
* @param integer $fontSize The font size
* @param integer $pageNumber Page number
* @param integer &$same_wide_width The max width among tables
* @param boolean $showKeys Whether to display keys or not
* @param boolean $showInfo Whether to display table position or not
*
* @global object The current eps document
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @global array The relations settings
* @global string The current db name
*
* @access private
* @see PMA_EPS, Table_Stats::Table_Stats_setWidth,
Table_Stats::Table_Stats_setHeight
* Table_Stats::Table_Stats_setHeight
*/
function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false)
function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
$showKeys = false, $showInfo = false)
{
global $eps, $cfgRelation, $db;
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$eps->dieSchema($pageNumber,"EPS",sprintf(__('The %s table doesn\'t exist!'), $tableName));
if (! $result || ! PMA_DBI_num_rows($result)) {
$eps->dieSchema(
$pageNumber, "EPS",
sprintf(__('The %s table doesn\'t exist!'), $tableName)
);
}
/*
@ -402,7 +429,10 @@ class Table_Stats
$indexes = PMA_Index::getFromTable($this->_tableName, $db);
$all_columns = array();
foreach ($indexes as $index) {
$all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
$all_columns = array_merge(
$all_columns,
array_flip(array_keys($index->getColumns()))
);
}
$this->fields = array_keys($all_columns);
} else {
@ -418,21 +448,28 @@ class Table_Stats
// setWidth must me after setHeight, because title
// can include table height which changes table width
$this->_setWidthTable($font,$fontSize);
$this->_setWidthTable($font, $fontSize);
if ($same_wide_width < $this->width) {
$same_wide_width = $this->width;
}
// x and y
$sql = 'SELECT x, y FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$eps->dieSchema($pageNumber,"EPS",sprintf(__('Please configure the coordinates for table %s'), $tableName));
if (! $result || ! PMA_DBI_num_rows($result)) {
$eps->dieSchema(
$pageNumber, "EPS",
sprintf(
__('Please configure the coordinates for table %s'),
$tableName
)
);
}
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x;
@ -440,7 +477,10 @@ class Table_Stats
// displayfield
$this->displayfield = PMA_getDisplayField($db, $tableName);
// index
$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
$result = PMA_DBI_query(
'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
null, PMA_DBI_QUERY_STORE
);
if (PMA_DBI_num_rows($result) > 0) {
while ($row = PMA_DBI_fetch_assoc($result)) {
if ($row['Key_name'] == 'PRIMARY') {
@ -459,16 +499,21 @@ class Table_Stats
*/
private function _getTitle()
{
return ($this->_showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '') . ' ' . $this->_tableName;
return ($this->_showInfo
? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell)
: '') . ' ' . $this->_tableName;
}
/**
* Sets the width of the table
*
* @param string font The font name
* @param integer fontSize The font size
* @param string $font The font name
* @param integer $fontSize The font size
*
* @global object The current eps document
*
* @return void
*
* @access private
* @see PMA_EPS
*/
@ -477,14 +522,17 @@ class Table_Stats
global $eps;
foreach ($this->fields as $field) {
$this->width = max($this->width, $eps->getStringWidth($field,$font,$fontSize));
$this->width = max(
$this->width,
$eps->getStringWidth($field, $font, $fontSize)
);
}
$this->width += $eps->getStringWidth(' ',$font,$fontSize);
$this->width += $eps->getStringWidth(' ', $font, $fontSize);
/*
* it is unknown what value must be added, because
* table title is affected by the tabe width value
*/
while ($this->width < $eps->getStringWidth($this->_getTitle(),$font,$fontSize)) {
while ($this->width < $eps->getStringWidth($this->_getTitle(), $font, $fontSize)) {
$this->width += 7;
}
}
@ -492,7 +540,8 @@ class Table_Stats
/**
* Sets the height of the table
*
* @param integer fontSize The font size
* @param integer $fontSize The font size
*
* @return void
* @access private
*/
@ -505,9 +554,12 @@ class Table_Stats
/**
* Draw the table
*
* @param boolean showColor Whether to display color
* @param boolean $showColor Whether to display color
*
* @global object The current eps document
*
* @return void
*
* @access public
* @see PMA_EPS,PMA_EPS::line,PMA_EPS::rect
*/
@ -515,25 +567,24 @@ class Table_Stats
{
global $eps;
//echo $this->_tableName.'<br />';
$eps->rect($this->x,$this->y + 12,
$this->width,$this->heightCell,
1
);
$eps->showXY($this->_getTitle(),$this->x + 5,$this->y + 14);
$eps->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1);
$eps->showXY($this->_getTitle(), $this->x + 5, $this->y + 14);
foreach ($this->fields as $field) {
$this->currentCell += $this->heightCell;
$showColor = 'none';
if ($showColor) {
if (in_array($field, $this->primary)) {
$showColor = '#0c0';
}
if ($field == $this->displayfield) {
$showColor = 'none';
}
$this->currentCell += $this->heightCell;
$showColor = 'none';
if ($showColor) {
if (in_array($field, $this->primary)) {
$showColor = '#0c0';
}
$eps->rect($this->x,$this->y + 12 + $this->currentCell,
$this->width, $this->heightCell,1);
$eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
if ($field == $this->displayfield) {
$showColor = 'none';
}
}
$eps->rect(
$this->x, $this->y + 12 + $this->currentCell,
$this->width, $this->heightCell, 1
);
$eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);
}
}
}
@ -563,10 +614,11 @@ class Relation_Stats
/**
* The "Relation_Stats" 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 foreigh_field The relation field in the foreign table
* @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::_getXy
*/
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
@ -617,26 +669,36 @@ class Relation_Stats
/**
* Gets arrows coordinates
*
* @param string table The current table name
* @param string column The relation column name
* @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);
return array(
$table->x,
$table->x + $table->width,
$table->y + ($pos + 1.5) * $table->heightCell
);
}
/**
* draws relation links and arrows
* shows foreign key relations
*
* @param boolean changeColor Whether to use one color per relation or not
* @global object The current EPS document
* @param boolean $changeColor Whether to use one color per relation or not
*
* @global object The current EPS document
*
* @access public
* @see PMA_EPS
*
* @return void
*/
public function relationDraw($changeColor)
{
@ -658,40 +720,58 @@ class Relation_Stats
$color = 'black';
}
// draw a line like -- to foreign field
$eps->line($this->xSrc,$this->ySrc,
$this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
$eps->line(
$this->xSrc,
$this->ySrc,
$this->xSrc + $this->srcDir * $this->wTick,
$this->ySrc,
1
);
);
// draw a line like -- to master field
$eps->line($this->xDest + $this->destDir * $this->wTick, $this->yDest,
$this->xDest, $this->yDest,
$eps->line(
$this->xDest + $this->destDir * $this->wTick,
$this->yDest,
$this->xDest,
$this->yDest,
1
);
);
// draw a line that connects to master field line and foreign field line
$eps->line($this->xSrc + $this->srcDir * $this->wTick,$this->ySrc,
$this->xDest + $this->destDir * $this->wTick, $this->yDest,
$eps->line(
$this->xSrc + $this->srcDir * $this->wTick,
$this->ySrc,
$this->xDest + $this->destDir * $this->wTick,
$this->yDest,
1
);
);
$root2 = 2 * sqrt(2);
$eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
$this->ySrc + $this->wTick / $root2 ,
$eps->line(
$this->xSrc + $this->srcDir * $this->wTick * 0.75,
$this->ySrc,
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
$this->ySrc + $this->wTick / $root2,
1
);
$eps->line($this->xSrc + $this->srcDir * $this->wTick * 0.75, $this->ySrc,
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick ,
$this->ySrc - $this->wTick / $root2 ,
);
$eps->line(
$this->xSrc + $this->srcDir * $this->wTick * 0.75,
$this->ySrc,
$this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
$this->ySrc - $this->wTick / $root2,
1
);
$eps->line($this->xDest + $this->destDir * $this->wTick / 2 , $this->yDest ,
);
$eps->line(
$this->xDest + $this->destDir * $this->wTick / 2,
$this->yDest,
$this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
$this->yDest + $this->wTick / $root2 ,
1);
$eps->line($this->xDest + $this->destDir * $this->wTick / 2 ,
$this->yDest , $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick ,
$this->yDest - $this->wTick / $root2 ,
$this->yDest + $this->wTick / $root2,
1
);
);
$eps->line(
$this->xDest + $this->destDir * $this->wTick / 2,
$this->yDest,
$this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
$this->yDest - $this->wTick / $root2,
1
);
}
}
/*
@ -738,19 +818,26 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
$this->setExportType($_POST['export_type']);
$eps = new PMA_EPS();
$eps->setTitle(sprintf(__('Schema of the %s database - Page %s'), $db, $this->pageNumber));
$eps->setTitle(
sprintf(
__('Schema of the %s database - Page %s'),
$db,
$this->pageNumber
)
);
$eps->setAuthor('phpMyAdmin ' . PMA_VERSION);
$eps->setDate(date("j F Y, g:i a"));
$eps->setOrientation($this->orientation);
$eps->setFont('Verdana','10');
$eps->setFont('Verdana', '10');
$alltables = $this->getAllTables($db,$this->pageNumber);
$alltables = $this->getAllTables($db, $this->pageNumber);
foreach ($alltables AS $table) {
if (! isset($this->tables[$table])) {
$this->tables[$table] = new Table_Stats($table,$eps->getFont(),$eps->getFontSize(), $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension);
$this->tables[$table] = new Table_Stats(
$table, $eps->getFont(), $eps->getFontSize(), $this->pageNumber,
$this->_tablewidth, $this->showKeys, $this->tableDimension
);
}
if ($this->sameWide) {
@ -770,7 +857,11 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
* to do a === false and this is not PHP3 compatible)
*/
if (in_array($rel['foreign_table'], $alltables)) {
$this->_addRelation($one_table,$eps->getFont(),$eps->getFontSize(), $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->tableDimension);
$this->_addRelation(
$one_table, $eps->getFont(), $eps->getFontSize(),
$master_field, $rel['foreign_table'],
$rel['foreign_field'], $this->tableDimension
);
}
}
}
@ -788,33 +879,48 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Defines relation objects
*
* @param string masterTable The master table name
* @param string masterField The relation field in the master table
* @param string foreignTable The foreign table name
* @param string foreignField The relation field in the foreign table
* @param boolean showInfo Whether to display table position or not
* @param string $masterTable The master table name
* @param string $font The font
* @param int $fontSize The font size
* @param string $masterField The relation field in the master table
* @param string $foreignTable The foreign table name
* @param string $foreignField The relation field in the foreign table
* @param boolean $showInfo Whether to display table position or not
*
* @return void
*
* @access private
* @see _setMinMax,Table_Stats::__construct(),Relation_Stats::__construct()
*/
private function _addRelation($masterTable,$font,$fontSize, $masterField, $foreignTable, $foreignField, $showInfo)
private function _addRelation($masterTable, $font, $fontSize, $masterField,
$foreignTable, $foreignField, $showInfo)
{
if (! isset($this->tables[$masterTable])) {
$this->tables[$masterTable] = new Table_Stats($masterTable, $font, $fontSize, $this->pageNumber, $this->_tablewidth, false, $showInfo);
$this->tables[$masterTable] = new Table_Stats(
$masterTable, $font, $fontSize, $this->pageNumber,
$this->_tablewidth, false, $showInfo
);
}
if (! isset($this->tables[$foreignTable])) {
$this->tables[$foreignTable] = new Table_Stats($foreignTable,$font,$fontSize,$this->pageNumber, $this->_tablewidth, false, $showInfo);
$this->tables[$foreignTable] = new Table_Stats(
$foreignTable, $font, $fontSize, $this->pageNumber,
$this->_tablewidth, false, $showInfo
);
}
$this->_relations[] = new Relation_Stats($this->tables[$masterTable], $masterField, $this->tables[$foreignTable], $foreignField);
$this->_relations[] = new Relation_Stats(
$this->tables[$masterTable], $masterField,
$this->tables[$foreignTable], $foreignField
);
}
/**
* Draws relation arrows and lines
* connects master table's master field to
* Draws relation arrows and lines connects master table's master field to
* foreign table's forein field
*
* @param boolean changeColor Whether to use one color per relation or not
* @param boolean $changeColor Whether to use one color per relation or not
*
* @return void
*
* @access private
* @see Relation_Stats::relationDraw()
*/
@ -828,8 +934,10 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Draws tables
*
* @param boolean changeColor Whether to show color for primary fields or not
* @param boolean $changeColor Whether to show color for primary fields or not
*
* @return void
*
* @access private
* @see Table_Stats::Table_Stats_tableDraw()
*/