README 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. This directory holds export plugins for phpMyAdmin. Any new plugin should
  2. basically follow the structure presented here. Official plugins need to
  3. have str* messages with their definition in language files, but if you build
  4. some plugins for your use, you can directly use texts in plugin.
  5. <?php
  6. /* vim: set expandtab sw=4 ts=4 sts=4: */
  7. /**
  8. * [Name] export plugin for phpMyAdmin
  9. *
  10. * @package PhpMyAdmin-Export
  11. * @subpackage [Name]
  12. */
  13. if (! defined('PHPMYADMIN')) {
  14. exit;
  15. }
  16. /**
  17. * Handles the export for the [Name] format
  18. *
  19. * @package PhpMyAdmin-Export
  20. */
  21. class Export[Name] extends PhpMyAdmin\Plugins\ExportPlugin
  22. {
  23. /**
  24. * optional - declare variables and descriptions
  25. *
  26. * @var type
  27. */
  28. private $_myOptionalVariable;
  29. /**
  30. * optional - declare global variables and descriptions
  31. *
  32. * @var type
  33. */
  34. private $_globalVariableName;
  35. /**
  36. * Constructor
  37. */
  38. public function __construct()
  39. {
  40. $this->setProperties();
  41. }
  42. // optional - declare global variables and use getters later
  43. /**
  44. * Initialize the local variables that are used specific for export SQL
  45. *
  46. * @global type $global_variable_name
  47. * [..]
  48. *
  49. * @return void
  50. */
  51. protected function initSpecificVariables()
  52. {
  53. global $global_variable_name;
  54. $this->_setGlobalVariableName($global_variable_name);
  55. }
  56. /**
  57. * Sets the export plugin properties.
  58. * Called in the constructor.
  59. *
  60. * @return void
  61. */
  62. protected function setProperties()
  63. {
  64. $exportPluginProperties = new PhpMyAdmin\Properties\Plugins\ExportPluginProperties();
  65. $exportPluginProperties->setText('[name]'); // the name of your plug-in
  66. $exportPluginProperties->setExtension('[ext]'); // extension this plug-in can handle
  67. $exportPluginProperties->setOptionsText(__('Options'));
  68. // create the root group that will be the options field for
  69. // $exportPluginProperties
  70. // this will be shown as "Format specific options"
  71. $exportSpecificOptions = new PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup(
  72. "Format Specific Options"
  73. );
  74. // general options main group
  75. $generalOptions = new PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup(
  76. "general_opts"
  77. );
  78. // optional :
  79. // create primary items and add them to the group
  80. // type - one of the classes listed in libraries/properties/options/items/
  81. // name - form element name
  82. // text - description in GUI
  83. // size - size of text element
  84. // len - maximal size of input
  85. // values - possible values of the item
  86. $leaf = new PhpMyAdmin\Properties\Options\Items\RadioPropertyItem(
  87. "structure_or_data"
  88. );
  89. $leaf->setValues(
  90. array(
  91. 'structure' => __('structure'),
  92. 'data' => __('data'),
  93. 'structure_and_data' => __('structure and data')
  94. )
  95. );
  96. $generalOptions->addProperty($leaf);
  97. // add the main group to the root group
  98. $exportSpecificOptions->addProperty($generalOptions);
  99. // set the options for the export plugin property item
  100. $exportPluginProperties->setOptions($exportSpecificOptions);
  101. $this->properties = $exportPluginProperties;
  102. }
  103. /**
  104. * Outputs export header
  105. *
  106. * @return bool Whether it succeeded
  107. */
  108. public function exportHeader ()
  109. {
  110. // implementation
  111. return true;
  112. }
  113. /**
  114. * Outputs export footer
  115. *
  116. * @return bool Whether it succeeded
  117. */
  118. public function exportFooter ()
  119. {
  120. // implementation
  121. return true;
  122. }
  123. /**
  124. * Outputs database header
  125. *
  126. * @param string $db Database name
  127. * @param string $db_alias Aliases of db
  128. *
  129. * @return bool Whether it succeeded
  130. */
  131. public function exportDBHeader ($db, $db_alias = '')
  132. {
  133. // implementation
  134. return true;
  135. }
  136. /**
  137. * Outputs database footer
  138. *
  139. * @param string $db Database name
  140. *
  141. * @return bool Whether it succeeded
  142. */
  143. public function exportDBFooter ($db)
  144. {
  145. // implementation
  146. return true;
  147. }
  148. /**
  149. * Outputs CREATE DATABASE statement
  150. *
  151. * @param string $db Database name
  152. * @param string $db_alias Aliases of db
  153. *
  154. * @return bool Whether it succeeded
  155. */
  156. public function exportDBCreate($db, $db_alias = '')
  157. {
  158. // implementation
  159. return true;
  160. }
  161. /**
  162. * Outputs the content of a table in [Name] format
  163. *
  164. * @param string $db database name
  165. * @param string $table table name
  166. * @param string $crlf the end of line sequence
  167. * @param string $error_url the url to go back in case of error
  168. * @param string $sql_query SQL query for obtaining data
  169. * @param array $aliases Aliases of db/table/columns
  170. *
  171. * @return bool Whether it succeeded
  172. */
  173. public function exportData(
  174. $db, $table, $crlf, $error_url, $sql_query, $aliases = array()
  175. ) {
  176. // implementation;
  177. return true;
  178. }
  179. // optional - implement other methods defined in PhpMyAdmin\Plugins\ExportPlugin.class.php:
  180. // - exportRoutines()
  181. // - exportStructure()
  182. // - getTableDefStandIn()
  183. // - getTriggers()
  184. // optional - implement other private methods in order to avoid
  185. // having huge methods or avoid duplicate code. Make use of them
  186. // as well as of the getters and setters declared both here
  187. // and in the PhpMyAdmin\Plugins\ExportPlugin class
  188. // optional:
  189. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  190. /**
  191. * Getter description
  192. *
  193. * @return type
  194. */
  195. private function _getMyOptionalVariable()
  196. {
  197. return $this->_myOptionalVariable;
  198. }
  199. /**
  200. * Setter description
  201. *
  202. * @param type $my_optional_variable description
  203. *
  204. * @return void
  205. */
  206. private function _setMyOptionalVariable($my_optional_variable)
  207. {
  208. $this->_myOptionalVariable = $my_optional_variable;
  209. }
  210. /**
  211. * Getter description
  212. *
  213. * @return type
  214. */
  215. private function _getGlobalVariableName()
  216. {
  217. return $this->_globalVariableName;
  218. }
  219. /**
  220. * Setter description
  221. *
  222. * @param type $global_variable_name description
  223. *
  224. * @return void
  225. */
  226. private function _setGlobalVariableName($global_variable_name)
  227. {
  228. $this->_globalVariableName = $global_variable_name;
  229. }
  230. }
  231. ?>