2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * functions for displaying server, database and table export
7 * @usedby display_export.inc.php
11 if (! defined('PHPMYADMIN')) {
16 * Outputs appropriate checked statement for checkbox.
18 * @param string $str option name
22 function PMA_exportCheckboxCheck($str)
24 if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
25 return ' checked="checked"';
32 * Prints Html For Export Selection Options
34 * @param String $tmp_select Tmp selected method of export
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)) {
67 if (isset($_GET['db_select'])) {
68 if (in_array($current_db, $_GET['db_select'])) {
69 $is_selected = ' selected="selected"';
73 } elseif (!empty($tmp_select)) {
74 if (/*overload*/mb_strpos(
76 '|' . $current_db . '|'
78 $is_selected = ' selected="selected"';
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";
89 $multi_values .= "\n";
90 $multi_values .= '</select></div>';
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
106 function PMA_getHtmlForHiddenInput(
107 $export_type, $db, $table, $single_table, $sql_query
111 if ($export_type == 'server') {
112 $html .= PMA_URL_getHiddenInputs('', '', 1);
113 } elseif ($export_type == 'database') {
114 $html .= PMA_URL_getHiddenInputs($db, '', 1);
116 $html .= PMA_URL_getHiddenInputs($db, $table, 1);
119 // just to keep this value for possible next display of this form after saving
121 if (!empty($single_table)) {
122 $html .= '<input type="hidden" name="single_table" value="TRUE" />'
126 $html .= '<input type="hidden" name="export_type" value="'
127 . $export_type . '" />';
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'])
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
166 function PMA_getHtmlForExportOptionHeader($export_type, $db, $table)
168 $html = '<div class="exportoptions" id="header">';
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') {
175 __('Exporting tables from "%s" database'),
176 htmlspecialchars($db)
180 __('Exporting rows from "%s" table'),
181 htmlspecialchars($table)
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"'
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') . '" />';
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') . '" />';
229 $html .= '<div class="clearfloat"></div>';
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);
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"';
266 $ret .= htmlspecialchars($row['template_name']) . '</option>';
273 * Prints Html For Export Options Method
277 function PMA_getHtmlForExportOptionsMethod()
280 if (isset($_GET['quick_or_custom'])) {
281 $export_method = $_GET['quick_or_custom'];
283 $export_method = $cfg['Export']['method'];
286 if ($export_method == 'custom-no-form') {
290 $html = '<div class="exportoptions" id="quick_or_custom">';
291 $html .= '<h3>' . __('Export method:') . '</h3>';
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"';
300 $html .= '<label for ="radio_quick_export">';
301 $html .= __('Quick - display only the minimal options');
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"';
312 $html .= '<label for="radio_custom_export">';
313 $html .= __('Custom - display all possible options');
324 * Prints Html For Export Options Selection
326 * @param String $export_type Selected Export Type
327 * @param String $multi_values Export Options
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;
348 * Prints Html For Export Options Format dropdown
350 * @param ExportPlugin[] $export_list Export List
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');
364 * Prints Html For Export Options Format-specific options
366 * @param ExportPlugin[] $export_list Export List
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">';
376 'Scroll down to fill in the options for the selected format '
377 . 'and ignore the options for other formats.'
380 $html .= PMA_pluginGetOptions('Export', $export_list);
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();
392 $html .= '<div class="exportoptions" id="submit">';
394 $html .= PMA_Util
::getExternalBug(
395 __('SQL compatibility mode'), 'mysql', '50027', '14515'
398 if ($cfg['ExecTimeLimit'] > 0) {
399 $html .= '<input type="submit" value="' . __('Go')
400 . '" id="buttonGo" onclick="check_time_out('
401 . $cfg['ExecTimeLimit'] . ')"/>';
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" />';
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
420 function PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows)
422 $html = '<div class="exportoptions" id="rows">';
423 $html .= '<h3>' . __('Rows:') . '</h3>';
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"';
431 $html .= '<label for ="radio_allrows_0">' . __('Dump some row(s)') . '</label>';
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;
441 $_table = new PMA_Table($table, $db);
442 $html .= $_table->countRecords();
444 $html .= '" onfocus="this.select()" />';
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']);
454 $html .= '" size="5" onfocus="this.select()" />';
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"';
464 $html .= ' <label for="radio_allrows_1">' . __('Dump all rows') . '</label>';
472 * Prints Html For Export Options Quick Export
476 function PMA_getHtmlForExportOptionsQuickExport()
479 $html = '<div class="exportoptions" id="output_quick_export">';
480 $html .= '<h3>' . __('Output:') . '</h3>';
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');
487 $html .= '<label for="checkbox_quick_dump_onserver">';
489 __('Save on server in the directory <b>%s</b>'),
490 htmlspecialchars(PMA_Util
::userDir($cfg['SaveDir']))
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');
499 $html .= '<label for="checkbox_quick_dump_onserver_overwrite">';
500 $html .= __('Overwrite existing file(s)');
510 * Prints Html For Export Options Save Dir
514 function PMA_getHtmlForExportOptionsOutputSaveDir()
518 $html .= '<input type="checkbox" name="onserver" value="saveit" ';
519 $html .= 'id="checkbox_dump_onserver" ';
520 $html .= PMA_exportCheckboxCheck('onserver');
522 $html .= '<label for="checkbox_dump_onserver">';
524 __('Save on server in the directory <b>%s</b>'),
525 htmlspecialchars(PMA_Util
::userDir($cfg['SaveDir']))
530 $html .= '<input type="checkbox" name="onserver_overwrite" value="saveitover"';
531 $html .= ' id="checkbox_dump_onserver_overwrite" ';
532 $html .= PMA_exportCheckboxCheck('onserver_overwrite');
534 $html .= '<label for="checkbox_dump_onserver_overwrite">';
535 $html .= __('Overwrite existing file(s)');
544 * Prints Html For Export Options
546 * @param String $export_type Selected Export Type
550 function PMA_getHtmlForExportOptionsOutputFormat($export_type)
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.'
573 '<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php'))
574 . '" target="documentation" title="' . __('Documentation') . '">',
577 $msg->addParam('</a>', false);
578 $msg->addParam($trans);
579 $doc_url = PMA_Util
::getDocuLink('faq', 'faq6-27');
581 '<a href="' . $doc_url . '" target="documentation">',
584 $msg->addParam('</a>', false);
586 $html .= PMA_Util
::showHint($msg);
588 $html .= '<input type="text" name="filename_template" id="filename_template" ';
590 if (isset($_GET['filename_template'])) {
591 $html .= htmlspecialchars($_GET['filename_template']);
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']
608 $html .= htmlspecialchars(
609 $GLOBALS['PMA_Config']->getUserValue(
610 'pma_server_filename_template',
611 $GLOBALS['cfg']['Export']['file_template_server']
618 $html .= '<input type="checkbox" name="remember_template" ';
619 $html .= 'id="checkbox_remember_template" ';
620 $html .= PMA_exportCheckboxCheck('remember_file_template');
622 $html .= '<label for="checkbox_remember_template">';
623 $html .= __('use this for future exports');
630 * Prints Html For Export Options Charset
634 function PMA_getHtmlForExportOptionsOutputCharset()
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)
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>';
654 $html .= '</select></li>';
660 * Prints Html For Export Options Compression
664 function PMA_getHtmlForExportOptionsOutputCompression()
667 if (isset($_GET['compression'])) {
668 $selected_compression = $_GET['compression'];
669 } elseif (isset($cfg['Export']['compression'])) {
670 $selected_compression = $cfg['Export']['compression'];
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";
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) {
688 $html .= '<label for="compression" class="desc">'
689 . __('Compression:') . '</label>';
690 $html .= '<select id="compression" name="compression">';
691 $html .= '<option value="none">' . __('None') . '</option>';
693 $html .= '<option value="zip" ';
694 if ($selected_compression == "zip") {
695 $html .= 'selected="selected"';
697 $html .= '>' . __('zipped') . '</option>';
700 $html .= '<option value="gzip" ';
701 if ($selected_compression == "gzip") {
702 $html .= 'selected="selected"';
704 $html .= '>' . __('gzipped') . '</option>';
706 $html .= '</select>';
709 $html .= '<input type="hidden" name="compression" value="'
710 . htmlspecialchars($selected_compression) . '" />';
717 * Prints Html For Export Options Radio
721 function PMA_getHtmlForExportOptionsOutputRadio()
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"';
730 $html .= '<label for="radio_view_as_text">'
731 . __('View output as text') . '</label></li>';
736 * Prints Html For Export Options Checkbox - Separate files
738 * @param String $export_type Selected Export Type
742 function PMA_getHtmlForExportOptionsOutputSeparateFiles($export_type)
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>';
762 * Prints Html For Export Options
764 * @param String $export_type Selected Export Type
768 function PMA_getHtmlForExportOptionsOutput($export_type)
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']);
782 $html .= '<label for="btn_alias_config">';
783 $html .= __('Rename exported databases/tables/columns');
784 $html .= '</label></li>';
786 if ($export_type != 'server') {
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>';
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');
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);
817 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
) {
818 $html .= PMA_getHtmlForExportOptionsOutputCharset();
821 $html .= PMA_getHtmlForExportOptionsOutputCompression();
823 if ($export_type == 'server'
824 ||
$export_type == 'database'
826 $html .= PMA_getHtmlForExportOptionsOutputSeparateFiles($export_type);
832 $html .= PMA_getHtmlForExportOptionsOutputRadio();
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');
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
862 function PMA_getHtmlForExportOptions(
863 $export_type, $db, $table, $multi_values,
864 $num_tables, $export_list, $unlim_num_rows
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);
888 * Prints Html For Alias Modal Dialog
890 * @param String $db Selected DB
891 * @param String $table Selected Table
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',
907 // Fetch Columns info
908 // Server export does not have db set.
909 $title = __('Rename exported databases/tables/columns');
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);
925 $columns = $GLOBALS['dbi']->getColumnsFull(
926 $db, $table, null, $GLOBALS['userlink']
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>';
940 $table_input_html = $db_input_html = '';
941 foreach ($databases as $db => $tables) {
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);
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">';
965 foreach ($tables as $table => $columns) {
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);
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>';
991 foreach ($columns as $column => $col_def) {
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
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>';
1018 $html .= $db_input_html . '<hr/>';
1019 $html .= $table_html;