README 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. /* Get the export interface */
  17. require_once 'libraries/plugins/ExportPlugin.class.php';
  18. /**
  19. * Handles the export for the [Name] format
  20. *
  21. * @package PhpMyAdmin-Export
  22. */
  23. class Export[Name] extends ExportPlugin
  24. {
  25. /**
  26. * optional - declare variables and descriptions
  27. *
  28. * @var type
  29. */
  30. private $_myOptionalVariable;
  31. /**
  32. * optional - declare global variables and descriptions
  33. *
  34. * @var type
  35. */
  36. private $_globalVariableName;
  37. /**
  38. * Constructor
  39. */
  40. public function __construct()
  41. {
  42. $this->setProperties();
  43. }
  44. // optional - declare global variables and use getters later
  45. /**
  46. * Initialize the local variables that are used specific for export SQL
  47. *
  48. * @global type $global_variable_name
  49. * [..]
  50. *
  51. * @return void
  52. */
  53. protected function initSpecificVariables()
  54. {
  55. global $global_variable_name;
  56. $this->_setGlobalVariableName($global_variable_name);
  57. }
  58. /**
  59. * Sets the export plugin properties.
  60. * Called in the constructor.
  61. *
  62. * @return void
  63. */
  64. protected function setProperties()
  65. {
  66. // set properties
  67. $props = 'libraries/properties/';
  68. // include the main class for properties for the export plug-ins
  69. include_once "$props/plugins/ExportPluginProperties.class.php";
  70. // include the group properties classes
  71. include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
  72. include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
  73. // include the needed single property items
  74. include_once "$props/options/items/RadioPropertyItem.class.php";
  75. $exportPluginProperties = new ExportPluginProperties();
  76. $exportPluginProperties->setText('[name]'); // the name of your plug-in
  77. $exportPluginProperties->setExtension('[ext]'); // extension this plug-in can handle
  78. $exportPluginProperties->setOptionsText(__('Options'));
  79. // create the root group that will be the options field for
  80. // $exportPluginProperties
  81. // this will be shown as "Format specific options"
  82. $exportSpecificOptions = new OptionsPropertyRootGroup();
  83. $exportSpecificOptions->setName("Format Specific Options");
  84. // general options main group
  85. $generalOptions = new OptionsPropertyMainGroup();
  86. $generalOptions->setName("general_opts");
  87. // optional :
  88. // create primary items and add them to the group
  89. // type - one of the classes listed in libraries/properties/options/items/
  90. // name - form element name
  91. // text - description in GUI
  92. // size - size of text element
  93. // len - maximal size of input
  94. // values - possible values of the item
  95. $leaf = new RadioPropertyItem();
  96. $leaf->setName("structure_or_data");
  97. $leaf->setValues(
  98. array(
  99. 'structure' => __('structure'),
  100. 'data' => __('data'),
  101. 'structure_and_data' => __('structure and data')
  102. )
  103. );
  104. $generalOptions->addProperty($leaf);
  105. // add the main group to the root group
  106. $exportSpecificOptions->addProperty($generalOptions);
  107. // set the options for the export plugin property item
  108. $exportPluginProperties->setOptions($exportSpecificOptions);
  109. $this->properties = $exportPluginProperties;
  110. }
  111. /**
  112. * This method is called when any PluginManager to which the observer
  113. * is attached calls PluginManager::notify()
  114. *
  115. * @param SplSubject $subject The PluginManager notifying the observer
  116. * of an update.
  117. *
  118. * @return void
  119. */
  120. public function update (SplSubject $subject)
  121. {
  122. }
  123. /**
  124. * Outputs export header
  125. *
  126. * @return bool Whether it succeeded
  127. */
  128. public function exportHeader ()
  129. {
  130. // implementation
  131. return true;
  132. }
  133. /**
  134. * Outputs export footer
  135. *
  136. * @return bool Whether it succeeded
  137. */
  138. public function exportFooter ()
  139. {
  140. // implementation
  141. return true;
  142. }
  143. /**
  144. * Outputs database header
  145. *
  146. * @param string $db Database name
  147. *
  148. * @return bool Whether it succeeded
  149. */
  150. public function exportDBHeader ($db)
  151. {
  152. // implementation
  153. return true;
  154. }
  155. /**
  156. * Outputs database footer
  157. *
  158. * @param string $db Database name
  159. *
  160. * @return bool Whether it succeeded
  161. */
  162. public function exportDBFooter ($db)
  163. {
  164. // implementation
  165. return true;
  166. }
  167. /**
  168. * Outputs CREATE DATABASE statement
  169. *
  170. * @param string $db Database name
  171. *
  172. * @return bool Whether it succeeded
  173. */
  174. public function exportDBCreate($db)
  175. {
  176. // implementation
  177. return true;
  178. }
  179. /**
  180. * Outputs the content of a table in [Name] format
  181. *
  182. * @param string $db database name
  183. * @param string $table table name
  184. * @param string $crlf the end of line sequence
  185. * @param string $error_url the url to go back in case of error
  186. * @param string $sql_query SQL query for obtaining data
  187. *
  188. * @return bool Whether it succeeded
  189. */
  190. public function exportData($db, $table, $crlf, $error_url, $sql_query)
  191. {
  192. // implementation;
  193. return true;
  194. }
  195. // optional - implement other methods defined in ExportPlugin.class.php:
  196. // - exportRoutines()
  197. // - exportStructure()
  198. // - getTableDefStandIn()
  199. // - getTriggers()
  200. // optional - implement other private methods in order to avoid
  201. // having huge methods or avoid duplicate code. Make use of them
  202. // as well as of the getters and setters declared both here
  203. // and in the ExportPlugin class
  204. // optional:
  205. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  206. /**
  207. * Getter description
  208. *
  209. * @return type
  210. */
  211. private function _getMyOptionalVariable()
  212. {
  213. return $this->_myOptionalVariable;
  214. }
  215. /**
  216. * Setter description
  217. *
  218. * @param type $my_optional_variable description
  219. *
  220. * @return void
  221. */
  222. private function _setMyOptionalVariable($my_optional_variable)
  223. {
  224. $this->_myOptionalVariable = $my_optional_variable;
  225. }
  226. /**
  227. * Getter description
  228. *
  229. * @return type
  230. */
  231. private function _getGlobalVariableName()
  232. {
  233. return $this->_globalVariableName;
  234. }
  235. /**
  236. * Setter description
  237. *
  238. * @param type $global_variable_name description
  239. *
  240. * @return void
  241. */
  242. private function _setGlobalVariableName($global_variable_name)
  243. {
  244. $this->_globalVariableName = $global_variable_name;
  245. }
  246. }
  247. ?>