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.
7 /* vim: set expandtab sw=4 ts=4 sts=4: */
9 * [Name] export plugin for phpMyAdmin
11 * @package PhpMyAdmin-Export
14 if (! defined('PHPMYADMIN')) {
18 /* Get the export interface */
19 require_once 'libraries/plugins/ExportPlugin.class.php';
22 * Handles the export for the [Name] format
24 * @package PhpMyAdmin-Export
26 class Export[Name] extends ExportPlugin
29 * optional - declare variables and descriptions
33 private $_myOptionalVariable;
36 * optional - declare global variables and descriptions
40 private $_globalVariableName;
45 public function __construct()
47 $this->setProperties();
50 // optional - declare global variables and use getters later
52 * Initialize the local variables that are used specific for export SQL
54 * @global type $global_variable_name
59 protected function initSpecificVariables()
61 global $global_variable_name;
62 $this->_setGlobalVariableName($global_variable_name);
66 * Sets the export plugin properties.
67 * Called in the constructor.
71 protected function setProperties()
74 $props = 'libraries/properties/';
75 // include the main class for properties for the export plug-ins
76 include_once "$props/plugins/ExportPluginProperties.class.php";
77 // include the group properties classes
78 include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
79 include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
80 // include the needed single property items
81 include_once "$props/options/items/RadioPropertyItem.class.php";
83 $exportPluginProperties = new ExportPluginProperties();
84 $exportPluginProperties->setText('[name]'); // the name of your plug-in
85 $exportPluginProperties->setExtension('[ext]'); // extension this plug-in can handle
86 $exportPluginProperties->setOptionsText(__('Options'));
88 // create the root group that will be the options field for
89 // $exportPluginProperties
90 // this will be shown as "Format specific options"
91 $exportSpecificOptions = new OptionsPropertyRootGroup();
92 $exportSpecificOptions->setName("Format Specific Options");
94 // general options main group
95 $generalOptions = new OptionsPropertyMainGroup();
96 $generalOptions->setName("general_opts");
99 // create primary items and add them to the group
100 // type - one of the classes listed in libraries/properties/options/items/
101 // name - form element name
102 // text - description in GUI
103 // size - size of text element
104 // len - maximal size of input
105 // values - possible values of the item
106 $leaf = new RadioPropertyItem();
107 $leaf->setName("structure_or_data");
110 'structure' => __('structure'),
111 'data' => __('data'),
112 'structure_and_data' => __('structure and data')
115 $generalOptions->addProperty($leaf);
117 // add the main group to the root group
118 $exportSpecificOptions->addProperty($generalOptions);
120 // set the options for the export plugin property item
121 $exportPluginProperties->setOptions($exportSpecificOptions);
122 $this->properties = $exportPluginProperties;
126 * This method is called when any PluginManager to which the observer
127 * is attached calls PluginManager::notify()
129 * @param SplSubject $subject The PluginManager notifying the observer
134 public function update (SplSubject $subject)
139 * Outputs export header
141 * @return bool Whether it succeeded
143 public function exportHeader ()
150 * Outputs export footer
152 * @return bool Whether it succeeded
154 public function exportFooter ()
161 * Outputs database header
163 * @param string $db Database name
165 * @return bool Whether it succeeded
167 public function exportDBHeader ($db)
174 * Outputs database footer
176 * @param string $db Database name
178 * @return bool Whether it succeeded
180 public function exportDBFooter ($db)
187 * Outputs CREATE DATABASE statement
189 * @param string $db Database name
191 * @return bool Whether it succeeded
193 public function exportDBCreate($db)
200 * Outputs the content of a table in [Name] format
202 * @param string $db database name
203 * @param string $table table name
204 * @param string $crlf the end of line sequence
205 * @param string $error_url the url to go back in case of error
206 * @param string $sql_query SQL query for obtaining data
208 * @return bool Whether it succeeded
210 public function exportData($db, $table, $crlf, $error_url, $sql_query)
216 // optional - implement other methods defined in ExportPlugin.class.php:
217 // - exportRoutines()
218 // - exportStructure()
219 // - getTableDefStandIn()
222 // optional - implement other private methods in order to avoid
223 // having huge methods or avoid duplicate code. Make use of them
224 // as well as of the getters and setters declared both here
225 // and in the ExportPlugin class
229 /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
237 private function _getMyOptionalVariable()
239 return $this->_myOptionalVariable;
245 * @param type $my_optional_variable description
249 private function _setMyOptionalVariable($my_optional_variable)
251 $this->_myOptionalVariable = $my_optional_variable;
259 private function _getGlobalVariableName()
261 return $this->_globalVariableName;
267 * @param type $global_variable_name description
271 private function _setGlobalVariableName($global_variable_name)
273 $this->_globalVariableName = $global_variable_name;