2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Contains Table_Stats_Svg class
8 if (! defined('PHPMYADMIN')) {
12 require_once 'libraries/plugins/schema/TableStats.class.php';
15 * Table preferences/statistics
17 * This class preserves the table co-ordinates,fields
18 * and helps in drawing/generating the Tables in SVG XML document.
21 * @name Table_Stats_Svg
24 class Table_Stats_Svg
extends TableStats
30 public $currentCell = 0;
33 * The "Table_Stats_Svg" constructor
35 * @param string $tableName The table name
36 * @param string $font Font face
37 * @param integer $fontSize The font size
38 * @param integer $pageNumber Page number
39 * @param integer &$same_wide_width The max. with among tables
40 * @param boolean $showKeys Whether to display keys or not
41 * @param boolean $tableDimension Whether to display table position or not
42 * @param boolean $offline Whether the coordinates are sent
45 * @global object $svg The current SVG image document
49 * @see PMA_SVG, Table_Stats_Svg::Table_Stats_setWidth,
50 * Table_Stats_Svg::Table_Stats_setHeight
53 $tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
54 $showKeys = false, $tableDimension = false, $offline = false
58 $svg, $GLOBALS['db'], $pageNumber, $tableName,
59 $showKeys, $tableDimension, $offline
63 $this->_setHeightTable($fontSize);
64 // setWidth must me after setHeight, because title
65 // can include table height which changes table width
66 $this->_setWidthTable($font, $fontSize);
67 if ($same_wide_width < $this->width
) {
68 $same_wide_width = $this->width
;
73 * Displays an error when the table cannot be found.
77 protected function showMissingTableError()
79 PMA_Export_Relation_Schema
::dieSchema(
82 sprintf(__('The %s table doesn\'t exist!'), $this->tableName
)
87 * Sets the width of the table
89 * @param string $font The font size
90 * @param integer $fontSize The font size
92 * @global object $svg The current SVG image document
99 private function _setWidthTable($font,$fontSize)
101 foreach ($this->fields
as $field) {
104 PMA_Font
::getStringWidth($field, $font, $fontSize)
107 $this->width +
= PMA_Font
::getStringWidth(' ', $font, $fontSize);
110 * it is unknown what value must be added, because
111 * table title is affected by the table width value
114 < PMA_Font
::getStringWidth($this->getTitle(), $font, $fontSize)
121 * Sets the height of the table
123 * @param integer $fontSize font size
128 function _setHeightTable($fontSize)
130 $this->heightCell
= $fontSize +
4;
131 $this->height
= (count($this->fields
) +
1) * $this->heightCell
;
137 * @param boolean $showColor Whether to display color
139 * @global object $svg The current SVG image document
144 * @see PMA_SVG,PMA_SVG::printElement
146 public function tableDraw($showColor)
151 'rect', $this->x
, $this->y
, $this->width
,
152 $this->heightCell
, null, 'fill:red;stroke:black;'
155 'text', $this->x +
5, $this->y+
14, $this->width
, $this->heightCell
,
156 $this->getTitle(), 'fill:none;stroke:black;'
158 foreach ($this->fields
as $field) {
159 $this->currentCell +
= $this->heightCell
;
162 if (in_array($field, $this->primary
)) {
165 if ($field == $this->displayfield
) {
170 'rect', $this->x
, $this->y +
$this->currentCell
, $this->width
,
171 $this->heightCell
, null, 'fill:' . $fillColor . ';stroke:black;'
174 'text', $this->x +
5, $this->y +
14 +
$this->currentCell
,
175 $this->width
, $this->heightCell
, $field, 'fill:none;stroke:black;'