ExportPlugin.class.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the export plugins
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /* This class extends the PluginObserver class */
  12. require_once 'PluginObserver.class.php';
  13. /**
  14. * Provides a common interface that will have to be implemented by all of the
  15. * export plugins. Some of the plugins will also implement other public
  16. * methods, but those are not declared here, because they are not implemented
  17. * by all export plugins.
  18. *
  19. * @package PhpMyAdmin
  20. */
  21. abstract class ExportPlugin extends PluginObserver
  22. {
  23. /**
  24. * Array containing the specific export plugin type properties
  25. *
  26. * @var array
  27. */
  28. protected $properties;
  29. /**
  30. * Common methods, must be overwritten by all export plugins
  31. */
  32. /**
  33. * Outputs export header
  34. *
  35. * @return bool Whether it succeeded
  36. */
  37. abstract public function exportHeader ();
  38. /**
  39. * Outputs export footer
  40. *
  41. * @return bool Whether it succeeded
  42. */
  43. abstract public function exportFooter ();
  44. /**
  45. * Outputs database header
  46. *
  47. * @param string $db Database name
  48. *
  49. * @return bool Whether it succeeded
  50. */
  51. abstract public function exportDBHeader ($db);
  52. /**
  53. * Outputs database footer
  54. *
  55. * @param string $db Database name
  56. *
  57. * @return bool Whether it succeeded
  58. */
  59. abstract public function exportDBFooter ($db);
  60. /**
  61. * Outputs CREATE DATABASE statement
  62. *
  63. * @param string $db Database name
  64. *
  65. * @return bool Whether it succeeded
  66. */
  67. abstract public function exportDBCreate($db);
  68. /**
  69. * Outputs the content of a table
  70. *
  71. * @param string $db database name
  72. * @param string $table table name
  73. * @param string $crlf the end of line sequence
  74. * @param string $error_url the url to go back in case of error
  75. * @param string $sql_query SQL query for obtaining data
  76. *
  77. * @return bool Whether it succeeded
  78. */
  79. abstract public function exportData ($db, $table, $crlf, $error_url, $sql_query);
  80. /**
  81. * The following methods are used in export.php or in db_operations.php,
  82. * but they are not implemented by all export plugins
  83. */
  84. /**
  85. * Exports routines (procedures and functions)
  86. *
  87. * @param string $db Database
  88. *
  89. * @return bool Whether it succeeded
  90. */
  91. public function exportRoutines($db)
  92. {
  93. ;
  94. }
  95. /**
  96. * Outputs table's structure
  97. *
  98. * @param string $db database name
  99. * @param string $table table name
  100. * @param string $crlf the end of line sequence
  101. * @param string $error_url the url to go back in case of error
  102. * @param string $export_mode 'create_table','triggers','create_view',
  103. * 'stand_in'
  104. * @param string $export_type 'server', 'database', 'table'
  105. * @param bool $relation whether to include relation comments
  106. * @param bool $comments whether to include the pmadb-style column comments
  107. * as comments in the structure; this is deprecated
  108. * but the parameter is left here because export.php
  109. * calls exportStructure() also for other export
  110. * types which use this parameter
  111. * @param bool $mime whether to include mime comments
  112. * @param bool $dates whether to include creation/update/check dates
  113. *
  114. * @return bool Whether it succeeded
  115. */
  116. public function exportStructure(
  117. $db,
  118. $table,
  119. $crlf,
  120. $error_url,
  121. $export_mode,
  122. $export_type,
  123. $relation = false,
  124. $comments = false,
  125. $mime = false,
  126. $dates = false
  127. ) {
  128. ;
  129. }
  130. /**
  131. * Returns a stand-in CREATE definition to resolve view dependencies
  132. *
  133. * @param string $db the database name
  134. * @param string $view the view name
  135. * @param string $crlf the end of line sequence
  136. *
  137. * @return string resulting definition
  138. */
  139. public function getTableDefStandIn($db, $view, $crlf)
  140. {
  141. ;
  142. }
  143. /**
  144. * Outputs triggers
  145. *
  146. * @param string $db database name
  147. * @param string $table table name
  148. *
  149. * @return string Formatted triggers list
  150. */
  151. protected function getTriggers($db, $table)
  152. {
  153. ;
  154. }
  155. /**
  156. * Initialize the specific variables for each export plugin
  157. *
  158. * @return void
  159. */
  160. protected function initSpecificVariables()
  161. {
  162. ;
  163. }
  164. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  165. /**
  166. * Gets the export specific format plugin properties
  167. *
  168. * @return array
  169. */
  170. public function getProperties()
  171. {
  172. return $this->properties;
  173. }
  174. /**
  175. * Sets the export plugins properties and is implemented by each export
  176. * plugin
  177. *
  178. * @return void
  179. */
  180. abstract protected function setProperties();
  181. }
  182. ?>