ExportPlugin.class.php 5.1 KB

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