2 /* vim: set expandtab sw=4 ts=4 sts=4: */
7 if (! defined('PHPMYADMIN')) {
12 * This class is inherited by all schema classes
13 * It contains those methods which are common in them
14 * it works like factory pattern
16 class PMA_Export_Relation_Schema
21 public $tableDimension;
32 * @param integer $value Page Number of the document to be created
38 public function setPageNumber($value)
40 $this->pageNumber
= isset($value) ?
$value : 1;
46 * @param boolean $value show grid of the document or not
52 public function setShowGrid($value)
54 $this->showGrid
= (isset($value) && $value == 'on') ?
1 : 0;
60 * @param string $value 'on' to set the the variable
64 public function setShowColor($value)
66 $this->showColor
= (isset($value) && $value == 'on') ?
1 : 0;
72 * @param boolean $value show table co-ordinates or not
78 public function setTableDimension($value)
80 $this->tableDimension
= (isset($value) && $value == 'on') ?
1 : 0;
84 * Set same width of All Tables
86 * @param boolean $value set same width of all tables or not
92 public function setAllTablesSameWidth($value)
94 $this->sameWide
= (isset($value) && $value == 'on') ?
1 : 0;
100 * @param boolean $value show selected database data dictionary or not
106 public function setWithDataDictionary($value)
108 $this->withDoc
= (isset($value) && $value == 'on') ?
1 : 0;
114 * @param boolean $value show only keys or not
120 public function setShowKeys($value)
122 $this->showKeys
= (isset($value) && $value == 'on') ?
1 : 0;
128 * @param string $value Orientation will be portrait or landscape
134 public function setOrientation($value)
136 $this->orientation
= (isset($value) && $value == 'P') ?
'P' : 'L';
142 * @param string $value paper type can be A4 etc
148 public function setPaper($value)
150 $this->paper
= isset($value) ?
$value : 'A4';
154 * Set title of the page
156 * @param string $title title of the page displayed at top of the document
162 public function setPageTitle($title)
164 $this->_pageTitle
=$title;
168 * Set type of export relational schema
170 * @param string $value can be pdf,svg,dia,eps etc
176 public function setExportType($value)
178 $this->exportType
=$value;
182 * get all tables involved or included in page
184 * @param string $db name of the database
185 * @param integer $pageNumber page no. whose tables will be fetched in an array
187 * @return Array an array of tables
191 public function getAllTables($db, $pageNumber)
196 $tab_sql = 'SELECT table_name FROM '
197 . PMA_Util
::backquote($GLOBALS['cfgRelation']['db']) . '.'
198 . PMA_Util
::backquote($cfgRelation['table_coords'])
199 . ' WHERE db_name = \'' . PMA_Util
::sqlAddSlashes($db) . '\''
200 . ' AND pdf_page_number = ' . $pageNumber;
202 $tab_rs = PMA_queryAsControlUser($tab_sql, null, PMA_DBI_QUERY_STORE
);
203 if (!$tab_rs ||
!PMA_DBI_num_rows($tab_rs) > 0) {
204 $this->dieSchema('', __('This page does not contain any tables!'));
206 while ($curr_table = @PMA_DBI_fetch_assoc
($tab_rs)) {
207 $alltables[] = PMA_Util
::sqlAddSlashes($curr_table['table_name']);
213 * Displays an error message
215 * @param integer $pageNumber ID of the chosen page
216 * @param string $type Schema Type
217 * @param string $error_message The error mesage
219 * @global array the PMA configuration array
220 * @global string the current database name
226 function dieSchema($pageNumber, $type = '', $error_message = '')
230 echo "<p><strong>" . __("SCHEMA ERROR: ") . $type . "</strong></p>" . "\n";
231 if (!empty($error_message)) {
232 $error_message = htmlspecialchars($error_message);
235 echo ' ' . $error_message . "\n";
237 echo '<a href="schema_edit.php?' . PMA_generate_common_url($db)
238 . '&do=selectpage&chpage=' . $pageNumber . '&action_choose=0'
239 . '">' . __('Back') . '</a>';