Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / schema / Export_Relation_Schema.class.php
blob27a9b40ea84bd64159b8f7a1d176ac197487885b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
7 if (! defined('PHPMYADMIN')) {
8 exit;
11 /**
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
18 private $_pageTitle;
19 public $showGrid;
20 public $showColor;
21 public $tableDimension;
22 public $sameWide;
23 public $withDoc;
24 public $showKeys;
25 public $orientation;
26 public $paper;
27 public $pageNumber;
29 /**
30 * Set Page Number
32 * @param integer $value Page Number of the document to be created
34 * @return void
36 * @access public
38 public function setPageNumber($value)
40 $this->pageNumber = isset($value) ? $value : 1;
43 /**
44 * Set Show Grid
46 * @param boolean $value show grid of the document or not
48 * @return void
50 * @access public
52 public function setShowGrid($value)
54 $this->showGrid = (isset($value) && $value == 'on') ? 1 : 0;
57 /**
58 * Sets showColor
60 * @param string $value 'on' to set the the variable
62 * @return void
64 public function setShowColor($value)
66 $this->showColor = (isset($value) && $value == 'on') ? 1 : 0;
69 /**
70 * Set Table Dimension
72 * @param boolean $value show table co-ordinates or not
74 * @return void
76 * @access public
78 public function setTableDimension($value)
80 $this->tableDimension = (isset($value) && $value == 'on') ? 1 : 0;
83 /**
84 * Set same width of All Tables
86 * @param boolean $value set same width of all tables or not
88 * @return void
90 * @access public
92 public function setAllTablesSameWidth($value)
94 $this->sameWide = (isset($value) && $value == 'on') ? 1 : 0;
97 /**
98 * Set Data Dictionary
100 * @param boolean $value show selected database data dictionary or not
102 * @return void
104 * @access public
106 public function setWithDataDictionary($value)
108 $this->withDoc = (isset($value) && $value == 'on') ? 1 : 0;
112 * Set Show only keys
114 * @param boolean $value show only keys or not
116 * @return void
118 * @access public
120 public function setShowKeys($value)
122 $this->showKeys = (isset($value) && $value == 'on') ? 1 : 0;
126 * Set Orientation
128 * @param string $value Orientation will be portrait or landscape
130 * @return void
132 * @access public
134 public function setOrientation($value)
136 $this->orientation = (isset($value) && $value == 'P') ? 'P' : 'L';
140 * Set type of paper
142 * @param string $value paper type can be A4 etc
144 * @return void
146 * @access public
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
158 * @return void
160 * @access public
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
172 * @return void
174 * @access public
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
189 * @access public
191 public function getAllTables($db, $pageNumber)
193 global $cfgRelation;
195 // Get All tables
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']);
209 return $alltables;
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
222 * @access public
224 * @return void
226 function dieSchema($pageNumber, $type = '', $error_message = '')
228 global $db;
230 echo "<p><strong>" . __("SCHEMA ERROR: ") . $type . "</strong></p>" . "\n";
231 if (!empty($error_message)) {
232 $error_message = htmlspecialchars($error_message);
234 echo '<p>' . "\n";
235 echo ' ' . $error_message . "\n";
236 echo '</p>' . "\n";
237 echo '<a href="schema_edit.php?' . PMA_generate_common_url($db)
238 . '&do=selectpage&chpage=' . $pageNumber . '&action_choose=0'
239 . '">' . __('Back') . '</a>';
240 echo "\n";
241 exit;