2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 use PMA\libraries\config\PageSettings
;
9 use PMA\libraries\Response
;
12 * Gets some core libraries
14 require_once 'libraries/common.inc.php';
15 require_once 'libraries/config/user_preferences.forms.php';
16 require_once 'libraries/config/page_settings.forms.php';
17 require_once 'libraries/export.lib.php';
19 PageSettings
::showGroup('Export');
21 $response = Response
::getInstance();
22 $header = $response->getHeader();
23 $scripts = $header->getScripts();
24 $scripts->addFile('export.js');
26 // $sub_part is used in PMA\libraries\Util::getDbInfo() to see if we are coming from
27 // db_export.php, in which case we don't obey $cfg['MaxTableList']
28 $sub_part = '_export';
29 require_once 'libraries/db_common.inc.php';
30 $url_query .= '&goto=db_export.php';
42 ) = PMA\libraries\Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
47 $export_page_title = __('View dump (schema) of database');
49 // exit if no tables in db found
50 if ($num_tables < 1) {
51 PMA\libraries\Message
::error(__('No tables found in database.'))->display();
55 $multi_values = '<div class="export_table_list_container">';
56 if (isset($_GET['structure_or_data_forced'])) {
57 $force_val = htmlspecialchars($_GET['structure_or_data_forced']);
61 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
63 $multi_values .= '<table class="export_table_select">'
64 . '<thead><tr><th></th>'
65 . '<th>' . __('Tables') . '</th>'
66 . '<th class="export_structure">' . __('Structure') . '</th>'
67 . '<th class="export_data">' . __('Data') . '</th>'
70 . '<td class="export_table_name all">' . __('Select all') . '</td>'
71 . '<td class="export_structure all">'
72 . '<input type="checkbox" id="table_structure_all" /></td>'
73 . '<td class="export_data all"><input type="checkbox" id="table_data_all" />'
77 $multi_values .= "\n";
79 // when called by libraries/mult_submits.inc.php
80 if (!empty($_POST['selected_tbl']) && empty($table_select)) {
81 $table_select = $_POST['selected_tbl'];
84 // Check if the selected tables are defined in $_GET
85 // (from clicking Back button on export.php)
86 foreach (array('table_select', 'table_structure', 'table_data') as $one_key) {
87 if (isset($_GET[$one_key])) {
88 $_GET[$one_key] = urldecode($_GET[$one_key]);
89 $_GET[$one_key] = explode(",", $_GET[$one_key]);
93 foreach ($tables as $each_table) {
94 if (isset($_GET['table_select']) && is_array($_GET['table_select'])) {
95 $is_checked = PMA_getCheckedClause(
96 $each_table['Name'], $_GET['table_select']
98 } elseif (isset($table_select)) {
99 $is_checked = PMA_getCheckedClause(
100 $each_table['Name'], $table_select
103 $is_checked = ' checked="checked"';
105 if (isset($_GET['table_structure']) && is_array($_GET['table_structure'])) {
106 $structure_checked = PMA_getCheckedClause(
107 $each_table['Name'], $_GET['table_structure']
110 $structure_checked = $is_checked;
112 if (isset($_GET['table_data'])) {
113 $data_checked = PMA_getCheckedClause(
114 $each_table['Name'], $_GET['table_data']
117 $data_checked = $is_checked;
119 $table_html = htmlspecialchars($each_table['Name']);
120 $multi_values .= '<tr>';
121 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
122 . ' value="' . $table_html . '"' . $is_checked . ' /></td>';
123 $multi_values .= '<td class="export_table_name">'
124 . str_replace(' ', ' ', $table_html) . '</td>';
125 $multi_values .= '<td class="export_structure">'
126 . '<input type="checkbox" name="table_structure[]"'
127 . ' value="' . $table_html . '"' . $structure_checked . ' /></td>';
128 $multi_values .= '<td class="export_data">'
129 . '<input type="checkbox" name="table_data[]"'
130 . ' value="' . $table_html . '"' . $data_checked . ' /></td>';
131 $multi_values .= '</tr>';
134 $multi_values .= "\n";
135 $multi_values .= '</tbody></table></div>';
137 require_once 'libraries/display_export.lib.php';
138 if (! isset($sql_query)) {
141 if (! isset($num_tables)) {
144 if (! isset($unlim_num_rows)) {
147 if (! isset($multi_values)) {
150 $response = Response
::getInstance();
152 PMA_getExportDisplay(
153 'database', $db, $table, $sql_query, $num_tables,
154 $unlim_num_rows, $multi_values