Translated using Weblate (Czech)
[phpmyadmin.git] / db_export.php
blob44a2643ced5ad20157f3b061b81d5478a5b7c86c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * dumps a database
6 * @package PhpMyAdmin
7 */
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;
16 use PhpMyAdmin\Util;
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 .= '&amp;goto=db_export.php';
47 list(
48 $tables,
49 $num_tables,
50 $total_num_tables,
51 $sub_part,
52 $is_show_stats,
53 $db_is_system_schema,
54 $tooltip_truename,
55 $tooltip_aliasname,
56 $pos
57 ) = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
59 /**
60 * Displays the form
62 $export_page_title = __('View dump (schema) of database');
64 // exit if no tables in db found
65 if ($num_tables < 1) {
66 $response->addHTML(
67 Message::error(__('No tables found in database.'))->getDisplay()
69 exit;
70 } // end if
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']);
75 } else {
76 $force_val = 0;
78 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
79 . $force_val . '">';
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>'
85 . '</tr><tr>'
86 . '<td></td>'
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">'
91 . '</td>'
92 . '</tr></thead>'
93 . '<tbody>';
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(
104 $each_table['Name'],
105 $_POST['table_select']
107 } elseif (isset($table_select)) {
108 $is_checked = $export->getCheckedClause(
109 $each_table['Name'],
110 $table_select
112 } else {
113 $is_checked = ' checked="checked"';
115 if (isset($_POST['table_structure']) && is_array($_POST['table_structure'])) {
116 $structure_checked = $export->getCheckedClause(
117 $each_table['Name'],
118 $_POST['table_structure']
120 } else {
121 $structure_checked = $is_checked;
123 if (isset($_POST['table_data']) && is_array($_POST['table_data'])) {
124 $data_checked = $export->getCheckedClause(
125 $each_table['Name'],
126 $_POST['table_data']
128 } else {
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(' ', '&nbsp;', $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>';
144 } // end for
146 $multi_values .= "\n";
147 $multi_values .= '</tbody></table></div>';
149 if (! isset($sql_query)) {
150 $sql_query = '';
152 if (! isset($num_tables)) {
153 $num_tables = 0;
155 if (! isset($unlim_num_rows)) {
156 $unlim_num_rows = 0;
158 if ($multi_values === null) {
159 $multi_values = '';
161 $response = Response::getInstance();
162 $displayExport = new DisplayExport();
163 $response->addHTML(
164 $displayExport->getDisplay(
165 'database',
166 $db,
167 $table,
168 $sql_query,
169 $num_tables,
170 $unlim_num_rows,
171 $multi_values