Update website
This commit is contained in:
parent
a0b0d3dae7
commit
ae7ef6ad45
3151 changed files with 566766 additions and 48 deletions
282
admin/phpMyAdmin/libraries/classes/Plugins/Schema/Eps/Eps.php
Normal file
282
admin/phpMyAdmin/libraries/classes/Plugins/Schema/Eps/Eps.php
Normal file
|
@ -0,0 +1,282 @@
|
|||
<?php
|
||||
/**
|
||||
* Classes to create relation schema in EPS format.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Schema\Eps;
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Response;
|
||||
use function strlen;
|
||||
|
||||
/**
|
||||
* This Class is EPS Library and
|
||||
* helps in developing structure of EPS Schema Export
|
||||
*
|
||||
* @see https://www.php.net/manual/en/book.xmlwriter.php
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
class Eps
|
||||
{
|
||||
/** @var string */
|
||||
public $font;
|
||||
|
||||
/** @var int */
|
||||
public $fontSize;
|
||||
|
||||
/** @var string */
|
||||
public $stringCommands;
|
||||
|
||||
/**
|
||||
* Upon instantiation This starts writing the EPS Document.
|
||||
* %!PS-Adobe-3.0 EPSF-3.0 This is the MUST first comment to include
|
||||
* it shows/tells that the Post Script document is purely under
|
||||
* Document Structuring Convention [DSC] and is Compliant
|
||||
* Encapsulated Post Script Document
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->stringCommands = '';
|
||||
$this->stringCommands .= "%!PS-Adobe-3.0 EPSF-3.0 \n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set document title
|
||||
*
|
||||
* @param string $value sets the title text
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTitle($value)
|
||||
{
|
||||
$this->stringCommands .= '%%Title: ' . $value . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set document author
|
||||
*
|
||||
* @param string $value sets the author
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAuthor($value)
|
||||
{
|
||||
$this->stringCommands .= '%%Creator: ' . $value . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set document creation date
|
||||
*
|
||||
* @param string $value sets the date
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDate($value)
|
||||
{
|
||||
$this->stringCommands .= '%%CreationDate: ' . $value . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set document orientation
|
||||
*
|
||||
* @param string $orientation sets the orientation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setOrientation($orientation)
|
||||
{
|
||||
$this->stringCommands .= "%%PageOrder: Ascend \n";
|
||||
if ($orientation === 'L') {
|
||||
$orientation = 'Landscape';
|
||||
$this->stringCommands .= '%%Orientation: ' . $orientation . "\n";
|
||||
} else {
|
||||
$orientation = 'Portrait';
|
||||
$this->stringCommands .= '%%Orientation: ' . $orientation . "\n";
|
||||
}
|
||||
$this->stringCommands .= "%%EndComments \n";
|
||||
$this->stringCommands .= "%%Pages 1 \n";
|
||||
$this->stringCommands .= "%%BoundingBox: 72 150 144 170 \n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font and size
|
||||
*
|
||||
* font can be set whenever needed in EPS
|
||||
*
|
||||
* @param string $value sets the font name e.g Arial
|
||||
* @param int $size sets the size of the font e.g 10
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
.= "setfont % Make it the current font\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font
|
||||
*
|
||||
* @return string return the font name e.g Arial
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font Size
|
||||
*
|
||||
* @return string|int return the size of the font e.g 10
|
||||
*/
|
||||
public function getFontSize()
|
||||
{
|
||||
return $this->fontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the line
|
||||
*
|
||||
* 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 int $x_from The x_from attribute defines the start
|
||||
* left position of the element
|
||||
* @param int $y_from The y_from attribute defines the start
|
||||
* right position of the element
|
||||
* @param int $x_to The x_to attribute defines the end
|
||||
* left position of the element
|
||||
* @param int $y_to The y_to attribute defines the end
|
||||
* right position of the element
|
||||
* @param int $lineWidth Sets the width of the line e.g 2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public 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";
|
||||
$this->stringCommands .= $x_to . ' ' . $y_to . " lineto \n";
|
||||
$this->stringCommands .= "stroke \n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the rectangle
|
||||
*
|
||||
* 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 int $x_from The x_from attribute defines the start
|
||||
* left position of the element
|
||||
* @param int $y_from The y_from attribute defines the start
|
||||
* right position of the element
|
||||
* @param int $x_to The x_to attribute defines the end
|
||||
* left position of the element
|
||||
* @param int $y_to The y_to attribute defines the end
|
||||
* right position of the element
|
||||
* @param int $lineWidth Sets the width of the line e.g 2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current point
|
||||
*
|
||||
* The moveto operator takes two numbers off the stack and treats
|
||||
* them as x and y coordinates to which to move. The coordinates
|
||||
* specified become the current point.
|
||||
*
|
||||
* @param int $x The x attribute defines the left position of the element
|
||||
* @param int $y The y attribute defines the right position of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function moveTo($x, $y)
|
||||
{
|
||||
$this->stringCommands .= $x . ' ' . $y . " moveto \n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output/Display the text
|
||||
*
|
||||
* @param string $text The string to be displayed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function show($text)
|
||||
{
|
||||
$this->stringCommands .= '(' . $text . ") show \n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the text at specified co-ordinates
|
||||
*
|
||||
* @param string $text String to be displayed
|
||||
* @param int $x X attribute defines the left position of the element
|
||||
* @param int $y Y attribute defines the right position of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showXY($text, $x, $y)
|
||||
{
|
||||
$this->moveTo($x, $y);
|
||||
$this->show($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends EPS Document
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endEpsDoc()
|
||||
{
|
||||
$this->stringCommands .= "showpage \n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output EPS Document for download
|
||||
*
|
||||
* @param string $fileName name of the eps document
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showOutput($fileName)
|
||||
{
|
||||
// if(ob_get_clean()){
|
||||
//ob_end_clean();
|
||||
//}
|
||||
$output = $this->stringCommands;
|
||||
Response::getInstance()
|
||||
->disable();
|
||||
Core::downloadHeader(
|
||||
$fileName,
|
||||
'image/x-eps',
|
||||
strlen($output)
|
||||
);
|
||||
print $output;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,252 @@
|
|||
<?php
|
||||
/**
|
||||
* Classes to create relation schema in EPS format.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Schema\Eps;
|
||||
|
||||
use PhpMyAdmin\Plugins\Schema\Dia\TableStatsDia;
|
||||
use PhpMyAdmin\Plugins\Schema\ExportRelationSchema;
|
||||
use PhpMyAdmin\Plugins\Schema\Pdf\TableStatsPdf;
|
||||
use PhpMyAdmin\Plugins\Schema\Svg\TableStatsSvg;
|
||||
use function date;
|
||||
use function in_array;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* EPS Relation Schema Class
|
||||
*
|
||||
* Purpose of this class is to generate the EPS Document
|
||||
* which is used for representing the database diagrams.
|
||||
* This class uses post script commands and with
|
||||
* the combination of these commands actually helps in preparing EPS Document.
|
||||
*
|
||||
* This class inherits ExportRelationSchema class has common functionality added
|
||||
* to this class
|
||||
*
|
||||
* @name EpsRelationSchema
|
||||
*/
|
||||
class EpsRelationSchema extends ExportRelationSchema
|
||||
{
|
||||
/** @var TableStatsDia[]|TableStatsEps[]|TableStatsPdf[]|TableStatsSvg[] */
|
||||
private $tables = [];
|
||||
|
||||
/** @var RelationStatsEps[] Relations */
|
||||
private $relations = [];
|
||||
|
||||
/** @var int */
|
||||
private $tablewidth;
|
||||
|
||||
/**
|
||||
* Upon instantiation This starts writing the EPS document
|
||||
* user will be prompted for download as .eps extension
|
||||
*
|
||||
* @see PMA_EPS
|
||||
*
|
||||
* @param string $db database name
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
parent::__construct($db, new Eps());
|
||||
|
||||
$this->setShowColor(isset($_REQUEST['eps_show_color']));
|
||||
$this->setShowKeys(isset($_REQUEST['eps_show_keys']));
|
||||
$this->setTableDimension(isset($_REQUEST['eps_show_table_dimension']));
|
||||
$this->setAllTablesSameWidth(isset($_REQUEST['eps_all_tables_same_width']));
|
||||
$this->setOrientation((string) $_REQUEST['eps_orientation']);
|
||||
|
||||
$this->diagram->setTitle(
|
||||
sprintf(
|
||||
__('Schema of the %s database - Page %s'),
|
||||
$this->db,
|
||||
$this->pageNumber
|
||||
)
|
||||
);
|
||||
$this->diagram->setAuthor('phpMyAdmin ' . PMA_VERSION);
|
||||
$this->diagram->setDate(date('j F Y, g:i a'));
|
||||
$this->diagram->setOrientation($this->orientation);
|
||||
$this->diagram->setFont('Verdana', '10');
|
||||
|
||||
$alltables = $this->getTablesFromRequest();
|
||||
|
||||
foreach ($alltables as $table) {
|
||||
if (! isset($this->tables[$table])) {
|
||||
$this->tables[$table] = new TableStatsEps(
|
||||
$this->diagram,
|
||||
$this->db,
|
||||
$table,
|
||||
$this->diagram->getFont(),
|
||||
$this->diagram->getFontSize(),
|
||||
$this->pageNumber,
|
||||
$this->tablewidth,
|
||||
$this->showKeys,
|
||||
$this->tableDimension,
|
||||
$this->offline
|
||||
);
|
||||
}
|
||||
|
||||
if (! $this->sameWide) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->tables[$table]->width = $this->tablewidth;
|
||||
}
|
||||
|
||||
$seen_a_relation = false;
|
||||
foreach ($alltables as $one_table) {
|
||||
$exist_rel = $this->relation->getForeigners($this->db, $one_table, '', 'both');
|
||||
if (! $exist_rel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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)
|
||||
*/
|
||||
if ($master_field !== 'foreign_keys_data') {
|
||||
if (in_array($rel['foreign_table'], $alltables)) {
|
||||
$this->addRelation(
|
||||
$one_table,
|
||||
$this->diagram->getFont(),
|
||||
$this->diagram->getFontSize(),
|
||||
$master_field,
|
||||
$rel['foreign_table'],
|
||||
$rel['foreign_field'],
|
||||
$this->tableDimension
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($rel as $one_key) {
|
||||
if (! in_array($one_key['ref_table_name'], $alltables)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($one_key['index_list'] as $index => $one_field) {
|
||||
$this->addRelation(
|
||||
$one_table,
|
||||
$this->diagram->getFont(),
|
||||
$this->diagram->getFontSize(),
|
||||
$one_field,
|
||||
$one_key['ref_table_name'],
|
||||
$one_key['ref_index_list'][$index],
|
||||
$this->tableDimension
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($seen_a_relation) {
|
||||
$this->drawRelations();
|
||||
}
|
||||
|
||||
$this->drawTables();
|
||||
$this->diagram->endEpsDoc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Output Eps Document for download
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showOutput()
|
||||
{
|
||||
$this->diagram->showOutput($this->getFileName('.eps'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines relation objects
|
||||
*
|
||||
* @see _setMinMax
|
||||
* @see TableStatsEps::__construct()
|
||||
* @see PhpMyAdmin\Plugins\Schema\Eps\RelationStatsEps::__construct()
|
||||
*
|
||||
* @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 bool $tableDimension Whether to display table position or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addRelation(
|
||||
$masterTable,
|
||||
$font,
|
||||
$fontSize,
|
||||
$masterField,
|
||||
$foreignTable,
|
||||
$foreignField,
|
||||
$tableDimension
|
||||
) {
|
||||
if (! isset($this->tables[$masterTable])) {
|
||||
$this->tables[$masterTable] = new TableStatsEps(
|
||||
$this->diagram,
|
||||
$this->db,
|
||||
$masterTable,
|
||||
$font,
|
||||
$fontSize,
|
||||
$this->pageNumber,
|
||||
$this->tablewidth,
|
||||
false,
|
||||
$tableDimension
|
||||
);
|
||||
}
|
||||
if (! isset($this->tables[$foreignTable])) {
|
||||
$this->tables[$foreignTable] = new TableStatsEps(
|
||||
$this->diagram,
|
||||
$this->db,
|
||||
$foreignTable,
|
||||
$font,
|
||||
$fontSize,
|
||||
$this->pageNumber,
|
||||
$this->tablewidth,
|
||||
false,
|
||||
$tableDimension
|
||||
);
|
||||
}
|
||||
$this->relations[] = new RelationStatsEps(
|
||||
$this->diagram,
|
||||
$this->tables[$masterTable],
|
||||
$masterField,
|
||||
$this->tables[$foreignTable],
|
||||
$foreignField
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws relation arrows and lines connects master table's master field to
|
||||
* foreign table's foreign field
|
||||
*
|
||||
* @see RelationStatsEps::relationDraw()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function drawRelations()
|
||||
{
|
||||
foreach ($this->relations as $relation) {
|
||||
$relation->relationDraw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws tables
|
||||
*
|
||||
* @see TableStatsEps::Table_Stats_tableDraw()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function drawTables()
|
||||
{
|
||||
foreach ($this->tables as $table) {
|
||||
$table->tableDraw($this->showColor);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
/**
|
||||
* Contains PhpMyAdmin\Plugins\Schema\Eps\RelationStatsEps class
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Schema\Eps;
|
||||
|
||||
use PhpMyAdmin\Plugins\Schema\RelationStats;
|
||||
use function sqrt;
|
||||
|
||||
/**
|
||||
* Relation preferences/statistics
|
||||
*
|
||||
* This class fetches the table master and foreign fields positions
|
||||
* and helps in generating the Table references and then connects
|
||||
* master table's master field to foreign table's foreign key
|
||||
* in EPS document.
|
||||
*
|
||||
* @see Eps
|
||||
*
|
||||
* @name RelationStatsEps
|
||||
*/
|
||||
class RelationStatsEps extends RelationStats
|
||||
{
|
||||
/**
|
||||
* @param Eps $diagram The EPS diagram
|
||||
* @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
|
||||
*/
|
||||
public function __construct(
|
||||
$diagram,
|
||||
$master_table,
|
||||
$master_field,
|
||||
$foreign_table,
|
||||
$foreign_field
|
||||
) {
|
||||
$this->wTick = 10;
|
||||
parent::__construct(
|
||||
$diagram,
|
||||
$master_table,
|
||||
$master_field,
|
||||
$foreign_table,
|
||||
$foreign_field
|
||||
);
|
||||
$this->ySrc += 10;
|
||||
$this->yDest += 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* draws relation links and arrows
|
||||
* shows foreign key relations
|
||||
*
|
||||
* @see Eps
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function relationDraw()
|
||||
{
|
||||
// draw a line like -- to foreign field
|
||||
$this->diagram->line(
|
||||
$this->xSrc,
|
||||
$this->ySrc,
|
||||
$this->xSrc + $this->srcDir * $this->wTick,
|
||||
$this->ySrc,
|
||||
1
|
||||
);
|
||||
// draw a line like -- to master field
|
||||
$this->diagram->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
|
||||
$this->diagram->line(
|
||||
$this->xSrc + $this->srcDir * $this->wTick,
|
||||
$this->ySrc,
|
||||
$this->xDest + $this->destDir * $this->wTick,
|
||||
$this->yDest,
|
||||
1
|
||||
);
|
||||
$root2 = 2 * sqrt(2);
|
||||
$this->diagram->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
|
||||
);
|
||||
$this->diagram->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
|
||||
);
|
||||
$this->diagram->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
|
||||
);
|
||||
$this->diagram->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
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
/**
|
||||
* Contains PhpMyAdmin\Plugins\Schema\Eps\TableStatsEps class
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Schema\Eps;
|
||||
|
||||
use PhpMyAdmin\Plugins\Schema\ExportRelationSchema;
|
||||
use PhpMyAdmin\Plugins\Schema\TableStats;
|
||||
use function count;
|
||||
use function max;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Table preferences/statistics
|
||||
*
|
||||
* This class preserves the table co-ordinates,fields
|
||||
* and helps in drawing/generating the Tables in EPS.
|
||||
*
|
||||
* @see Eps
|
||||
*
|
||||
* @name TableStatsEps
|
||||
*/
|
||||
class TableStatsEps extends TableStats
|
||||
{
|
||||
/** @var int */
|
||||
public $height;
|
||||
|
||||
/** @var int */
|
||||
public $currentCell = 0;
|
||||
|
||||
/**
|
||||
* @see Eps
|
||||
* @see TableStatsEps::setWidthTable
|
||||
* @see TableStatsEps::setHeightTable
|
||||
*
|
||||
* @param object $diagram The EPS diagram
|
||||
* @param string $db The database name
|
||||
* @param string $tableName The table name
|
||||
* @param string $font The font name
|
||||
* @param int $fontSize The font size
|
||||
* @param int $pageNumber Page number
|
||||
* @param int $same_wide_width The max width among tables
|
||||
* @param bool $showKeys Whether to display keys or not
|
||||
* @param bool $tableDimension Whether to display table position or not
|
||||
* @param bool $offline Whether the coordinates are sent
|
||||
* from the browser
|
||||
*/
|
||||
public function __construct(
|
||||
$diagram,
|
||||
$db,
|
||||
$tableName,
|
||||
$font,
|
||||
$fontSize,
|
||||
$pageNumber,
|
||||
&$same_wide_width,
|
||||
$showKeys = false,
|
||||
$tableDimension = false,
|
||||
$offline = false
|
||||
) {
|
||||
parent::__construct(
|
||||
$diagram,
|
||||
$db,
|
||||
$pageNumber,
|
||||
$tableName,
|
||||
$showKeys,
|
||||
$tableDimension,
|
||||
$offline
|
||||
);
|
||||
|
||||
// height and width
|
||||
$this->setHeightTable($fontSize);
|
||||
// setWidth must me after setHeight, because title
|
||||
// can include table height which changes table width
|
||||
$this->setWidthTable($font, $fontSize);
|
||||
if ($same_wide_width >= $this->width) {
|
||||
return;
|
||||
}
|
||||
|
||||
$same_wide_width = $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an error when the table cannot be found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showMissingTableError()
|
||||
{
|
||||
ExportRelationSchema::dieSchema(
|
||||
$this->pageNumber,
|
||||
'EPS',
|
||||
sprintf(__('The %s table doesn\'t exist!'), $this->tableName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the table
|
||||
*
|
||||
* @see Eps
|
||||
*
|
||||
* @param string $font The font name
|
||||
* @param int $fontSize The font size
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setWidthTable($font, $fontSize)
|
||||
{
|
||||
foreach ($this->fields as $field) {
|
||||
$this->width = max(
|
||||
$this->width,
|
||||
$this->font->getStringWidth($field, $font, (int) $fontSize)
|
||||
);
|
||||
}
|
||||
$this->width += $this->font->getStringWidth(
|
||||
' ',
|
||||
$font,
|
||||
(int) $fontSize
|
||||
);
|
||||
/*
|
||||
* it is unknown what value must be added, because
|
||||
* table title is affected by the table width value
|
||||
*/
|
||||
while ($this->width
|
||||
< $this->font->getStringWidth(
|
||||
$this->getTitle(),
|
||||
$font,
|
||||
(int) $fontSize
|
||||
)
|
||||
) {
|
||||
$this->width += 7;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the height of the table
|
||||
*
|
||||
* @param int $fontSize The font size
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setHeightTable($fontSize)
|
||||
{
|
||||
$this->heightCell = $fontSize + 4;
|
||||
$this->height = (count($this->fields) + 1) * $this->heightCell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the table
|
||||
*
|
||||
* @see Eps
|
||||
* @see Eps::line
|
||||
* @see Eps::rect
|
||||
*
|
||||
* @param bool $showColor Whether to display color
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tableDraw($showColor)
|
||||
{
|
||||
$this->diagram->rect(
|
||||
$this->x,
|
||||
$this->y + 12,
|
||||
$this->width,
|
||||
$this->heightCell,
|
||||
1
|
||||
);
|
||||
$this->diagram->showXY($this->getTitle(), $this->x + 5, $this->y + 14);
|
||||
foreach ($this->fields as $field) {
|
||||
$this->currentCell += $this->heightCell;
|
||||
$this->diagram->rect(
|
||||
$this->x,
|
||||
$this->y + 12 + $this->currentCell,
|
||||
$this->width,
|
||||
$this->heightCell,
|
||||
1
|
||||
);
|
||||
$this->diagram->showXY(
|
||||
$field,
|
||||
$this->x + 5,
|
||||
$this->y + 14 + $this->currentCell
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue