another minor fix to prior commit
[openemr.git] / phpmyadmin / db_export.php
blob6cf1be8b5ee83d0e9bc5299e94ac1d63073563dc
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * dumps a database
6 * @package PhpMyAdmin
7 */
9 /**
10 * Gets some core libraries
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/config/page_settings.class.php';
14 require_once 'libraries/export.lib.php';
16 PMA_PageSettings::showGroup('Export');
18 $response = PMA_Response::getInstance();
19 $header = $response->getHeader();
20 $scripts = $header->getScripts();
21 $scripts->addFile('export.js');
23 // $sub_part is used in PMA_Util::getDbInfo() to see if we are coming from
24 // db_export.php, in which case we don't obey $cfg['MaxTableList']
25 $sub_part = '_export';
26 require_once 'libraries/db_common.inc.php';
27 $url_query .= '&amp;goto=db_export.php';
29 list(
30 $tables,
31 $num_tables,
32 $total_num_tables,
33 $sub_part,
34 $is_show_stats,
35 $db_is_system_schema,
36 $tooltip_truename,
37 $tooltip_aliasname,
38 $pos
39 ) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
41 /**
42 * Displays the form
44 $export_page_title = __('View dump (schema) of database');
46 // exit if no tables in db found
47 if ($num_tables < 1) {
48 PMA_Message::error(__('No tables found in database.'))->display();
49 exit;
50 } // end if
52 $multi_values = '<div class="export_table_list_container">';
53 if (isset($_GET['structure_or_data_forced'])) {
54 $force_val = htmlspecialchars($_GET['structure_or_data_forced']);
55 } else {
56 $force_val = 0;
58 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
59 . $force_val . '">';
60 $multi_values .= '<table class="export_table_select">'
61 . '<thead><tr><th></th>'
62 . '<th>' . __('Tables') . '</th>'
63 . '<th class="export_structure">' . __('Structure') . '</th>'
64 . '<th class="export_data">' . __('Data') . '</th>'
65 . '</tr><tr>'
66 . '<td></td>'
67 . '<td class="export_table_name all">' . __('Select all') . '</td>'
68 . '<td class="export_structure all">'
69 . '<input type="checkbox" id="table_structure_all" /></td>'
70 . '<td class="export_data all"><input type="checkbox" id="table_data_all" />'
71 . '</td>'
72 . '</tr></thead>'
73 . '<tbody>';
74 $multi_values .= "\n";
76 // when called by libraries/mult_submits.inc.php
77 if (!empty($_POST['selected_tbl']) && empty($table_select)) {
78 $table_select = $_POST['selected_tbl'];
81 // Check if the selected tables are defined in $_GET
82 // (from clicking Back button on export.php)
83 foreach (array('table_select', 'table_structure', 'table_data') as $one_key) {
84 if (isset($_GET[$one_key])) {
85 $_GET[$one_key] = urldecode($_GET[$one_key]);
86 $_GET[$one_key] = explode(",", $_GET[$one_key]);
90 foreach ($tables as $each_table) {
91 if (isset($_GET['table_select'])) {
92 $is_checked = PMA_getCheckedClause(
93 $each_table['Name'], $_GET['table_select']
95 } elseif (isset($table_select)) {
96 $is_checked = PMA_getCheckedClause(
97 $each_table['Name'], $table_select
99 } else {
100 $is_checked = ' checked="checked"';
102 if (isset($_GET['table_structure'])) {
103 $structure_checked = PMA_getCheckedClause(
104 $each_table['Name'], $_GET['table_structure']
106 } else {
107 $structure_checked = $is_checked;
109 if (isset($_GET['table_data'])) {
110 $data_checked = PMA_getCheckedClause(
111 $each_table['Name'], $_GET['table_data']
113 } else {
114 $data_checked = $is_checked;
116 $table_html = htmlspecialchars($each_table['Name']);
117 $multi_values .= '<tr>';
118 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
119 . ' value="' . $table_html . '"' . $is_checked . ' /></td>';
120 $multi_values .= '<td class="export_table_name">'
121 . str_replace(' ', '&nbsp;', $table_html) . '</td>';
122 $multi_values .= '<td class="export_structure">'
123 . '<input type="checkbox" name="table_structure[]"'
124 . ' value="' . $table_html . '"' . $structure_checked . ' /></td>';
125 $multi_values .= '<td class="export_data">'
126 . '<input type="checkbox" name="table_data[]"'
127 . ' value="' . $table_html . '"' . $data_checked . ' /></td>';
128 $multi_values .= '</tr>';
129 } // end for
131 $multi_values .= "\n";
132 $multi_values .= '</tbody></table></div>';
134 $export_type = 'database';
135 require_once 'libraries/display_export.inc.php';