2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Contains PMA_Export_Relation_Schema class which is inherited
5 * by all schema classes.
9 if (! defined('PHPMYADMIN')) {
14 * This class is inherited by all schema classes
15 * It contains those methods which are common in them
16 * it works like factory pattern
20 class PMA_Export_Relation_Schema
25 * @param string $db database name
26 * @param object $diagram schema diagram
28 public function __construct($db, $diagram)
31 $this->diagram
= $diagram;
32 $this->setPageNumber($_REQUEST['page_number']);
33 $this->setOffline(isset($_REQUEST['offline_export']));
40 protected $tableDimension;
43 protected $orientation;
46 protected $pageNumber;
52 * @param integer $value Page Number of the document to be created
56 public function setPageNumber($value)
58 $this->pageNumber
= $value;
62 * Returns the schema page number
64 * @return integer schema page number
66 public function getPageNumber()
68 return $this->pageNumber
;
74 * @param boolean $value whether to show colors
78 public function setShowColor($value)
80 $this->showColor
= $value;
84 * Returns whether to show colors
86 * @return boolean whether to show colors
88 public function isShowColor()
90 return $this->showColor
;
96 * @param boolean $value show table co-ordinates or not
100 public function setTableDimension($value)
102 $this->tableDimension
= $value;
106 * Returns whether to show table dimensions
108 * @return boolean whether to show table dimensions
110 public function isTableDimension()
112 return $this->tableDimension
;
116 * Set same width of All Tables
118 * @param boolean $value set same width of all tables or not
122 public function setAllTablesSameWidth($value)
124 $this->sameWide
= $value;
128 * Returns whether to use same width for all tables or not
130 * @return boolean whether to use same width for all tables or not
132 public function isAllTableSameWidth()
134 return $this->sameWide
;
140 * @param boolean $value show only keys or not
146 public function setShowKeys($value)
148 $this->showKeys
= $value;
152 * Returns whether to show keys
154 * @return boolean whether to show keys
156 public function isShowKeys()
158 return $this->showKeys
;
164 * @param string $value Orientation will be portrait or landscape
170 public function setOrientation($value)
172 $this->orientation
= ($value == 'P') ?
'P' : 'L';
176 * Returns orientation
178 * @return string orientation
180 public function getOrientation()
182 return $this->orientation
;
188 * @param string $value paper type can be A4 etc
194 public function setPaper($value)
196 $this->paper
= $value;
200 * Returns the paper size
202 * @return string paper size
204 public function getPaper()
210 * Set whether the document is generated from client side DB
212 * @param boolean $value offline or not
218 public function setOffline($value)
220 $this->offline
= $value;
224 * Returns whether the client side database is used
230 public function isOffline()
232 return $this->offline
;
236 * Get the table names from the request
238 * @return array an array of table names
240 protected function getTablesFromRequest()
243 $dbLength = mb_strlen($this->db
);
244 foreach ($_REQUEST['t_h'] as $key => $value) {
246 $tables[] = mb_substr($key, $dbLength +
1);
253 * Returns the file name
255 * @param String $extension file extension
257 * @return string file name
259 protected function getFileName($extension)
261 $filename = $this->db
. $extension;
262 // Get the name of this page to use as filename
263 if ($this->pageNumber
!= -1 && ! $this->offline
) {
264 $_name_sql = 'SELECT page_descr FROM '
265 . PMA_Util
::backquote($GLOBALS['cfgRelation']['db']) . '.'
266 . PMA_Util
::backquote($GLOBALS['cfgRelation']['pdf_pages'])
267 . ' WHERE page_nr = ' . $this->pageNumber
;
268 $_name_rs = PMA_queryAsControlUser($_name_sql);
269 $_name_row = $GLOBALS['dbi']->fetchRow($_name_rs);
270 $filename = $_name_row[0] . $extension;
277 * Displays an error message
279 * @param integer $pageNumber ID of the chosen page
280 * @param string $type Schema Type
281 * @param string $error_message The error message
287 public static function dieSchema($pageNumber, $type = '', $error_message = '')
289 echo "<p><strong>" . __("SCHEMA ERROR: ") . $type . "</strong></p>" . "\n";
290 if (!empty($error_message)) {
291 $error_message = htmlspecialchars($error_message);
294 echo ' ' . $error_message . "\n";
296 echo '<a href="db_designer.php'
297 . PMA_URL_getCommon(array('db' => $GLOBALS['db']))
298 . '&page=' . htmlspecialchars($pageNumber) . '">' . __('Back') . '</a>';