Merge remote-tracking branch 'origin/master' into drizzle
[phpmyadmin.git] / libraries / schema / Export_Relation_Schema.class.php
blobbfdb0636ba7bcec5df2688402e8b45775a8bc0c3
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
9 * This class is inherited by all schema classes
10 * It contains those methods which are common in them
11 * it works like factory pattern
14 class PMA_Export_Relation_Schema
16 private $_pageTitle;
17 public $showGrid;
18 public $showColor;
19 public $tableDimension;
20 public $sameWide;
21 public $withDoc;
22 public $showKeys;
23 public $orientation;
24 public $paper;
25 public $pageNumber;
27 /**
28 * Set Page Number
30 * @param integer value Page Number of the document to be created
31 * @return void
32 * @access public
34 public function setPageNumber($value)
36 $this->pageNumber = isset($value) ? $value : 1;
39 /**
40 * Set Show Grid
42 * @param boolean value show grid of the document or not
43 * @return void
44 * @access public
46 public function setShowGrid($value)
48 $this->showGrid = (isset($value) && $value == 'on') ? 1 : 0;
51 public function setShowColor($value)
53 $this->showColor = (isset($value) && $value == 'on') ? 1 : 0;
56 /**
57 * Set Table Dimension
59 * @param boolean value show table co-ordinates or not
60 * @return void
61 * @access public
63 public function setTableDimension($value)
65 $this->tableDimension = (isset($value) && $value == 'on') ? 1 : 0;
68 /**
69 * Set same width of All Tables
71 * @param boolean value set same width of all tables or not
72 * @return void
73 * @access public
75 public function setAllTableSameWidth($value)
77 $this->sameWide = (isset($value) && $value == 'on') ? 1 : 0;
80 /**
81 * Set Data Dictionary
83 * @param boolean value show selected database data dictionary or not
84 * @return void
85 * @access public
87 public function setWithDataDictionary($value)
89 $this->withDoc = (isset($value) && $value == 'on') ? 1 : 0;
92 /**
93 * Set Show only keys
95 * @param boolean value show only keys or not
96 * @return void
97 * @access public
99 public function setShowKeys($value)
101 $this->showKeys = (isset($value) && $value == 'on') ? 1 : 0;
105 * Set Orientation
107 * @param string value Orientation will be portrait or landscape
108 * @return void
109 * @access public
111 public function setOrientation($value)
113 $this->orientation = (isset($value) && $value == 'P') ? 'P' : 'L';
117 * Set type of paper
119 * @param string value paper type can be A4 etc
120 * @return void
121 * @access public
123 public function setPaper($value)
125 $this->paper = isset($value) ? $value : 'A4';
129 * Set title of the page
131 * @param string value title of the page displayed at top of the document
132 * @return void
133 * @access public
135 public function setPageTitle($title)
137 $this->_pageTitle=$title;
141 * Set type of export relational schema
143 * @param string value can be pdf,svg,dia,visio,eps etc
144 * @return void
145 * @access public
147 public function setExportType($value)
149 $this->exportType=$value;
153 * get all tables involved or included in page
155 * @param string db name of the database
156 * @param integer pageNumber page number whose tables will be fetched in an array
157 * @return Array an array of tables
158 * @access public
160 public function getAllTables($db,$pageNumber)
162 global $cfgRelation;
163 // Get All tables
164 $tab_sql = 'SELECT table_name FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
165 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
166 . ' AND pdf_page_number = ' . $pageNumber;
168 $tab_rs = PMA_query_as_controluser($tab_sql, null, PMA_DBI_QUERY_STORE);
169 if (!$tab_rs || !PMA_DBI_num_rows($tab_rs) > 0) {
170 $this->dieSchema('',__('This page does not contain any tables!'));
172 while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
173 $alltables[] = PMA_sqlAddSlashes($curr_table['table_name']);
175 return $alltables;
179 * Displays an error message
181 * @param integer pageNumber ID of the chosen page
182 * @param string type Schema Type
183 * @param string error_message the error mesage
184 * @global array the PMA configuration array
185 * @global string the current database name
186 * @access public
187 * @return void
189 function dieSchema($pageNumber, $type = '', $error_message = '')
191 global $cfg;
192 global $db;
194 require_once './libraries/header.inc.php';
195 echo "<p><strong>" . __("SCHEMA ERROR: ") . $type ."</strong></p>" . "\n";
196 if (!empty($error_message)) {
197 $error_message = htmlspecialchars($error_message);
199 echo '<p>' . "\n";
200 echo ' ' . $error_message . "\n";
201 echo '</p>' . "\n";
202 echo '<a href="schema_edit.php?' . PMA_generate_common_url($db).'&do=selectpage&chpage='.$pageNumber.'&action_choose=0'
203 . '">' . __('Back') . '</a>';
204 echo "\n";
205 require_once './libraries/footer.inc.php';
206 exit();