Translated using Weblate (Slovenian)
[phpmyadmin.git] / db_export.php
blobcfad2ce5d0bce652cd40bef7daf77c46f3a9ab62
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\Display\Export as DisplayExport;
12 use PhpMyAdmin\Export;
13 use PhpMyAdmin\Message;
14 use PhpMyAdmin\Response;
15 use PhpMyAdmin\Util;
17 /**
18 * Gets some core libraries
20 require_once 'libraries/common.inc.php';
22 PageSettings::showGroup('Export');
24 $response = Response::getInstance();
25 $header = $response->getHeader();
26 $scripts = $header->getScripts();
27 $scripts->addFile('export.js');
29 $export = new Export();
31 // $sub_part is used in Util::getDbInfo() to see if we are coming from
32 // db_export.php, in which case we don't obey $cfg['MaxTableList']
33 $sub_part = '_export';
34 require_once 'libraries/db_common.inc.php';
35 $url_query .= '&amp;goto=db_export.php';
37 list(
38 $tables,
39 $num_tables,
40 $total_num_tables,
41 $sub_part,
42 $is_show_stats,
43 $db_is_system_schema,
44 $tooltip_truename,
45 $tooltip_aliasname,
46 $pos
47 ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
49 /**
50 * Displays the form
52 $export_page_title = __('View dump (schema) of database');
54 // exit if no tables in db found
55 if ($num_tables < 1) {
56 $response->addHTML(
57 Message::error(__('No tables found in database.'))->getDisplay()
59 exit;
60 } // end if
62 $multi_values = '<div class="export_table_list_container">';
63 if (isset($_GET['structure_or_data_forced'])) {
64 $force_val = htmlspecialchars($_GET['structure_or_data_forced']);
65 } else {
66 $force_val = 0;
68 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
69 . $force_val . '">';
70 $multi_values .= '<table class="export_table_select">'
71 . '<thead><tr><th></th>'
72 . '<th>' . __('Tables') . '</th>'
73 . '<th class="export_structure">' . __('Structure') . '</th>'
74 . '<th class="export_data">' . __('Data') . '</th>'
75 . '</tr><tr>'
76 . '<td></td>'
77 . '<td class="export_table_name all">' . __('Select all') . '</td>'
78 . '<td class="export_structure all">'
79 . '<input type="checkbox" id="table_structure_all" /></td>'
80 . '<td class="export_data all"><input type="checkbox" id="table_data_all" />'
81 . '</td>'
82 . '</tr></thead>'
83 . '<tbody>';
84 $multi_values .= "\n";
86 // when called by libraries/mult_submits.inc.php
87 if (!empty($_POST['selected_tbl']) && empty($table_select)) {
88 $table_select = $_POST['selected_tbl'];
91 // Check if the selected tables are defined in $_GET
92 // (from clicking Back button on export.php)
93 foreach (array('table_select', 'table_structure', 'table_data') as $one_key) {
94 if (isset($_GET[$one_key])) {
95 $_GET[$one_key] = urldecode($_GET[$one_key]);
96 $_GET[$one_key] = explode(",", $_GET[$one_key]);
100 foreach ($tables as $each_table) {
101 if (isset($_GET['table_select']) && is_array($_GET['table_select'])) {
102 $is_checked = $export->getCheckedClause(
103 $each_table['Name'], $_GET['table_select']
105 } elseif (isset($table_select)) {
106 $is_checked = $export->getCheckedClause(
107 $each_table['Name'], $table_select
109 } else {
110 $is_checked = ' checked="checked"';
112 if (isset($_GET['table_structure']) && is_array($_GET['table_structure'])) {
113 $structure_checked = $export->getCheckedClause(
114 $each_table['Name'], $_GET['table_structure']
116 } else {
117 $structure_checked = $is_checked;
119 if (isset($_GET['table_data']) && is_array($_GET['table_data'])) {
120 $data_checked = $export->getCheckedClause(
121 $each_table['Name'], $_GET['table_data']
123 } else {
124 $data_checked = $is_checked;
126 $table_html = htmlspecialchars($each_table['Name']);
127 $multi_values .= '<tr class="marked">';
128 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
129 . ' value="' . $table_html . '"' . $is_checked . ' class="checkall"/></td>';
130 $multi_values .= '<td class="export_table_name">'
131 . str_replace(' ', '&nbsp;', $table_html) . '</td>';
132 $multi_values .= '<td class="export_structure">'
133 . '<input type="checkbox" name="table_structure[]"'
134 . ' value="' . $table_html . '"' . $structure_checked . ' /></td>';
135 $multi_values .= '<td class="export_data">'
136 . '<input type="checkbox" name="table_data[]"'
137 . ' value="' . $table_html . '"' . $data_checked . ' /></td>';
138 $multi_values .= '</tr>';
139 } // end for
141 $multi_values .= "\n";
142 $multi_values .= '</tbody></table></div>';
144 if (! isset($sql_query)) {
145 $sql_query = '';
147 if (! isset($num_tables)) {
148 $num_tables = 0;
150 if (! isset($unlim_num_rows)) {
151 $unlim_num_rows = 0;
153 if (! isset($multi_values)) {
154 $multi_values = '';
156 $response = Response::getInstance();
157 $displayExport = new DisplayExport();
158 $response->addHTML(
159 $displayExport->getDisplay(
160 'database', $db, $table, $sql_query, $num_tables,
161 $unlim_num_rows, $multi_values