2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 declare(strict_types
=1);
10 use PhpMyAdmin\Config\PageSettings
;
11 use PhpMyAdmin\DatabaseInterface
;
12 use PhpMyAdmin\Display\Export
as DisplayExport
;
13 use PhpMyAdmin\Export
;
14 use PhpMyAdmin\Message
;
15 use PhpMyAdmin\Response
;
18 if (! defined('ROOT_PATH')) {
19 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
22 global $db, $table, $url_query, $containerBuilder;
24 require_once ROOT_PATH
. 'libraries/common.inc.php';
26 /** @var Response $response */
27 $response = $containerBuilder->get(Response
::class);
29 /** @var DatabaseInterface $dbi */
30 $dbi = $containerBuilder->get(DatabaseInterface
::class);
32 PageSettings
::showGroup('Export');
34 $header = $response->getHeader();
35 $scripts = $header->getScripts();
36 $scripts->addFile('export.js');
38 /** @var Export $export */
39 $export = $containerBuilder->get('export');
41 // $sub_part is used in Util::getDbInfo() to see if we are coming from
42 // db_export.php, in which case we don't obey $cfg['MaxTableList']
43 $sub_part = '_export';
44 require_once ROOT_PATH
. 'libraries/db_common.inc.php';
45 $url_query .= '&goto=db_export.php';
57 ) = Util
::getDbInfo($db, $sub_part === null ?
'' : $sub_part);
62 $export_page_title = __('View dump (schema) of database');
64 // exit if no tables in db found
65 if ($num_tables < 1) {
67 Message
::error(__('No tables found in database.'))->getDisplay()
72 $multi_values = '<div class="export_table_list_container">';
73 if (isset($_POST['structure_or_data_forced'])) {
74 $force_val = htmlspecialchars($_POST['structure_or_data_forced']);
78 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
80 $multi_values .= '<table class="export_table_select">'
81 . '<thead><tr><th></th>'
82 . '<th>' . __('Tables') . '</th>'
83 . '<th class="export_structure">' . __('Structure') . '</th>'
84 . '<th class="export_data">' . __('Data') . '</th>'
87 . '<td class="export_table_name all">' . __('Select all') . '</td>'
88 . '<td class="export_structure all">'
89 . '<input type="checkbox" id="table_structure_all"></td>'
90 . '<td class="export_data all"><input type="checkbox" id="table_data_all">'
94 $multi_values .= "\n";
96 // when called by libraries/mult_submits.inc.php
97 if (! empty($_POST['selected_tbl']) && empty($table_select)) {
98 $table_select = $_POST['selected_tbl'];
101 foreach ($tables as $each_table) {
102 if (isset($_POST['table_select']) && is_array($_POST['table_select'])) {
103 $is_checked = $export->getCheckedClause(
105 $_POST['table_select']
107 } elseif (isset($table_select)) {
108 $is_checked = $export->getCheckedClause(
113 $is_checked = ' checked="checked"';
115 if (isset($_POST['table_structure']) && is_array($_POST['table_structure'])) {
116 $structure_checked = $export->getCheckedClause(
118 $_POST['table_structure']
121 $structure_checked = $is_checked;
123 if (isset($_POST['table_data']) && is_array($_POST['table_data'])) {
124 $data_checked = $export->getCheckedClause(
129 $data_checked = $is_checked;
131 $table_html = htmlspecialchars($each_table['Name']);
132 $multi_values .= '<tr class="marked">';
133 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
134 . ' value="' . $table_html . '"' . $is_checked . ' class="checkall"></td>';
135 $multi_values .= '<td class="export_table_name">'
136 . str_replace(' ', ' ', $table_html) . '</td>';
137 $multi_values .= '<td class="export_structure">'
138 . '<input type="checkbox" name="table_structure[]"'
139 . ' value="' . $table_html . '"' . $structure_checked . '></td>';
140 $multi_values .= '<td class="export_data">'
141 . '<input type="checkbox" name="table_data[]"'
142 . ' value="' . $table_html . '"' . $data_checked . '></td>';
143 $multi_values .= '</tr>';
146 $multi_values .= "\n";
147 $multi_values .= '</tbody></table></div>';
149 if (! isset($sql_query)) {
152 if (! isset($num_tables)) {
155 if (! isset($unlim_num_rows)) {
158 if ($multi_values === null) {
161 $response = Response
::getInstance();
162 $displayExport = new DisplayExport();
164 $displayExport->getDisplay(