Export_Relation_Schema.class.php 5.7 KB

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