Export_Relation_Schema.class.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Contains PMA_Export_Relation_Schema class which is inherited
  5. * by all schema classes.
  6. *
  7. * @package PhpMyAdmin
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /**
  13. * This class is inherited by all schema classes
  14. * It contains those methods which are common in them
  15. * it works like factory pattern
  16. *
  17. * @package PhpMyAdmin
  18. */
  19. class PMA_Export_Relation_Schema
  20. {
  21. private $_pageTitle;
  22. public $showGrid;
  23. public $showColor;
  24. public $tableDimension;
  25. public $sameWide;
  26. public $withDoc;
  27. public $showKeys;
  28. public $orientation;
  29. public $paper;
  30. public $pageNumber;
  31. public $exportType;
  32. /**
  33. * Set Page Number
  34. *
  35. * @param integer $value Page Number of the document to be created
  36. *
  37. * @return void
  38. *
  39. * @access public
  40. */
  41. public function setPageNumber($value)
  42. {
  43. $this->pageNumber = isset($value) ? $value : 1;
  44. }
  45. /**
  46. * Set Show Grid
  47. *
  48. * @param boolean $value show grid of the document or not
  49. *
  50. * @return void
  51. *
  52. * @access public
  53. */
  54. public function setShowGrid($value)
  55. {
  56. $this->showGrid = (isset($value) && $value == 'on') ? 1 : 0;
  57. }
  58. /**
  59. * Sets showColor
  60. *
  61. * @param string $value 'on' to set the the variable
  62. *
  63. * @return void
  64. */
  65. public function setShowColor($value)
  66. {
  67. $this->showColor = (isset($value) && $value == 'on') ? 1 : 0;
  68. }
  69. /**
  70. * Set Table Dimension
  71. *
  72. * @param boolean $value show table co-ordinates or not
  73. *
  74. * @return void
  75. *
  76. * @access public
  77. */
  78. public function setTableDimension($value)
  79. {
  80. $this->tableDimension = (isset($value) && $value == 'on') ? 1 : 0;
  81. }
  82. /**
  83. * Set same width of All Tables
  84. *
  85. * @param boolean $value set same width of all tables or not
  86. *
  87. * @return void
  88. *
  89. * @access public
  90. */
  91. public function setAllTablesSameWidth($value)
  92. {
  93. $this->sameWide = (isset($value) && $value == 'on') ? 1 : 0;
  94. }
  95. /**
  96. * Set Data Dictionary
  97. *
  98. * @param boolean $value show selected database data dictionary or not
  99. *
  100. * @return void
  101. *
  102. * @access public
  103. */
  104. public function setWithDataDictionary($value)
  105. {
  106. $this->withDoc = (isset($value) && $value == 'on') ? 1 : 0;
  107. }
  108. /**
  109. * Set Show only keys
  110. *
  111. * @param boolean $value show only keys or not
  112. *
  113. * @return void
  114. *
  115. * @access public
  116. */
  117. public function setShowKeys($value)
  118. {
  119. $this->showKeys = (isset($value) && $value == 'on') ? 1 : 0;
  120. }
  121. /**
  122. * Set Orientation
  123. *
  124. * @param string $value Orientation will be portrait or landscape
  125. *
  126. * @return void
  127. *
  128. * @access public
  129. */
  130. public function setOrientation($value)
  131. {
  132. $this->orientation = (isset($value) && $value == 'P') ? 'P' : 'L';
  133. }
  134. /**
  135. * Set type of paper
  136. *
  137. * @param string $value paper type can be A4 etc
  138. *
  139. * @return void
  140. *
  141. * @access public
  142. */
  143. public function setPaper($value)
  144. {
  145. $this->paper = isset($value) ? $value : 'A4';
  146. }
  147. /**
  148. * Set title of the page
  149. *
  150. * @param string $title title of the page displayed at top of the document
  151. *
  152. * @return void
  153. *
  154. * @access public
  155. */
  156. public function setPageTitle($title)
  157. {
  158. $this->_pageTitle=$title;
  159. }
  160. /**
  161. * Set type of export relational schema
  162. *
  163. * @param string $value can be pdf,svg,dia,eps etc
  164. *
  165. * @return void
  166. *
  167. * @access public
  168. */
  169. public function setExportType($value)
  170. {
  171. $this->exportType=$value;
  172. }
  173. /**
  174. * get all tables involved or included in page
  175. *
  176. * @param string $db name of the database
  177. * @param integer $pageNumber page no. whose tables will be fetched in an array
  178. *
  179. * @return Array an array of tables
  180. *
  181. * @access public
  182. */
  183. public function getAllTables($db, $pageNumber)
  184. {
  185. global $cfgRelation;
  186. // Get All tables
  187. $tab_sql = 'SELECT table_name FROM '
  188. . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
  189. . PMA_Util::backquote($cfgRelation['table_coords'])
  190. . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
  191. . ' AND pdf_page_number = ' . $pageNumber;
  192. $tab_rs = PMA_queryAsControlUser(
  193. $tab_sql, null, PMA_DatabaseInterface::QUERY_STORE
  194. );
  195. if (! $tab_rs || ! $GLOBALS['dbi']->numRows($tab_rs) > 0) {
  196. $this->dieSchema('', __('This page does not contain any tables!'));
  197. }
  198. //Fix undefined error
  199. $alltables = array();
  200. while ($curr_table = @$GLOBALS['dbi']->fetchAssoc($tab_rs)) {
  201. $alltables[] = PMA_Util::sqlAddSlashes($curr_table['table_name']);
  202. }
  203. return $alltables;
  204. }
  205. /**
  206. * Displays an error message
  207. *
  208. * @param integer $pageNumber ID of the chosen page
  209. * @param string $type Schema Type
  210. * @param string $error_message The error mesage
  211. *
  212. * @global array the PMA configuration array
  213. * @global string $db the current database name
  214. *
  215. * @access public
  216. *
  217. * @return void
  218. */
  219. function dieSchema($pageNumber, $type = '', $error_message = '')
  220. {
  221. global $db;
  222. echo "<p><strong>" . __("SCHEMA ERROR: ") . $type . "</strong></p>" . "\n";
  223. if (!empty($error_message)) {
  224. $error_message = htmlspecialchars($error_message);
  225. }
  226. echo '<p>' . "\n";
  227. echo ' ' . $error_message . "\n";
  228. echo '</p>' . "\n";
  229. echo '<a href="schema_edit.php?' . PMA_URL_getCommon($db)
  230. . '&do=selectpage&chpage=' . htmlspecialchars($pageNumber)
  231. . '&action_choose=0'
  232. . '">' . __('Back') . '</a>';
  233. echo "\n";
  234. exit;
  235. }
  236. }
  237. ?>