Translated using Weblate (Norwegian Bokmål)
[phpmyadmin.git] / db_export.php
blobb04a8b01932a0f9dfcd18f8d26f7ab6a8e2cf81c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * dumps a database
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Config\PageSettings;
9 use PhpMyAdmin\Display\Export as DisplayExport;
10 use PhpMyAdmin\Export;
11 use PhpMyAdmin\Message;
12 use PhpMyAdmin\Response;
13 use PhpMyAdmin\Util;
15 /**
16 * Gets some core libraries
18 require_once 'libraries/common.inc.php';
20 PageSettings::showGroup('Export');
22 $response = Response::getInstance();
23 $header = $response->getHeader();
24 $scripts = $header->getScripts();
25 $scripts->addFile('export.js');
27 // $sub_part is used in Util::getDbInfo() to see if we are coming from
28 // db_export.php, in which case we don't obey $cfg['MaxTableList']
29 $sub_part = '_export';
30 require_once 'libraries/db_common.inc.php';
31 $url_query .= '&amp;goto=db_export.php';
33 list(
34 $tables,
35 $num_tables,
36 $total_num_tables,
37 $sub_part,
38 $is_show_stats,
39 $db_is_system_schema,
40 $tooltip_truename,
41 $tooltip_aliasname,
42 $pos
43 ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
45 /**
46 * Displays the form
48 $export_page_title = __('View dump (schema) of database');
50 // exit if no tables in db found
51 if ($num_tables < 1) {
52 $response->addHTML(
53 Message::error(__('No tables found in database.'))->getDisplay()
55 exit;
56 } // end if
58 $multi_values = '<div class="export_table_list_container">';
59 if (isset($_GET['structure_or_data_forced'])) {
60 $force_val = htmlspecialchars($_GET['structure_or_data_forced']);
61 } else {
62 $force_val = 0;
64 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
65 . $force_val . '">';
66 $multi_values .= '<table class="export_table_select">'
67 . '<thead><tr><th></th>'
68 . '<th>' . __('Tables') . '</th>'
69 . '<th class="export_structure">' . __('Structure') . '</th>'
70 . '<th class="export_data">' . __('Data') . '</th>'
71 . '</tr><tr>'
72 . '<td></td>'
73 . '<td class="export_table_name all">' . __('Select all') . '</td>'
74 . '<td class="export_structure all">'
75 . '<input type="checkbox" id="table_structure_all" /></td>'
76 . '<td class="export_data all"><input type="checkbox" id="table_data_all" />'
77 . '</td>'
78 . '</tr></thead>'
79 . '<tbody>';
80 $multi_values .= "\n";
82 // when called by libraries/mult_submits.inc.php
83 if (!empty($_POST['selected_tbl']) && empty($table_select)) {
84 $table_select = $_POST['selected_tbl'];
87 // Check if the selected tables are defined in $_GET
88 // (from clicking Back button on export.php)
89 foreach (array('table_select', 'table_structure', 'table_data') as $one_key) {
90 if (isset($_GET[$one_key])) {
91 $_GET[$one_key] = urldecode($_GET[$one_key]);
92 $_GET[$one_key] = explode(",", $_GET[$one_key]);
96 foreach ($tables as $each_table) {
97 if (isset($_GET['table_select']) && is_array($_GET['table_select'])) {
98 $is_checked = Export::getCheckedClause(
99 $each_table['Name'], $_GET['table_select']
101 } elseif (isset($table_select)) {
102 $is_checked = Export::getCheckedClause(
103 $each_table['Name'], $table_select
105 } else {
106 $is_checked = ' checked="checked"';
108 if (isset($_GET['table_structure']) && is_array($_GET['table_structure'])) {
109 $structure_checked = Export::getCheckedClause(
110 $each_table['Name'], $_GET['table_structure']
112 } else {
113 $structure_checked = $is_checked;
115 if (isset($_GET['table_data']) && is_array($_GET['table_data'])) {
116 $data_checked = Export::getCheckedClause(
117 $each_table['Name'], $_GET['table_data']
119 } else {
120 $data_checked = $is_checked;
122 $table_html = htmlspecialchars($each_table['Name']);
123 $multi_values .= '<tr class="marked">';
124 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
125 . ' value="' . $table_html . '"' . $is_checked . ' class="checkall"/></td>';
126 $multi_values .= '<td class="export_table_name">'
127 . str_replace(' ', '&nbsp;', $table_html) . '</td>';
128 $multi_values .= '<td class="export_structure">'
129 . '<input type="checkbox" name="table_structure[]"'
130 . ' value="' . $table_html . '"' . $structure_checked . ' /></td>';
131 $multi_values .= '<td class="export_data">'
132 . '<input type="checkbox" name="table_data[]"'
133 . ' value="' . $table_html . '"' . $data_checked . ' /></td>';
134 $multi_values .= '</tr>';
135 } // end for
137 $multi_values .= "\n";
138 $multi_values .= '</tbody></table></div>';
140 if (! isset($sql_query)) {
141 $sql_query = '';
143 if (! isset($num_tables)) {
144 $num_tables = 0;
146 if (! isset($unlim_num_rows)) {
147 $unlim_num_rows = 0;
149 if (! isset($multi_values)) {
150 $multi_values = '';
152 $response = Response::getInstance();
153 $displayExport = new DisplayExport();
154 $response->addHTML(
155 $displayExport->getDisplay(
156 'database', $db, $table, $sql_query, $num_tables,
157 $unlim_num_rows, $multi_values