Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
14b0b0ea9a
@ -578,8 +578,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
|
||||
echo '<input id="col_visib" type="hidden" value="' . implode(',', $col_visib) . '" />';
|
||||
}
|
||||
// generate table create time
|
||||
echo '<input id="table_create_time" type="hidden" value="' .
|
||||
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
|
||||
if (! PMA_Table::isView($GLOBALS['table'], $GLOBALS['db'])) {
|
||||
echo '<input id="table_create_time" type="hidden" value="' .
|
||||
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
|
||||
include_once("Export_Relation_Schema.class.php");
|
||||
include_once "Export_Relation_Schema.class.php";
|
||||
|
||||
/**
|
||||
* This Class inherits the XMLwriter class and
|
||||
@ -14,7 +14,6 @@ include_once("Export_Relation_Schema.class.php");
|
||||
* @access public
|
||||
* @see http://php.net/manual/en/book.xmlwriter.php
|
||||
*/
|
||||
|
||||
class PMA_DIA extends XMLWriter
|
||||
{
|
||||
public $title;
|
||||
@ -44,7 +43,7 @@ class PMA_DIA extends XMLWriter
|
||||
* Create the XML document
|
||||
*/
|
||||
|
||||
$this->startDocument('1.0','UTF-8');
|
||||
$this->startDocument('1.0', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,27 +54,29 @@ class PMA_DIA extends XMLWriter
|
||||
* to define the document, then finally a Layer starts which
|
||||
* holds all the objects.
|
||||
*
|
||||
* @param string paper The size of the paper/document
|
||||
* @param float topMargin top margin of the paper/document in cm
|
||||
* @param float bottomMargin bottom margin of the paper/document in cm
|
||||
* @param float leftMargin left margin of the paper/document in cm
|
||||
* @param float rightMargin right margin of the paper/document in cm
|
||||
* @param string portrait document will be portrait or landscape
|
||||
* @param string $paper the size of the paper/document
|
||||
* @param float $topMargin top margin of the paper/document in cm
|
||||
* @param float $bottomMargin bottom margin of the paper/document in cm
|
||||
* @param float $leftMargin left margin of the paper/document in cm
|
||||
* @param float $rightMargin right margin of the paper/document in cm
|
||||
* @param string $portrait document will be portrait or landscape
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @see XMLWriter::startElement(),XMLWriter::writeAttribute(),XMLWriter::writeRaw()
|
||||
*/
|
||||
function startDiaDoc($paper,$topMargin,$bottomMargin,$leftMargin,$rightMargin,$portrait)
|
||||
{
|
||||
if($portrait == 'P'){
|
||||
if ($portrait == 'P') {
|
||||
$isPortrait='true';
|
||||
}else{
|
||||
} else {
|
||||
$isPortrait='false';
|
||||
}
|
||||
$this->startElement('dia:diagram');
|
||||
$this->writeAttribute('xmlns:dia', 'http://www.lysator.liu.se/~alla/dia/');
|
||||
$this->startElement('dia:diagramdata');
|
||||
$this->writeRaw (
|
||||
$this->writeRaw(
|
||||
'<dia:attribute name="background">
|
||||
<dia:color val="#ffffff"/>
|
||||
</dia:attribute>
|
||||
@ -85,22 +86,22 @@ class PMA_DIA extends XMLWriter
|
||||
<dia:attribute name="paper">
|
||||
<dia:composite type="paper">
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#'.$paper.'#</dia:string>
|
||||
<dia:string>#' . $paper . '#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="tmargin">
|
||||
<dia:real val="'.$topMargin.'"/>
|
||||
<dia:real val="' . $topMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="bmargin">
|
||||
<dia:real val="'.$bottomMargin.'"/>
|
||||
<dia:real val="' . $bottomMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="lmargin">
|
||||
<dia:real val="'.$leftMargin.'"/>
|
||||
<dia:real val="' . $leftMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="rmargin">
|
||||
<dia:real val="'.$rightMargin.'"/>
|
||||
<dia:real val="' . $rightMargin . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="is_portrait">
|
||||
<dia:boolean val="'.$isPortrait.'"/>
|
||||
<dia:boolean val="' . $isPortrait . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="scaling">
|
||||
<dia:real val="1"/>
|
||||
@ -160,18 +161,21 @@ class PMA_DIA extends XMLWriter
|
||||
/**
|
||||
* Output Dia Document for download
|
||||
*
|
||||
* @param string fileName name of the dia document
|
||||
* @param string $fileName name of the dia document
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
* @see XMLWriter::flush()
|
||||
*/
|
||||
function showOutput($fileName)
|
||||
{
|
||||
if(ob_get_clean()){
|
||||
if (ob_get_clean()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
$output = $this->flush();
|
||||
PMA_download_header($fileName . '.dia', 'application/x-dia-diagram', strlen($output));
|
||||
PMA_download_header(
|
||||
$fileName . '.dia', 'application/x-dia-diagram', strlen($output)
|
||||
);
|
||||
print $output;
|
||||
}
|
||||
}
|
||||
@ -200,14 +204,17 @@ class Table_Stats
|
||||
/**
|
||||
* The "Table_Stats" constructor
|
||||
*
|
||||
* @param string table_name The table name
|
||||
* @param integer pageNumber The current page number (from the
|
||||
* $cfg['Servers'][$i]['table_coords'] table)
|
||||
* @param boolean showKeys Whether to display ONLY keys or not
|
||||
* @param string $tableName The table name
|
||||
* @param integer $pageNumber The current page number (from the
|
||||
* $cfg['Servers'][$i]['table_coords'] table)
|
||||
* @param boolean $showKeys Whether to display ONLY keys or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @global object The current dia document
|
||||
* @global array The relations settings
|
||||
* @global string The current db name
|
||||
*
|
||||
* @see PMA_DIA
|
||||
*/
|
||||
function __construct($tableName, $pageNumber, $showKeys = false)
|
||||
@ -218,7 +225,10 @@ class Table_Stats
|
||||
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
|
||||
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (!$result || !PMA_DBI_num_rows($result)) {
|
||||
$dia->dieSchema($pageNumber,"DIA",sprintf(__('The %s table doesn\'t exist!'), $tableName));
|
||||
$dia->dieSchema(
|
||||
$pageNumber, "DIA",
|
||||
sprintf(__('The %s table doesn\'t exist!'), $tableName)
|
||||
);
|
||||
}
|
||||
/*
|
||||
* load fields
|
||||
@ -228,7 +238,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 {
|
||||
@ -238,13 +251,21 @@ class Table_Stats
|
||||
}
|
||||
|
||||
$sql = 'SELECT x, y FROM '
|
||||
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||
. 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)) {
|
||||
$dia->dieSchema($pageNumber,"DIA",sprintf(__('Please configure the coordinates for table %s'), $tableName));
|
||||
if (! $result || ! PMA_DBI_num_rows($result)) {
|
||||
$dia->dieSchema(
|
||||
$pageNumber,
|
||||
"DIA",
|
||||
sprintf(
|
||||
__('Please configure the coordinates for table %s'),
|
||||
$tableName
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
|
||||
$this->x = (double) $this->x;
|
||||
@ -256,7 +277,11 @@ class Table_Stats
|
||||
/*
|
||||
* 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') {
|
||||
@ -280,13 +305,15 @@ class Table_Stats
|
||||
* is used to generate the XML of Dia Document. Database Table
|
||||
* Object and their attributes are involved in the combination
|
||||
* of displaing Database - Table on Dia Document.
|
||||
|
||||
* @param boolean changeColor Whether to show color for tables text or not
|
||||
if changeColor is true then an array of $listOfColors
|
||||
will be used to choose the random colors for tables text
|
||||
we can change/add more colors to this array
|
||||
@return void
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @param boolean $changeColor Whether to show color for tables text or not
|
||||
* if changeColor is true then an array of $listOfColors will be used to choose
|
||||
* the random colors for tables text we can change/add more colors to this array
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @access public
|
||||
* @see PMA_DIA
|
||||
*/
|
||||
@ -301,7 +328,7 @@ class Table_Stats
|
||||
'00FF00'
|
||||
);
|
||||
shuffle($listOfColors);
|
||||
$this->tableColor = '#'.$listOfColors[0].'';
|
||||
$this->tableColor = '#' . $listOfColors[0] . '';
|
||||
} else {
|
||||
$this->tableColor = '#000000';
|
||||
}
|
||||
@ -311,19 +338,22 @@ class Table_Stats
|
||||
$dia->startElement('dia:object');
|
||||
$dia->writeAttribute('type', 'Database - Table');
|
||||
$dia->writeAttribute('version', '0');
|
||||
$dia->writeAttribute('id', ''.$this->tableId.'');
|
||||
$dia->writeAttribute('id', '' . $this->tableId . '');
|
||||
$dia->writeRaw(
|
||||
'<dia:attribute name="obj_pos">
|
||||
<dia:point val="'.($this->x * $factor).','.($this->y * $factor).'"/>
|
||||
<dia:point val="'
|
||||
. ($this->x * $factor) . ',' . ($this->y * $factor) . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="'.($this->x * $factor).','.($this->y * $factor).';9.97,9.2"/>
|
||||
<dia:rectangle val="'
|
||||
.($this->x * $factor) . ',' . ($this->y * $factor) . ';9.97,9.2"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="meta">
|
||||
<dia:composite type="dict"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="'.($this->x * $factor).','.($this->y * $factor).'"/>
|
||||
<dia:point val="'
|
||||
. ($this->x * $factor) . ',' . ($this->y * $factor) . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5.9199999999999999"/>
|
||||
@ -332,7 +362,7 @@ class Table_Stats
|
||||
<dia:real val="3.5"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="text_colour">
|
||||
<dia:color val="'.$this->tableColor.'"/>
|
||||
<dia:color val="' . $this->tableColor . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="line_colour">
|
||||
<dia:color val="#000000"/>
|
||||
@ -344,7 +374,7 @@ class Table_Stats
|
||||
<dia:real val="0.10000000000000001"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#'.$this->tableName.'#</dia:string>
|
||||
<dia:string>#' . $this->tableName . '#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="comment">
|
||||
<dia:string>##</dia:string>
|
||||
@ -379,44 +409,44 @@ class Table_Stats
|
||||
<dia:attribute name="comment_font_height">
|
||||
<dia:real val="0.69999999999999996"/>
|
||||
</dia:attribute>'
|
||||
);
|
||||
);
|
||||
|
||||
$dia->startElement('dia:attribute');
|
||||
$dia->writeAttribute('name', 'attributes');
|
||||
|
||||
foreach ($this->fields as $field) {
|
||||
$dia->writeRaw(
|
||||
'<dia:composite type="table_attribute">
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#'.$field.'#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="type">
|
||||
<dia:string>##</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="comment">
|
||||
$dia->writeRaw(
|
||||
'<dia:composite type="table_attribute">
|
||||
<dia:attribute name="name">
|
||||
<dia:string>#' . $field . '#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="type">
|
||||
<dia:string>##</dia:string>
|
||||
</dia:attribute>'
|
||||
);
|
||||
unset($pm);
|
||||
$pm = 'false';
|
||||
if (in_array($field, $this->primary)) {
|
||||
$pm = 'true';
|
||||
}
|
||||
if ($field == $this->displayfield) {
|
||||
$pm = 'false';
|
||||
}
|
||||
$dia->writeRaw(
|
||||
'<dia:attribute name="primary_key">
|
||||
<dia:boolean val="'.$pm.'"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="nullable">
|
||||
<dia:boolean val="false"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="unique">
|
||||
<dia:boolean val="'.$pm.'"/>
|
||||
</dia:attribute>
|
||||
</dia:composite>'
|
||||
);
|
||||
</dia:attribute>
|
||||
<dia:attribute name="comment">
|
||||
<dia:string>##</dia:string>
|
||||
</dia:attribute>'
|
||||
);
|
||||
unset($pm);
|
||||
$pm = 'false';
|
||||
if (in_array($field, $this->primary)) {
|
||||
$pm = 'true';
|
||||
}
|
||||
if ($field == $this->displayfield) {
|
||||
$pm = 'false';
|
||||
}
|
||||
$dia->writeRaw(
|
||||
'<dia:attribute name="primary_key">
|
||||
<dia:boolean val="' . $pm . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="nullable">
|
||||
<dia:boolean val="false"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="unique">
|
||||
<dia:boolean val="' . $pm . '"/>
|
||||
</dia:attribute>
|
||||
</dia:composite>'
|
||||
);
|
||||
}
|
||||
$dia->endElement();
|
||||
$dia->endElement();
|
||||
@ -452,11 +482,13 @@ 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
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @see Relation_Stats::_getXy
|
||||
*/
|
||||
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
|
||||
@ -480,9 +512,11 @@ class Relation_Stats
|
||||
* then determines its left and right connection
|
||||
* points.
|
||||
*
|
||||
* @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 Table right,left connection points and key position
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function _getXy($table, $column)
|
||||
@ -490,8 +524,7 @@ class Relation_Stats
|
||||
$pos = array_search($column, $table->fields);
|
||||
// left, right, position
|
||||
$value = 12;
|
||||
if($pos != 0)
|
||||
{
|
||||
if ($pos != 0) {
|
||||
return array($pos + $value + $pos, $pos + $value + $pos + 1, $pos);
|
||||
}
|
||||
return array($pos + $value , $pos + $value + 1, $pos);
|
||||
@ -506,12 +539,14 @@ class Relation_Stats
|
||||
* Database reference Object and their attributes are involved
|
||||
* in the combination of displaing Database - reference on Dia Document.
|
||||
*
|
||||
* @param boolean changeColor Whether to use one color per relation or not
|
||||
if changeColor is true then an array of $listOfColors
|
||||
will be used to choose the random colors for references
|
||||
lines. we can change/add more colors to this array
|
||||
* @param boolean $changeColor Whether to use one color per relation or not
|
||||
* if changeColor is true then an array of $listOfColors will be used to choose
|
||||
* the random colors for references lines. we can change/add more colors to this
|
||||
*
|
||||
* @return void
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @global object The current Dia document
|
||||
*
|
||||
* @access public
|
||||
* @see PMA_PDF
|
||||
*/
|
||||
@ -525,8 +560,8 @@ class Relation_Stats
|
||||
* points are same then return it false and don't draw that
|
||||
* relation
|
||||
*/
|
||||
if ( $this->srcConnPointsRight == $this->destConnPointsRight ){
|
||||
if ( $this->srcConnPointsLeft == $this->destConnPointsLeft ){
|
||||
if ( $this->srcConnPointsRight == $this->destConnPointsRight) {
|
||||
if ( $this->srcConnPointsLeft == $this->destConnPointsLeft) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -538,13 +573,14 @@ class Relation_Stats
|
||||
'00FF00'
|
||||
);
|
||||
shuffle($listOfColors);
|
||||
$this->referenceColor = '#'.$listOfColors[0].'';
|
||||
$this->referenceColor = '#' . $listOfColors[0] . '';
|
||||
} else {
|
||||
$this->referenceColor = '#000000';
|
||||
}
|
||||
|
||||
$dia->writeRaw(
|
||||
'<dia:object type="Database - Reference" version="0" id="'.PMA_Dia_Relation_Schema::$objectId.'">
|
||||
'<dia:object type="Database - Reference" version="0" id="'
|
||||
. PMA_Dia_Relation_Schema::$objectId . '">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="3.27,18.9198"/>
|
||||
</dia:attribute>
|
||||
@ -576,7 +612,7 @@ class Relation_Stats
|
||||
<dia:color val="#000000"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="line_colour">
|
||||
<dia:color val="'.$this->referenceColor.'"/>
|
||||
<dia:color val="' . $this->referenceColor . '"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="line_width">
|
||||
<dia:real val="0.10000000000000001"/>
|
||||
@ -610,11 +646,15 @@ class Relation_Stats
|
||||
<dia:real val="0.59999999999999998"/>
|
||||
</dia:attribute>
|
||||
<dia:connections>
|
||||
<dia:connection handle="0" to="'.$this->masterTableId.'" connection="'.$this->srcConnPointsRight.'"/>
|
||||
<dia:connection handle="1" to="'.$this->foreignTableId.'" connection="'.$this->destConnPointsRight.'"/>
|
||||
<dia:connection handle="0" to="'
|
||||
. $this->masterTableId . '" connection="'
|
||||
. $this->srcConnPointsRight . '"/>
|
||||
<dia:connection handle="1" to="'
|
||||
. $this->foreignTableId . '" connection="'
|
||||
. $this->destConnPointsRight . '"/>
|
||||
</dia:connections>
|
||||
</dia:object>'
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -667,11 +707,16 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->setExportType($_POST['export_type']);
|
||||
|
||||
$dia = new PMA_DIA();
|
||||
$dia->startDiaDoc($this->paper,$this->_topMargin,$this->_bottomMargin,$this->_leftMargin,$this->_rightMargin,$this->orientation);
|
||||
$alltables = $this->getAllTables($db,$this->pageNumber);
|
||||
$dia->startDiaDoc(
|
||||
$this->paper, $this->_topMargin, $this->_bottomMargin,
|
||||
$this->_leftMargin, $this->_rightMargin, $this->orientation
|
||||
);
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
foreach ($alltables as $table) {
|
||||
if (! isset($this->tables[$table])) {
|
||||
$this->tables[$table] = new Table_Stats($table, $this->pageNumber, $this->showKeys);
|
||||
$this->tables[$table] = new Table_Stats(
|
||||
$table, $this->pageNumber, $this->showKeys
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,12 +727,15 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$seen_a_relation = true;
|
||||
foreach ($exist_rel as $master_field => $rel) {
|
||||
/* put the foreign table on the schema only if selected
|
||||
* by the user
|
||||
* (do not use array_search() because we would have to
|
||||
* to do a === false and this is not PHP3 compatible)
|
||||
*/
|
||||
* by the user
|
||||
* (do not use array_search() because we would have to
|
||||
* to do a === false and this is not PHP3 compatible)
|
||||
*/
|
||||
if (in_array($rel['foreign_table'], $alltables)) {
|
||||
$this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field'],$this->showKeys);
|
||||
$this->_addRelation(
|
||||
$one_table, $master_field, $rel['foreign_table'],
|
||||
$rel['foreign_field'], $this->showKeys
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -698,30 +746,40 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->_drawRelations($this->showColor);
|
||||
}
|
||||
$dia->endDiaDoc();
|
||||
$dia->showOutput($db.'-'.$this->pageNumber);
|
||||
$dia->showOutput($db . '-' . $this->pageNumber);
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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 bool $showKeys Whether to display ONLY keys or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see Table_Stats::__construct(),Relation_Stats::__construct()
|
||||
*/
|
||||
private function _addRelation($masterTable, $masterField, $foreignTable, $foreignField, $showKeys)
|
||||
{
|
||||
if (! isset($this->tables[$masterTable])) {
|
||||
$this->tables[$masterTable] = new Table_Stats($masterTable, $this->pageNumber, $showKeys);
|
||||
$this->tables[$masterTable] = new Table_Stats(
|
||||
$masterTable, $this->pageNumber, $showKeys
|
||||
);
|
||||
}
|
||||
if (! isset($this->tables[$foreignTable])) {
|
||||
$this->tables[$foreignTable] = new Table_Stats($foreignTable, $this->pageNumber, $showKeys);
|
||||
$this->tables[$foreignTable] = new Table_Stats(
|
||||
$foreignTable, $this->pageNumber, $showKeys
|
||||
);
|
||||
}
|
||||
$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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -731,8 +789,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
* foreign table's forein field using Dia object
|
||||
* type Database - Reference
|
||||
*
|
||||
* @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()
|
||||
*/
|
||||
@ -749,8 +809,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
* Tables are generated using Dia object type Database - Table
|
||||
* primary fields are underlined and bold in tables
|
||||
*
|
||||
* @param boolean changeColor Whether to show color for tables text or not
|
||||
* @param boolean $changeColor Whether to show color for tables text or not
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @see Table_Stats::tableDraw()
|
||||
*/
|
||||
|
||||
@ -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()
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user