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\Di\Container
;
13 use PhpMyAdmin\Display\Export
as DisplayExport
;
14 use PhpMyAdmin\Export
;
15 use PhpMyAdmin\Message
;
16 use PhpMyAdmin\Response
;
19 if (! defined('ROOT_PATH')) {
20 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
23 require_once ROOT_PATH
. 'libraries/common.inc.php';
25 $container = Container
::getDefaultContainer();
26 $container->set(Response
::class, Response
::getInstance());
28 /** @var Response $response */
29 $response = $container->get(Response
::class);
31 /** @var DatabaseInterface $dbi */
32 $dbi = $container->get(DatabaseInterface
::class);
34 PageSettings
::showGroup('Export');
36 $header = $response->getHeader();
37 $scripts = $header->getScripts();
38 $scripts->addFile('export.js');
40 $export = new Export($dbi);
42 // $sub_part is used in Util::getDbInfo() to see if we are coming from
43 // db_export.php, in which case we don't obey $cfg['MaxTableList']
44 $sub_part = '_export';
45 require_once ROOT_PATH
. 'libraries/db_common.inc.php';
46 $url_query .= '&goto=db_export.php';
58 ) = Util
::getDbInfo($db, is_null($sub_part) ?
'' : $sub_part);
63 $export_page_title = __('View dump (schema) of database');
65 // exit if no tables in db found
66 if ($num_tables < 1) {
68 Message
::error(__('No tables found in database.'))->getDisplay()
73 $multi_values = '<div class="export_table_list_container">';
74 if (isset($_POST['structure_or_data_forced'])) {
75 $force_val = htmlspecialchars($_POST['structure_or_data_forced']);
79 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
81 $multi_values .= '<table class="export_table_select">'
82 . '<thead><tr><th></th>'
83 . '<th>' . __('Tables') . '</th>'
84 . '<th class="export_structure">' . __('Structure') . '</th>'
85 . '<th class="export_data">' . __('Data') . '</th>'
88 . '<td class="export_table_name all">' . __('Select all') . '</td>'
89 . '<td class="export_structure all">'
90 . '<input type="checkbox" id="table_structure_all"></td>'
91 . '<td class="export_data all"><input type="checkbox" id="table_data_all">'
95 $multi_values .= "\n";
97 // when called by libraries/mult_submits.inc.php
98 if (! empty($_POST['selected_tbl']) && empty($table_select)) {
99 $table_select = $_POST['selected_tbl'];
102 foreach ($tables as $each_table) {
103 if (isset($_POST['table_select']) && is_array($_POST['table_select'])) {
104 $is_checked = $export->getCheckedClause(
106 $_POST['table_select']
108 } elseif (isset($table_select)) {
109 $is_checked = $export->getCheckedClause(
114 $is_checked = ' checked="checked"';
116 if (isset($_POST['table_structure']) && is_array($_POST['table_structure'])) {
117 $structure_checked = $export->getCheckedClause(
119 $_POST['table_structure']
122 $structure_checked = $is_checked;
124 if (isset($_POST['table_data']) && is_array($_POST['table_data'])) {
125 $data_checked = $export->getCheckedClause(
130 $data_checked = $is_checked;
132 $table_html = htmlspecialchars($each_table['Name']);
133 $multi_values .= '<tr class="marked">';
134 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
135 . ' value="' . $table_html . '"' . $is_checked . ' class="checkall"></td>';
136 $multi_values .= '<td class="export_table_name">'
137 . str_replace(' ', ' ', $table_html) . '</td>';
138 $multi_values .= '<td class="export_structure">'
139 . '<input type="checkbox" name="table_structure[]"'
140 . ' value="' . $table_html . '"' . $structure_checked . '></td>';
141 $multi_values .= '<td class="export_data">'
142 . '<input type="checkbox" name="table_data[]"'
143 . ' value="' . $table_html . '"' . $data_checked . '></td>';
144 $multi_values .= '</tr>';
147 $multi_values .= "\n";
148 $multi_values .= '</tbody></table></div>';
150 if (! isset($sql_query)) {
153 if (! isset($num_tables)) {
156 if (! isset($unlim_num_rows)) {
159 if (is_null($multi_values)) {
162 $response = Response
::getInstance();
163 $displayExport = new DisplayExport();
165 $displayExport->getDisplay(