UPDATE 4.4.0.0
[phpmyadmin.git] / libraries / plugins / schema / eps / TableStatsEps.class.php
blob7114410b65963e82d9718636e9e8e109ed644c84
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Contains Table_Stats_Eps class
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 require_once 'libraries/plugins/schema/TableStats.class.php';
14 /**
15 * Table preferences/statistics
17 * This class preserves the table co-ordinates,fields
18 * and helps in drawing/generating the Tables in EPS.
20 * @package PhpMyAdmin
21 * @name Table_Stats_Eps
22 * @see PMA_EPS
24 class Table_Stats_Eps extends TableStats
26 /**
27 * Defines properties
29 public $height;
30 public $currentCell = 0;
32 /**
33 * The "Table_Stats_Eps" constructor
35 * @param string $tableName The table name
36 * @param string $font The font name
37 * @param integer $fontSize The font size
38 * @param integer $pageNumber Page number
39 * @param integer &$same_wide_width The max width 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
43 * from the browser
45 * @global object $eps The current eps document
47 * @access private
48 * @see PMA_EPS, Table_Stats_Eps::Table_Stats_setWidth,
49 * Table_Stats_Eps::Table_Stats_setHeight
51 function __construct(
52 $tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
53 $showKeys = false, $tableDimension = false, $offline = false
54 ) {
55 global $eps;
56 parent::__construct(
57 $eps, $GLOBALS['db'], $pageNumber, $tableName,
58 $showKeys, $tableDimension, $offline
61 // height and width
62 $this->_setHeightTable($fontSize);
63 // setWidth must me after setHeight, because title
64 // can include table height which changes table width
65 $this->_setWidthTable($font, $fontSize);
66 if ($same_wide_width < $this->width) {
67 $same_wide_width = $this->width;
71 /**
72 * Displays an error when the table cannot be found.
74 * @return void
76 protected function showMissingTableError()
78 PMA_Export_Relation_Schema::dieSchema(
79 $this->pageNumber,
80 "EPS",
81 sprintf(__('The %s table doesn\'t exist!'), $this->tableName)
85 /**
86 * Sets the width of the table
88 * @param string $font The font name
89 * @param integer $fontSize The font size
91 * @return void
93 * @access private
94 * @see PMA_EPS
96 private function _setWidthTable($font,$fontSize)
98 foreach ($this->fields as $field) {
99 $this->width = max(
100 $this->width,
101 PMA_Font::getStringWidth($field, $font, $fontSize)
104 $this->width += PMA_Font::getStringWidth(' ', $font, $fontSize);
106 * it is unknown what value must be added, because
107 * table title is affected by the table width value
109 while ($this->width
110 < PMA_Font::getStringWidth($this->getTitle(), $font, $fontSize)) {
111 $this->width += 7;
116 * Sets the height of the table
118 * @param integer $fontSize The font size
120 * @return void
121 * @access private
123 private function _setHeightTable($fontSize)
125 $this->heightCell = $fontSize + 4;
126 $this->height = (count($this->fields) + 1) * $this->heightCell;
130 * Draw the table
132 * @param boolean $showColor Whether to display color
134 * @global object $eps The current eps document
136 * @return void
138 * @access public
139 * @see PMA_EPS,PMA_EPS::line,PMA_EPS::rect
141 public function tableDraw($showColor)
143 global $eps;
144 //echo $this->tableName.'<br />';
145 $eps->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1);
146 $eps->showXY($this->getTitle(), $this->x + 5, $this->y + 14);
147 foreach ($this->fields as $field) {
148 $this->currentCell += $this->heightCell;
149 $eps->rect(
150 $this->x, $this->y + 12 + $this->currentCell,
151 $this->width, $this->heightCell, 1
153 $eps->showXY($field, $this->x + 5, $this->y + 14 + $this->currentCell);