Removing old documentation
[openemr.git] / phpmyadmin / libraries / display_export.lib.php
blob2613cd9d13a6b52d57a3a3e6cf5917fa4a4f067c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * functions for displaying server, database and table export
7 * @usedby display_export.inc.php
9 * @package PhpMyAdmin
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
16 * Outputs appropriate checked statement for checkbox.
18 * @param string $str option name
20 * @return string
22 function PMA_exportCheckboxCheck($str)
24 if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
25 return ' checked="checked"';
28 return null;
31 /**
32 * Prints Html For Export Selection Options
34 * @param String $tmp_select Tmp selected method of export
36 * @return string
38 function PMA_getHtmlForExportSelectOptions($tmp_select = '')
40 $multi_values = '<div>';
41 $multi_values .= '<a href="#"';
42 $multi_values .= ' onclick="setSelectOptions'
43 . '(\'dump\', \'db_select[]\', true); return false;">';
44 $multi_values .= __('Select all');
45 $multi_values .= '</a>';
46 $multi_values .= ' / ';
47 $multi_values .= '<a href="#"';
48 $multi_values .= ' onclick="setSelectOptions'
49 . '(\'dump\', \'db_select[]\', false); return false;">';
50 $multi_values .= __('Unselect all') . '</a><br />';
52 $multi_values .= '<select name="db_select[]" '
53 . 'id="db_select" size="10" multiple="multiple">';
54 $multi_values .= "\n";
56 // Check if the selected databases are defined in $_GET
57 // (from clicking Back button on export.php)
58 if (isset($_GET['db_select'])) {
59 $_GET['db_select'] = urldecode($_GET['db_select']);
60 $_GET['db_select'] = explode(",", $_GET['db_select']);
63 foreach ($GLOBALS['pma']->databases as $current_db) {
64 if ($GLOBALS['dbi']->isSystemSchema($current_db, true)) {
65 continue;
67 if (isset($_GET['db_select'])) {
68 if (in_array($current_db, $_GET['db_select'])) {
69 $is_selected = ' selected="selected"';
70 } else {
71 $is_selected = '';
73 } elseif (!empty($tmp_select)) {
74 if (/*overload*/mb_strpos(
75 ' ' . $tmp_select,
76 '|' . $current_db . '|'
77 )) {
78 $is_selected = ' selected="selected"';
79 } else {
80 $is_selected = '';
82 } else {
83 $is_selected = ' selected="selected"';
85 $current_db = htmlspecialchars($current_db);
86 $multi_values .= ' <option value="' . $current_db . '"'
87 . $is_selected . '>' . $current_db . '</option>' . "\n";
88 } // end while
89 $multi_values .= "\n";
90 $multi_values .= '</select></div>';
92 return $multi_values;
95 /**
96 * Prints Html For Export Hidden Input
98 * @param String $export_type Selected Export Type
99 * @param String $db Selected DB
100 * @param String $table Selected Table
101 * @param String $single_table Single Table
102 * @param String $sql_query Sql Query
104 * @return string
106 function PMA_getHtmlForHiddenInput(
107 $export_type, $db, $table, $single_table, $sql_query
109 global $cfg;
110 $html = "";
111 if ($export_type == 'server') {
112 $html .= PMA_URL_getHiddenInputs('', '', 1);
113 } elseif ($export_type == 'database') {
114 $html .= PMA_URL_getHiddenInputs($db, '', 1);
115 } else {
116 $html .= PMA_URL_getHiddenInputs($db, $table, 1);
119 // just to keep this value for possible next display of this form after saving
120 // on server
121 if (!empty($single_table)) {
122 $html .= '<input type="hidden" name="single_table" value="TRUE" />'
123 . "\n";
126 $html .= '<input type="hidden" name="export_type" value="'
127 . $export_type . '" />';
128 $html .= "\n";
130 // If the export method was not set, the default is quick
131 if (isset($_GET['export_method'])) {
132 $cfg['Export']['method'] = $_GET['export_method'];
133 } elseif (! isset($cfg['Export']['method'])) {
134 $cfg['Export']['method'] = 'quick';
136 // The export method (quick, custom or custom-no-form)
137 $html .= '<input type="hidden" name="export_method" value="'
138 . htmlspecialchars($cfg['Export']['method']) . '" />';
140 if (! empty($sql_query)) {
141 $html .= '<input type="hidden" name="sql_query" value="'
142 . htmlspecialchars($sql_query) . '" />' . "\n";
143 } elseif (isset($_GET['sql_query'])) {
144 $html .= '<input type="hidden" name="sql_query" value="'
145 . htmlspecialchars($_GET['sql_query']) . '" />' . "\n";
148 $html .= '<input type="hidden" name="template_id"' . ' value="'
149 . (isset($_GET['template_id'])
150 ? htmlspecialchars($_GET['template_id'])
151 : '')
152 . '" />';
154 return $html;
158 * Prints Html For Export Options Header
160 * @param String $export_type Selected Export Type
161 * @param String $db Selected DB
162 * @param String $table Selected Table
164 * @return string
166 function PMA_getHtmlForExportOptionHeader($export_type, $db, $table)
168 $html = '<div class="exportoptions" id="header">';
169 $html .= '<h2>';
170 $html .= PMA_Util::getImage('b_export.png', __('Export'));
171 if ($export_type == 'server') {
172 $html .= __('Exporting databases from the current server');
173 } elseif ($export_type == 'database') {
174 $html .= sprintf(
175 __('Exporting tables from "%s" database'),
176 htmlspecialchars($db)
178 } else {
179 $html .= sprintf(
180 __('Exporting rows from "%s" table'),
181 htmlspecialchars($table)
184 $html .= '</h2>';
185 $html .= '</div>';
187 return $html;
191 * Returns HTML for export template operations
193 * @param string $export_type export type - server, database, or table
195 * @return string HTML for export template operations
197 function PMA_getHtmlForExportTemplateLoading($export_type)
199 $html = '<div class="exportoptions" id="export_templates">';
200 $html .= '<h3>' . __('Export templates:') . '</h3>';
202 $html .= '<div class="floatleft">';
203 $html .= '<form method="post" action="tbl_export.php" id="newTemplateForm"'
204 . ' class="ajax">';
205 $html .= '<h4>' . __('New template:') . '</h4>';
206 $html .= '<input type="text" name="templateName" id="templateName" '
207 . 'maxlength="64"' . 'required="required" '
208 . 'placeholder="' . __('Template name') . '" />';
209 $html .= '<input type="submit" name="createTemplate" id="createTemplate" '
210 . 'value="' . __('Create') . '" />';
211 $html .= '</form>';
212 $html .= '</div>';
214 $html .= '<div class="floatleft" style="margin-left: 50px;">';
215 $html .= '<form method="post" action="tbl_export.php"'
216 . ' id="existingTemplatesForm" class="ajax">';
217 $html .= '<h4>' . __('Existing templates:') . '</h4>';
218 $html .= '<label for="template">' . __('Template:') . '</label>';
219 $html .= '<select required="required" name="template" id="template">';
220 $html .= PMA_getOptionsForExportTemplates($export_type);
221 $html .= '</select>';
222 $html .= '<input type="submit" name="updateTemplate" '
223 . 'id="updateTemplate" value="' . __('Update') . '" />';
224 $html .= '<input type="submit" name="deleteTemplate" '
225 . 'id="deleteTemplate" value="' . __('Delete') . '" />';
226 $html .= '</form>';
227 $html .= '</div>';
229 $html .= '<div class="clearfloat"></div>';
231 $html .= '</div>';
233 return $html;
237 * Returns HTML for the options in teplate dropdown
239 * @param string $export_type export type - server, database, or table
241 * @return string HTML for the options in teplate dropdown
243 function PMA_getOptionsForExportTemplates($export_type)
245 $ret = '<option value="">-- ' . __('Select a template') . ' --</option>';
247 // Get the relation settings
248 $cfgRelation = PMA_getRelationsParam();
250 $query = "SELECT `id`, `template_name` FROM "
251 . PMA_Util::backquote($cfgRelation['db']) . '.'
252 . PMA_Util::backquote($cfgRelation['export_templates'])
253 . " WHERE `username` = "
254 . "'" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
255 . " AND `export_type` = '" . $export_type . "'"
256 . " ORDER BY `template_name`;";
258 $result = PMA_queryAsControlUser($query);
259 if ($result) {
260 while ($row = $GLOBALS['dbi']->fetchAssoc($result, $GLOBALS['controllink'])) {
261 $ret .= '<option value="' . htmlspecialchars($row['id']) . '"';
262 if (!empty($_GET['template_id']) && $_GET['template_id'] == $row['id']) {
263 $ret .= ' selected="selected"';
265 $ret .= '>';
266 $ret .= htmlspecialchars($row['template_name']) . '</option>';
269 return $ret;
273 * Prints Html For Export Options Method
275 * @return string
277 function PMA_getHtmlForExportOptionsMethod()
279 global $cfg;
280 if (isset($_GET['quick_or_custom'])) {
281 $export_method = $_GET['quick_or_custom'];
282 } else {
283 $export_method = $cfg['Export']['method'];
286 if ($export_method == 'custom-no-form') {
287 return '';
290 $html = '<div class="exportoptions" id="quick_or_custom">';
291 $html .= '<h3>' . __('Export method:') . '</h3>';
292 $html .= '<ul>';
293 $html .= '<li>';
294 $html .= '<input type="radio" name="quick_or_custom" value="quick" '
295 . ' id="radio_quick_export"';
296 if ($export_method == 'quick') {
297 $html .= ' checked="checked"';
299 $html .= ' />';
300 $html .= '<label for ="radio_quick_export">';
301 $html .= __('Quick - display only the minimal options');
302 $html .= '</label>';
303 $html .= '</li>';
305 $html .= '<li>';
306 $html .= '<input type="radio" name="quick_or_custom" value="custom" '
307 . ' id="radio_custom_export"';
308 if ($export_method == 'custom') {
309 $html .= ' checked="checked"';
311 $html .= ' />';
312 $html .= '<label for="radio_custom_export">';
313 $html .= __('Custom - display all possible options');
314 $html .= '</label>';
315 $html .= '</li>';
317 $html .= '</ul>';
318 $html .= '</div>';
320 return $html;
324 * Prints Html For Export Options Selection
326 * @param String $export_type Selected Export Type
327 * @param String $multi_values Export Options
329 * @return string
331 function PMA_getHtmlForExportOptionsSelection($export_type, $multi_values)
333 $html = '<div class="exportoptions" id="databases_and_tables">';
334 if ($export_type == 'server') {
335 $html .= '<h3>' . __('Databases:') . '</h3>';
336 } else if ($export_type == 'database') {
337 $html .= '<h3>' . __('Tables:') . '</h3>';
339 if (! empty($multi_values)) {
340 $html .= $multi_values;
342 $html .= '</div>';
344 return $html;
348 * Prints Html For Export Options Format dropdown
350 * @param ExportPlugin[] $export_list Export List
352 * @return string
354 function PMA_getHtmlForExportOptionsFormatDropdown($export_list)
356 $html = '<div class="exportoptions" id="format">';
357 $html .= '<h3>' . __('Format:') . '</h3>';
358 $html .= PMA_pluginGetChoice('Export', 'what', $export_list, 'format');
359 $html .= '</div>';
360 return $html;
364 * Prints Html For Export Options Format-specific options
366 * @param ExportPlugin[] $export_list Export List
368 * @return string
370 function PMA_getHtmlForExportOptionsFormat($export_list)
372 $html = '<div class="exportoptions" id="format_specific_opts">';
373 $html .= '<h3>' . __('Format-specific options:') . '</h3>';
374 $html .= '<p class="no_js_msg" id="scroll_to_options_msg">';
375 $html .= __(
376 'Scroll down to fill in the options for the selected format '
377 . 'and ignore the options for other formats.'
379 $html .= '</p>';
380 $html .= PMA_pluginGetOptions('Export', $export_list);
381 $html .= '</div>';
383 if (function_exists('PMA_Kanji_encodingForm')) {
384 // Encoding setting form appended by Y.Kawada
385 // Japanese encoding setting
386 $html .= '<div class="exportoptions" id="kanji_encoding">';
387 $html .= '<h3>' . __('Encoding Conversion:') . '</h3>';
388 $html .= PMA_Kanji_encodingForm();
389 $html .= '</div>';
392 $html .= '<div class="exportoptions" id="submit">';
394 $html .= PMA_Util::getExternalBug(
395 __('SQL compatibility mode'), 'mysql', '50027', '14515'
397 global $cfg;
398 if ($cfg['ExecTimeLimit'] > 0) {
399 $html .= '<input type="submit" value="' . __('Go')
400 . '" id="buttonGo" onclick="check_time_out('
401 . $cfg['ExecTimeLimit'] . ')"/>';
402 } else {
403 // if the time limit set is zero, then time out won't occur
404 // So no need to check for time out.
405 $html .= '<input type="submit" value="' . __('Go') . '" id="buttonGo" />';
407 $html .= '</div>';
409 return $html;
412 * Prints Html For Export Options Rows
414 * @param String $db Selected DB
415 * @param String $table Selected Table
416 * @param String $unlim_num_rows Num of Rows
418 * @return string
420 function PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows)
422 $html = '<div class="exportoptions" id="rows">';
423 $html .= '<h3>' . __('Rows:') . '</h3>';
424 $html .= '<ul>';
425 $html .= '<li>';
426 $html .= '<input type="radio" name="allrows" value="0" id="radio_allrows_0"';
427 if (isset($_GET['allrows']) && $_GET['allrows'] == 0) {
428 $html .= ' checked="checked"';
430 $html .= '/>';
431 $html .= '<label for ="radio_allrows_0">' . __('Dump some row(s)') . '</label>';
432 $html .= '<ul>';
433 $html .= '<li>';
434 $html .= '<label for="limit_to">' . __('Number of rows:') . '</label>';
435 $html .= '<input type="text" id="limit_to" name="limit_to" size="5" value="';
436 if (isset($_GET['limit_to'])) {
437 $html .= htmlspecialchars($_GET['limit_to']);
438 } elseif (!empty($unlim_num_rows)) {
439 $html .= $unlim_num_rows;
440 } else {
441 $_table = new PMA_Table($table, $db);
442 $html .= $_table->countRecords();
444 $html .= '" onfocus="this.select()" />';
445 $html .= '</li>';
446 $html .= '<li>';
447 $html .= '<label for="limit_from">' . __('Row to begin at:') . '</label>';
448 $html .= '<input type="text" id="limit_from" name="limit_from" value="';
449 if (isset($_GET['limit_from'])) {
450 $html .= htmlspecialchars($_GET['limit_from']);
451 } else {
452 $html .= '0';
454 $html .= '" size="5" onfocus="this.select()" />';
455 $html .= '</li>';
456 $html .= '</ul>';
457 $html .= '</li>';
458 $html .= '<li>';
459 $html .= '<input type="radio" name="allrows" value="1" id="radio_allrows_1"';
460 if (! isset($_GET['allrows']) || $_GET['allrows'] == 1) {
461 $html .= ' checked="checked"';
463 $html .= '/>';
464 $html .= ' <label for="radio_allrows_1">' . __('Dump all rows') . '</label>';
465 $html .= '</li>';
466 $html .= '</ul>';
467 $html .= '</div>';
468 return $html;
472 * Prints Html For Export Options Quick Export
474 * @return string
476 function PMA_getHtmlForExportOptionsQuickExport()
478 global $cfg;
479 $html = '<div class="exportoptions" id="output_quick_export">';
480 $html .= '<h3>' . __('Output:') . '</h3>';
481 $html .= '<ul>';
482 $html .= '<li>';
483 $html .= '<input type="checkbox" name="quick_export_onserver" value="saveit" ';
484 $html .= 'id="checkbox_quick_dump_onserver" ';
485 $html .= PMA_exportCheckboxCheck('quick_export_onserver');
486 $html .= '/>';
487 $html .= '<label for="checkbox_quick_dump_onserver">';
488 $html .= sprintf(
489 __('Save on server in the directory <b>%s</b>'),
490 htmlspecialchars(PMA_Util::userDir($cfg['SaveDir']))
492 $html .= '</label>';
493 $html .= '</li>';
494 $html .= '<li>';
495 $html .= '<input type="checkbox" name="quick_export_onserver_overwrite" ';
496 $html .= 'value="saveitover" id="checkbox_quick_dump_onserver_overwrite" ';
497 $html .= PMA_exportCheckboxCheck('quick_export_onserver_overwrite');
498 $html .= '/>';
499 $html .= '<label for="checkbox_quick_dump_onserver_overwrite">';
500 $html .= __('Overwrite existing file(s)');
501 $html .= '</label>';
502 $html .= '</li>';
503 $html .= '</ul>';
504 $html .= '</div>';
506 return $html;
510 * Prints Html For Export Options Save Dir
512 * @return string
514 function PMA_getHtmlForExportOptionsOutputSaveDir()
516 global $cfg;
517 $html = '<li>';
518 $html .= '<input type="checkbox" name="onserver" value="saveit" ';
519 $html .= 'id="checkbox_dump_onserver" ';
520 $html .= PMA_exportCheckboxCheck('onserver');
521 $html .= '/>';
522 $html .= '<label for="checkbox_dump_onserver">';
523 $html .= sprintf(
524 __('Save on server in the directory <b>%s</b>'),
525 htmlspecialchars(PMA_Util::userDir($cfg['SaveDir']))
527 $html .= '</label>';
528 $html .= '</li>';
529 $html .= '<li>';
530 $html .= '<input type="checkbox" name="onserver_overwrite" value="saveitover"';
531 $html .= ' id="checkbox_dump_onserver_overwrite" ';
532 $html .= PMA_exportCheckboxCheck('onserver_overwrite');
533 $html .= '/>';
534 $html .= '<label for="checkbox_dump_onserver_overwrite">';
535 $html .= __('Overwrite existing file(s)');
536 $html .= '</label>';
537 $html .= '</li>';
539 return $html;
544 * Prints Html For Export Options
546 * @param String $export_type Selected Export Type
548 * @return string
550 function PMA_getHtmlForExportOptionsOutputFormat($export_type)
552 $html = '<li>';
553 $html .= '<label for="filename_template" class="desc">';
554 $html .= __('File name template:');
555 $trans = new PMA_Message;
556 $trans->addMessage(__('@SERVER@ will become the server name'));
557 if ($export_type == 'database' || $export_type == 'table') {
558 $trans->addMessage(__(', @DATABASE@ will become the database name'));
559 if ($export_type == 'table') {
560 $trans->addMessage(__(', @TABLE@ will become the table name'));
564 $msg = new PMA_Message(
566 'This value is interpreted using %1$sstrftime%2$s, '
567 . 'so you can use time formatting strings. '
568 . 'Additionally the following transformations will happen: %3$s. '
569 . 'Other text will be kept as is. See the %4$sFAQ%5$s for details.'
572 $msg->addParam(
573 '<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php'))
574 . '" target="documentation" title="' . __('Documentation') . '">',
575 false
577 $msg->addParam('</a>', false);
578 $msg->addParam($trans);
579 $doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
580 $msg->addParam(
581 '<a href="' . $doc_url . '" target="documentation">',
582 false
584 $msg->addParam('</a>', false);
586 $html .= PMA_Util::showHint($msg);
587 $html .= '</label>';
588 $html .= '<input type="text" name="filename_template" id="filename_template" ';
589 $html .= ' value="';
590 if (isset($_GET['filename_template'])) {
591 $html .= htmlspecialchars($_GET['filename_template']);
592 } else {
593 if ($export_type == 'database') {
594 $html .= htmlspecialchars(
595 $GLOBALS['PMA_Config']->getUserValue(
596 'pma_db_filename_template',
597 $GLOBALS['cfg']['Export']['file_template_database']
600 } elseif ($export_type == 'table') {
601 $html .= htmlspecialchars(
602 $GLOBALS['PMA_Config']->getUserValue(
603 'pma_table_filename_template',
604 $GLOBALS['cfg']['Export']['file_template_table']
607 } else {
608 $html .= htmlspecialchars(
609 $GLOBALS['PMA_Config']->getUserValue(
610 'pma_server_filename_template',
611 $GLOBALS['cfg']['Export']['file_template_server']
616 $html .= '"';
617 $html .= '/>';
618 $html .= '<input type="checkbox" name="remember_template" ';
619 $html .= 'id="checkbox_remember_template" ';
620 $html .= PMA_exportCheckboxCheck('remember_file_template');
621 $html .= '/>';
622 $html .= '<label for="checkbox_remember_template">';
623 $html .= __('use this for future exports');
624 $html .= '</label>';
625 $html .= '</li>';
626 return $html;
630 * Prints Html For Export Options Charset
632 * @return string
634 function PMA_getHtmlForExportOptionsOutputCharset()
636 global $cfg;
637 $html = ' <li><label for="select_charset" class="desc">'
638 . __('Character set of the file:') . '</label>' . "\n";
639 reset($cfg['AvailableCharsets']);
640 $html .= '<select id="select_charset" name="charset" size="1">';
641 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
642 $html .= '<option value="' . $temp_charset . '"';
643 if (isset($_GET['charset'])
644 && ($_GET['charset'] != $temp_charset)
646 $html .= '';
647 } elseif ((empty($cfg['Export']['charset']) && $temp_charset == 'utf-8')
648 || $temp_charset == $cfg['Export']['charset']
650 $html .= ' selected="selected"';
652 $html .= '>' . $temp_charset . '</option>';
653 } // end foreach
654 $html .= '</select></li>';
656 return $html;
660 * Prints Html For Export Options Compression
662 * @return string
664 function PMA_getHtmlForExportOptionsOutputCompression()
666 global $cfg;
667 if (isset($_GET['compression'])) {
668 $selected_compression = $_GET['compression'];
669 } elseif (isset($cfg['Export']['compression'])) {
670 $selected_compression = $cfg['Export']['compression'];
671 } else {
672 $selected_compression = "none";
675 // Since separate files export works with ZIP only
676 if (isset($cfg['Export']['as_separate_files'])
677 && $cfg['Export']['as_separate_files']
679 $selected_compression = "zip";
682 $html = "";
683 // zip and gzip encode features
684 $is_zip = ($cfg['ZipDump'] && @function_exists('gzcompress'));
685 $is_gzip = ($cfg['GZipDump'] && @function_exists('gzencode'));
686 if ($is_zip || $is_gzip) {
687 $html .= '<li>';
688 $html .= '<label for="compression" class="desc">'
689 . __('Compression:') . '</label>';
690 $html .= '<select id="compression" name="compression">';
691 $html .= '<option value="none">' . __('None') . '</option>';
692 if ($is_zip) {
693 $html .= '<option value="zip" ';
694 if ($selected_compression == "zip") {
695 $html .= 'selected="selected"';
697 $html .= '>' . __('zipped') . '</option>';
699 if ($is_gzip) {
700 $html .= '<option value="gzip" ';
701 if ($selected_compression == "gzip") {
702 $html .= 'selected="selected"';
704 $html .= '>' . __('gzipped') . '</option>';
706 $html .= '</select>';
707 $html .= '</li>';
708 } else {
709 $html .= '<input type="hidden" name="compression" value="'
710 . htmlspecialchars($selected_compression) . '" />';
713 return $html;
717 * Prints Html For Export Options Radio
719 * @return string
721 function PMA_getHtmlForExportOptionsOutputRadio()
723 $html = '<li>';
724 $html .= '<input type="radio" id="radio_view_as_text" '
725 . ' name="output_format" value="astext" ';
726 if (isset($_GET['repopulate']) || $GLOBALS['cfg']['Export']['asfile'] == false) {
727 $html .= 'checked="checked"';
729 $html .= '/>';
730 $html .= '<label for="radio_view_as_text">'
731 . __('View output as text') . '</label></li>';
732 return $html;
736 * Prints Html For Export Options Checkbox - Separate files
738 * @param String $export_type Selected Export Type
740 * @return string
742 function PMA_getHtmlForExportOptionsOutputSeparateFiles($export_type)
744 $html = '<li>';
745 $html .= '<input type="checkbox" id="checkbox_as_separate_files" '
746 . PMA_exportCheckboxCheck('as_separate_files')
747 . ' name="as_separate_files" value="' . $export_type . '" />';
748 $html .= '<label for="checkbox_as_separate_files">';
750 if ($export_type == 'server') {
751 $html .= __('Export databases as separate files');
752 } elseif ($export_type == 'database') {
753 $html .= __('Export tables as separate files');
756 $html .= '</label></li>';
758 return $html;
762 * Prints Html For Export Options
764 * @param String $export_type Selected Export Type
766 * @return string
768 function PMA_getHtmlForExportOptionsOutput($export_type)
770 global $cfg;
771 $html = '<div class="exportoptions" id="output">';
772 $html .= '<h3>' . __('Output:') . '</h3>';
773 $html .= '<ul id="ul_output">';
774 $html .= '<li><input type="checkbox" id="btn_alias_config" ';
775 if (isset($_SESSION['tmpval']['aliases'])
776 && !PMA_emptyRecursive($_SESSION['tmpval']['aliases'])
778 $html .= 'checked="checked"';
780 unset($_SESSION['tmpval']['aliases']);
781 $html .= '/>';
782 $html .= '<label for="btn_alias_config">';
783 $html .= __('Rename exported databases/tables/columns');
784 $html .= '</label></li>';
786 if ($export_type != 'server') {
787 $html .= '<li>';
788 $html .= '<input type="checkbox" name="lock_tables"';
789 $html .= ' value="something" id="checkbox_lock_tables"';
790 if (! isset($_GET['repopulate'])) {
791 $html .= PMA_exportCheckboxCheck('lock_tables') . '/>';
792 } elseif (isset($_GET['lock_tables'])) {
793 $html .= ' checked="checked"';
795 $html .= '<label for="checkbox_lock_tables">';
796 $html .= sprintf(__('Use %s statement'), '<code>LOCK TABLES</code>');
797 $html .= '</label></li>';
800 $html .= '<li>';
801 $html .= '<input type="radio" name="output_format" value="sendit" ';
802 $html .= 'id="radio_dump_asfile" ';
803 if (!isset($_GET['repopulate'])) {
804 $html .= PMA_exportCheckboxCheck('asfile');
806 $html .= '/>';
807 $html .= '<label for="radio_dump_asfile">'
808 . __('Save output to a file') . '</label>';
809 $html .= '<ul id="ul_save_asfile">';
810 if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
811 $html .= PMA_getHtmlForExportOptionsOutputSaveDir();
814 $html .= PMA_getHtmlForExportOptionsOutputFormat($export_type);
816 // charset of file
817 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE) {
818 $html .= PMA_getHtmlForExportOptionsOutputCharset();
819 } // end if
821 $html .= PMA_getHtmlForExportOptionsOutputCompression();
823 if ($export_type == 'server'
824 || $export_type == 'database'
826 $html .= PMA_getHtmlForExportOptionsOutputSeparateFiles($export_type);
829 $html .= '</ul>';
830 $html .= '</li>';
832 $html .= PMA_getHtmlForExportOptionsOutputRadio();
834 $html .= '</ul>';
837 * @todo use sprintf() for better translatability, while keeping the
838 * <label></label> principle (for screen readers)
840 $html .= '<label for="maxsize">'
841 . __('Skip tables larger than') . '</label>';
842 $html .= '<input type="text" id="maxsize" name="maxsize" size="4">' . __('MiB');
844 $html .= '</div>';
846 return $html;
850 * Prints Html For Export Options
852 * @param String $export_type Selected Export Type
853 * @param String $db Selected DB
854 * @param String $table Selected Table
855 * @param String $multi_values Export selection
856 * @param String $num_tables number of tables
857 * @param ExportPlugin[] $export_list Export List
858 * @param String $unlim_num_rows Number of Rows
860 * @return string
862 function PMA_getHtmlForExportOptions(
863 $export_type, $db, $table, $multi_values,
864 $num_tables, $export_list, $unlim_num_rows
866 global $cfg;
867 $html = PMA_getHtmlForExportOptionsMethod();
868 $html .= PMA_getHtmlForExportOptionsFormatDropdown($export_list);
869 $html .= PMA_getHtmlForExportOptionsSelection($export_type, $multi_values);
871 $tableLength = /*overload*/mb_strlen($table);
872 $_table = new PMA_Table($table, $db);
873 if ($tableLength && empty($num_tables) && ! $_table->isMerge()) {
874 $html .= PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows);
877 if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
878 $html .= PMA_getHtmlForExportOptionsQuickExport();
881 $html .= PMA_getHtmlForAliasModalDialog($db, $table);
882 $html .= PMA_getHtmlForExportOptionsOutput($export_type);
883 $html .= PMA_getHtmlForExportOptionsFormat($export_list);
884 return $html;
888 * Prints Html For Alias Modal Dialog
890 * @param String $db Selected DB
891 * @param String $table Selected Table
893 * @return string
895 function PMA_getHtmlForAliasModalDialog($db = '', $table = '')
897 if (isset($_SESSION['tmpval']['aliases'])) {
898 $aliases = $_SESSION['tmpval']['aliases'];
900 // In case of server export, the following list of
901 // databases are not shown in the list.
902 $dbs_not_allowed = array(
903 'information_schema',
904 'performance_schema',
905 'mysql'
907 // Fetch Columns info
908 // Server export does not have db set.
909 $title = __('Rename exported databases/tables/columns');
910 if (empty($db)) {
911 $databases = $GLOBALS['dbi']->getColumnsFull(
912 null, null, null, $GLOBALS['userlink']
914 foreach ($dbs_not_allowed as $db) {
915 unset($databases[$db]);
917 // Database export does not have table set.
918 } elseif (empty($table)) {
919 $tables = $GLOBALS['dbi']->getColumnsFull(
920 $db, null, null, $GLOBALS['userlink']
922 $databases = array($db => $tables);
923 // Table export
924 } else {
925 $columns = $GLOBALS['dbi']->getColumnsFull(
926 $db, $table, null, $GLOBALS['userlink']
928 $databases = array(
929 $db => array(
930 $table => $columns
935 $html = '<div id="alias_modal" class="hide" title="' . $title . '">';
936 $db_html = '<label class="col-2">' . __('Select database') . ': '
937 . '</label><select id="db_alias_select">';
938 $table_html = '<label class="col-2">' . __('Select table') . ': </label>';
939 $first_db = true;
940 $table_input_html = $db_input_html = '';
941 foreach ($databases as $db => $tables) {
942 $val = '';
943 if (!empty($aliases[$db]['alias'])) {
944 $val = htmlspecialchars($aliases[$db]['alias']);
946 $db = htmlspecialchars($db);
947 $name_attr = 'aliases[' . $db . '][alias]';
948 $id_attr = substr(md5($name_attr), 0, 12);
949 $class = 'hide';
950 if ($first_db) {
951 $first_db = false;
952 $class = '';
953 $db_input_html = '<label class="col-2" for="' . $id_attr . '">'
954 . __('New database name') . ': </label>';
956 $db_input_html .= '<input type="text" name="' . $name_attr . '" '
957 . 'placeholder="' . $db . ' alias" class="' . $class . '" '
958 . 'id="' . $id_attr . '" value="' . $val . '" disabled="disabled"/>';
959 $db_html .= '<option value="' . $id_attr . '">' . $db . '</option>';
960 $table_html .= '<span id="' . $id_attr . '_tables" class="' . $class . '">';
961 $table_html .= '<select id="' . $id_attr . '_tables_select" '
962 . 'class="table_alias_select">';
963 $first_tbl = true;
964 $col_html = '';
965 foreach ($tables as $table => $columns) {
966 $val = '';
967 if (!empty($aliases[$db]['tables'][$table]['alias'])) {
968 $val = htmlspecialchars($aliases[$db]['tables'][$table]['alias']);
970 $table = htmlspecialchars($table);
971 $name_attr = 'aliases[' . $db . '][tables][' . $table . '][alias]';
972 $id_attr = substr(md5($name_attr), 0, 12);
973 $class = 'hide';
974 if ($first_tbl) {
975 $first_tbl = false;
976 $class = '';
977 $table_input_html = '<label class="col-2" for="' . $id_attr . '">'
978 . __('New table name') . ': </label>';
980 $table_input_html .= '<input type="text" value="' . $val . '" '
981 . 'name="' . $name_attr . '" id="' . $id_attr . '" '
982 . 'placeholder="' . $table . ' alias" class="' . $class . '" '
983 . 'disabled="disabled"/>';
984 $table_html .= '<option value="' . $id_attr . '">'
985 . $table . '</option>';
986 $col_html .= '<table id="' . $id_attr . '_cols" class="'
987 . $class . '" width="100%">';
988 $col_html .= '<thead><tr><th>' . __('Old column name') . '</th>'
989 . '<th>' . __('New column name') . '</th></tr></thead><tbody>';
990 $class = 'odd';
991 foreach ($columns as $column => $col_def) {
992 $val = '';
993 if (!empty($aliases[$db]['tables'][$table]['columns'][$column])) {
994 $val = htmlspecialchars(
995 $aliases[$db]['tables'][$table]['columns'][$column]
998 $column = htmlspecialchars($column);
999 $name_attr = 'aliases[' . $db . '][tables][' . $table
1000 . '][columns][' . $column . ']';
1001 $id_attr = substr(md5($name_attr), 0, 12);
1002 $col_html .= '<tr class="' . $class . '">';
1003 $col_html .= '<th><label for="' . $id_attr . '">' . $column
1004 . '</label></th>';
1005 $col_html .= '<td><dummy_inp type="text" name="' . $name_attr . '" '
1006 . 'id="' . $id_attr . '" placeholder="'
1007 . $column . ' alias" value="' . $val . '"></dummy_inp></td>';
1008 $col_html .= '</tr>';
1009 $class = $class === 'odd' ? 'even' : 'odd';
1011 $col_html .= '</tbody></table>';
1013 $table_html .= '</select>';
1014 $table_html .= $table_input_html . '<hr/>' . $col_html . '</span>';
1016 $db_html .= '</select>';
1017 $html .= $db_html;
1018 $html .= $db_input_html . '<hr/>';
1019 $html .= $table_html;
1021 $html .= '</div>';
1022 return $html;