2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 if (! defined('PHPMYADMIN')) {
12 // Get relations & co. status
13 $cfgRelation = PMA_getRelationsParam();
15 if (isset($_REQUEST['single_table'])) {
16 $GLOBALS['single_table'] = $_REQUEST['single_table'];
19 require_once './libraries/file_listing.lib.php';
20 require_once './libraries/plugin_interface.lib.php';
23 * Outputs appropriate checked statement for checkbox.
25 * @param string $str option name
29 function PMA_exportCheckboxCheck($str)
31 if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
32 return ' checked="checked"';
36 /* Scan for plugins */
37 $export_list = PMA_getPlugins(
39 'libraries/plugins/export/',
41 'export_type' => $export_type,
42 'single_table' => isset($single_table)
46 /* Fail if we didn't find any plugin */
47 if (empty($export_list)) {
49 __('Could not load export plugins, please check your installation!')
55 $html .= '<form method="post" action="export.php" '
56 . ' name="dump" class="disableAjax">';
58 if ($export_type == 'server') {
59 $html .= PMA_generate_common_hidden_inputs('', '', 1);
60 } elseif ($export_type == 'database') {
61 $html .= PMA_generate_common_hidden_inputs($db, '', 1);
63 $html .= PMA_generate_common_hidden_inputs($db, $table, 1);
66 // just to keep this value for possible next display of this form after saving
68 if (isset($single_table)) {
69 $html .= '<input type="hidden" name="single_table" value="TRUE" />'
73 $html .= '<input type="hidden" name="export_type" value="'
74 . $export_type . '" />';
77 // If the export method was not set, the default is quick
78 if (isset($_GET['export_method'])) {
79 $cfg['Export']['method'] = $_GET['export_method'];
80 } elseif (! isset($cfg['Export']['method'])) {
81 $cfg['Export']['method'] = 'quick';
83 // The export method (quick, custom or custom-no-form)
84 $html .= '<input type="hidden" name="export_method" value="'
85 . htmlspecialchars($cfg['Export']['method']) . '" />';
88 if (isset($_GET['sql_query'])) {
89 $html .= '<input type="hidden" name="sql_query" value="'
90 . htmlspecialchars($_GET['sql_query']) . '" />' . "\n";
91 } elseif (! empty($sql_query)) {
92 $html .= '<input type="hidden" name="sql_query" value="'
93 . htmlspecialchars($sql_query) . '" />' . "\n";
96 $html .= '<div class="exportoptions" id="header">';
98 $html .= PMA_Util
::getImage('b_export.png', __('Export'));
99 if ($export_type == 'server') {
100 $html .= __('Exporting databases from the current server');
101 } elseif ($export_type == 'database') {
103 __('Exporting tables from "%s" database'),
104 htmlspecialchars($db)
108 __('Exporting rows from "%s" table'),
109 htmlspecialchars($table)
115 if (isset($_GET['quick_or_custom'])) {
116 $export_method = $_GET['quick_or_custom'];
118 $export_method = $cfg['Export']['method'];
121 $html .= '<div class="exportoptions" id="quick_or_custom">';
122 $html .= '<h3>' . __('Export Method:') . '</h3>';
125 $html .= '<input type="radio" name="quick_or_custom" value="quick" '
126 . ' id="radio_quick_export"';
127 if ($export_method == 'quick' ||
$export_method == 'quick_no_form') {
128 $html .= ' checked="checked"';
131 $html .= '<label for ="radio_quick_export">';
132 $html .= __('Quick - display only the minimal options');
137 $html .= '<input type="radio" name="quick_or_custom" value="custom" '
138 . ' id="radio_custom_export"';
139 if ($export_method == 'custom' ||
$export_method == 'custom_no_form') {
140 $html .= ' checked="checked"';
143 $html .= '<label for="radio_custom_export">';
144 $html .= __('Custom - display all possible options');
151 $html .= '<div class="exportoptions" id="databases_and_tables">';
152 if ($export_type == 'server') {
153 $html .= '<h3>' . __('Database(s):') . '</h3>';
154 } else if ($export_type == 'database') {
155 $html .= '<h3>' . __('Table(s):') . '</h3>';
157 if (! empty($multi_values)) {
158 $html .= $multi_values;
162 if (strlen($table) && ! isset($num_tables) && ! PMA_Table
::isMerge($db, $table)) {
163 $html .= '<div class="exportoptions" id="rows">';
164 $html .= '<h3>' . __('Rows:') . '</h3>';
167 $html .= '<input type="radio" name="allrows" value="0" id="radio_allrows_0"';
168 if (isset($_GET['allrows']) && $_GET['allrows'] == 0) {
169 $html .= ' checked="checked"';
172 $html .= '<label for ="radio_allrows_0">' . __('Dump some row(s)') . '</label>';
175 $html .= '<label for="limit_to">' . __('Number of rows:') . '</label>';
176 $html .= '<input type="text" id="limit_to" name="limit_to" size="5" value="';
177 if (isset($_GET['limit_to'])) {
178 $html .= htmlspecialchars($_GET['limit_to']);
179 } elseif (isset($unlim_num_rows)) {
180 $html .= $unlim_num_rows;
182 $html .= PMA_Table
::countRecords($db, $table);
184 $html .= '" onfocus="this.select()" />';
187 $html .= '<label for="limit_from">' . __('Row to begin at:') . '</label>';
188 $html .= '<input type="text" id="limit_from" name="limit_from" value="';
189 if (isset($_GET['limit_from'])) {
190 $html .= htmlspecialchars($_GET['limit_from']);
194 $html .= '" size="5" onfocus="this.select()" />';
199 $html .= '<input type="radio" name="allrows" value="1" id="radio_allrows_1"';
200 if (! isset($_GET['allrows']) ||
$_GET['allrows'] == 1) {
201 $html .= ' checked="checked"';
204 $html .= ' <label for="radio_allrows_1">' . __('Dump all rows') . '</label>';
210 if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
211 $html .= '<div class="exportoptions" id="output_quick_export">';
212 $html .= '<h3>' . __('Output:') . '</h3>';
215 $html .= '<input type="checkbox" name="quick_export_onserver" value="saveit" ';
216 $html .= 'id="checkbox_quick_dump_onserver" ';
217 $html .= PMA_exportCheckboxCheck('quick_export_onserver');
219 $html .= '<label for="checkbox_quick_dump_onserver">';
221 __('Save on server in the directory <b>%s</b>'),
222 htmlspecialchars(PMA_Util
::userDir($cfg['SaveDir']))
227 $html .= '<input type="checkbox" name="quick_export_onserverover" ';
228 $html .= 'value="saveitover" id="checkbox_quick_dump_onserverover" ';
229 $html .= PMA_exportCheckboxCheck('quick_export_onserver_overwrite');
231 $html .= '<label for="checkbox_quick_dump_onserverover">';
232 $html .= __('Overwrite existing file(s)');
239 $html .= '<div class="exportoptions" id="output">';
240 $html .= '<h3>' . __('Output:') . '</h3>';
241 $html .= '<ul id="ul_output">';
243 $html .= '<input type="radio" name="output_format" value="sendit" ';
244 $html .= 'id="radio_dump_asfile" ';
245 if (!isset($_GET['repopulate'])) {
246 $html .= PMA_exportCheckboxCheck('asfile');
249 $html .= '<label for="radio_dump_asfile">'
250 . __('Save output to a file') . '</label>';
251 $html .= '<ul id="ul_save_asfile">';
252 if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
254 $html .= '<input type="checkbox" name="onserver" value="saveit" ';
255 $html .= 'id="checkbox_dump_onserver" ';
256 $html .= PMA_exportCheckboxCheck('onserver');
258 $html .= '<label for="checkbox_dump_onserver">';
260 __('Save on server in the directory <b>%s</b>'),
261 htmlspecialchars(PMA_Util
::userDir($cfg['SaveDir']))
266 $html .= '<input type="checkbox" name="onserverover" value="saveitover"';
267 $html .= ' id="checkbox_dump_onserverover" ';
268 $html .= PMA_exportCheckboxCheck('onserver_overwrite');
270 $html .= '<label for="checkbox_dump_onserverover">';
271 $html .= __('Overwrite existing file(s)');
276 $html .= '<label for="filename_template" class="desc">';
277 $html .= __('File name template:');
278 $trans = new PMA_Message
;
279 $trans->addMessage(__('@SERVER@ will become the server name'));
280 if ($export_type == 'database' ||
$export_type == 'table') {
281 $trans->addMessage(__(', @DATABASE@ will become the database name'));
282 if ($export_type == 'table') {
283 $trans->addMessage(__(', @TABLE@ will become the table name'));
287 $msg = new PMA_Message(
288 __('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.')
291 '<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php'))
292 . '" target="documentation" title="' . __('Documentation') . '">',
295 $msg->addParam('</a>', false);
296 $msg->addParam($trans);
297 $doc_url = PMA_Util
::getDocuLink('faq', 'faq6-27');
299 '<a href="'. $doc_url . '" target="documentation">',
302 $msg->addParam('</a>', false);
304 $html .= PMA_Util
::showHint($msg);
306 $html .= '<input type="text" name="filename_template" id="filename_template" ';
308 if (isset($_GET['filename_template'])) {
309 $html .= htmlspecialchars($_GET['filename_template']);
311 if ($export_type == 'database') {
312 $html .= htmlspecialchars(
313 $GLOBALS['PMA_Config']->getUserValue(
314 'pma_db_filename_template',
315 $GLOBALS['cfg']['Export']['file_template_database']
318 } elseif ($export_type == 'table') {
319 $html .= htmlspecialchars(
320 $GLOBALS['PMA_Config']->getUserValue(
321 'pma_table_filename_template',
322 $GLOBALS['cfg']['Export']['file_template_table']
326 $html .= htmlspecialchars(
327 $GLOBALS['PMA_Config']->getUserValue(
328 'pma_server_filename_template',
329 $GLOBALS['cfg']['Export']['file_template_server']
336 $html .= '<input type="checkbox" name="remember_template" ';
337 $html .= 'id="checkbox_remember_template" ';
338 $html .= PMA_exportCheckboxCheck('remember_file_template');
340 $html .= '<label for="checkbox_remember_template">';
341 $html .= __('use this for future exports');
345 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
) {
346 $html .= ' <li><label for="select_charset_of_file" class="desc">'
347 . __('Character set of the file:') . '</label>' . "\n";
348 reset($cfg['AvailableCharsets']);
349 $html .= '<select id="select_charset_of_file" name="charset_of_file" size="1">';
350 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
351 $html .= '<option value="' . $temp_charset . '"';
352 if (isset($_GET['charset_of_file'])
353 && ($_GET['charset_of_file'] != $temp_charset)
356 } elseif ((empty($cfg['Export']['charset']) && $temp_charset == 'utf-8')
357 ||
$temp_charset == $cfg['Export']['charset']
359 $html .= ' selected="selected"';
361 $html .= '>' . $temp_charset . '</option>';
363 $html .= '</select></li>';
366 if (isset($_GET['compression'])) {
367 $selected_compression = $_GET['compression'];
368 } elseif (isset($cfg['Export']['compression'])) {
369 $selected_compression = $cfg['Export']['compression'];
371 $selected_compression = "none";
374 // zip, gzip and bzip2 encode features
375 $is_zip = ($cfg['ZipDump'] && @function_exists
('gzcompress'));
376 $is_gzip = ($cfg['GZipDump'] && @function_exists
('gzencode'));
377 $is_bzip2 = ($cfg['BZipDump'] && @function_exists
('bzcompress'));
378 if ($is_zip ||
$is_gzip ||
$is_bzip2) {
380 $html .= '<label for="compression" class="desc">'
381 . __('Compression:') . '</label>';
382 $html .= '<select id="compression" name="compression">';
383 $html .= '<option value="none">' . __('None') . '</option>';
385 $html .= '<option value="zip" ';
386 if ($selected_compression == "zip") {
387 $html .= 'selected="selected"';
389 $html .= '>' . __('zipped') . '</option>';
392 $html .= '<option value="gzip" ';
393 if ($selected_compression == "gzip") {
394 $html .= 'selected="selected"';
396 $html .= '>' . __('gzipped') . '</option>';
399 $html .= '<option value="bzip2" ';
400 if ($selected_compression == "bzip2") {
401 $html .= 'selected="selected"';
403 $html .= '>' . __('bzipped') . '</option>';
405 $html .= '</select>';
408 $html .= '<input type="hidden" name="compression" value="'
409 . htmlspecialchars($selected_compression) . '" />';
414 $html .= '<input type="radio" id="radio_view_as_text" '
415 . ' name="output_format" value="astext" ';
416 if (isset($_GET['repopulate']) ||
$GLOBALS['cfg']['Export']['asfile'] == false) {
417 $html .= 'checked="checked"';
420 $html .= '<label for="radio_view_as_text">'
421 . __('View output as text') . '</label></li>';
425 $html .= '<div class="exportoptions" id="format">';
426 $html .= '<h3>' . __('Format:') . '</h3>';
427 $html .= PMA_pluginGetChoice('Export', 'what', $export_list, 'format');
430 $html .= '<div class="exportoptions" id="format_specific_opts">';
431 $html .= '<h3>' . __('Format-specific options:') . '</h3>';
432 $html .= '<p class="no_js_msg" id="scroll_to_options_msg">';
433 $html .= __('Scroll down to fill in the options for the selected format and ignore the options for other formats.');
435 $html .= PMA_pluginGetOptions('Export', $export_list);
438 if (function_exists('PMA_Kanji_encodingForm')) {
439 // Encoding setting form appended by Y.Kawada
440 // Japanese encoding setting
441 $html .= '<div class="exportoptions" id="kanji_encoding">';
442 $html .= '<h3>' . __('Encoding Conversion:') . '</h3>';
443 $html .= PMA_Kanji_encodingForm();
447 $html .= '<div class="exportoptions" id="submit">';
449 $html .= PMA_Util
::getExternalBug(
450 __('SQL compatibility mode'), 'mysql', '50027', '14515'
453 $html .= '<input type="submit" value="' . __('Go') . '" id="buttonGo" />';
457 $response = PMA_Response
::getInstance();
458 $response->addHTML($html);