Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / display_export.lib.php
blob9e162a05e76d865961185198ef5b6fc03b332a55
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays export tab.
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 // Get relations & co. status
13 $cfgRelation = PMA_getRelationsParam();
15 if (isset($_REQUEST['single_table'])) {
16 $GLOBALS['single_table'] = $_REQUEST['single_table'];
19 require_once './libraries/file_listing.lib.php';
20 require_once './libraries/plugin_interface.lib.php';
22 /**
23 * Outputs appropriate checked statement for checkbox.
25 * @param string $str option name
27 * @return void
29 function PMA_exportCheckboxCheck($str)
31 if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
32 echo ' checked="checked"';
36 /* Scan for plugins */
37 $export_list = PMA_getPlugins(
38 "export",
39 'libraries/plugins/export/',
40 array(
41 'export_type' => $export_type,
42 'single_table' => isset($single_table)
46 /* Fail if we didn't find any plugin */
47 if (empty($export_list)) {
48 PMA_Message::error(
49 __('Could not load export plugins, please check your installation!')
50 )->display();
51 exit;
54 echo '<form method="post" action="export.php" name="dump" class="disableAjax">';
56 if ($export_type == 'server') {
57 echo PMA_generate_common_hidden_inputs('', '', 1);
58 } elseif ($export_type == 'database') {
59 echo PMA_generate_common_hidden_inputs($db, '', 1);
60 } else {
61 echo PMA_generate_common_hidden_inputs($db, $table, 1);
64 // just to keep this value for possible next display of this form after saving
65 // on server
66 if (isset($single_table)) {
67 echo '<input type="hidden" name="single_table" value="TRUE" />' . "\n";
70 echo '<input type="hidden" name="export_type" value="' . $export_type . '" />';
71 echo "\n";
73 // If the export method was not set, the default is quick
74 if (isset($_GET['export_method'])) {
75 $cfg['Export']['method'] = $_GET['export_method'];
76 } elseif (! isset($cfg['Export']['method'])) {
77 $cfg['Export']['method'] = 'quick';
79 // The export method (quick, custom or custom-no-form)
80 echo '<input type="hidden" name="export_method" value="'
81 . htmlspecialchars($cfg['Export']['method']) . '" />';
84 if (isset($_GET['sql_query'])) {
85 echo '<input type="hidden" name="sql_query" value="'
86 . htmlspecialchars($_GET['sql_query']) . '" />' . "\n";
87 } elseif (! empty($sql_query)) {
88 echo '<input type="hidden" name="sql_query" value="'
89 . htmlspecialchars($sql_query) . '" />' . "\n";
92 echo '<div class="exportoptions" id="header">';
93 echo '<h2>';
94 echo PMA_Util::getImage('b_export.png', __('Export'));
95 if ($export_type == 'server') {
96 echo __('Exporting databases from the current server');
97 } elseif ($export_type == 'database') {
98 printf(__('Exporting tables from "%s" database'), htmlspecialchars($db));
99 } else {
100 printf(__('Exporting rows from "%s" table'), htmlspecialchars($table));
102 echo '</h2>';
103 echo '</div>';
105 if (isset($_GET['quick_or_custom'])) {
106 $export_method = $_GET['quick_or_custom'];
107 } else {
108 $export_method = $cfg['Export']['method'];
111 echo '<div class="exportoptions" id="quick_or_custom">';
112 echo '<h3>' . __('Export Method:') . '</h3>';
113 echo '<ul>';
114 echo '<li>';
115 echo '<input type="radio" name="quick_or_custom" value="quick" '
116 . ' id="radio_quick_export"';
117 if ($export_method == 'quick' || $export_method == 'quick_no_form') {
118 echo ' checked="checked"';
120 echo ' />';
121 echo '<label for ="radio_quick_export">';
122 echo __('Quick - display only the minimal options');
123 echo '</label>';
124 echo '</li>';
126 echo '<li>';
127 echo '<input type="radio" name="quick_or_custom" value="custom" '
128 . ' id="radio_custom_export"';
129 if ($export_method == 'custom' || $export_method == 'custom_no_form') {
130 echo ' checked="checked"';
132 echo ' />';
133 echo '<label for="radio_custom_export">';
134 echo __('Custom - display all possible options');
135 echo '</label>';
136 echo '</li>';
138 echo '</ul>';
139 echo '</div>';
141 echo '<div class="exportoptions" id="databases_and_tables">';
142 if ($export_type == 'server') {
143 echo '<h3>' . __('Database(s):') . '</h3>';
144 } else if ($export_type == 'database') {
145 echo '<h3>' . __('Table(s):') . '</h3>';
147 if (! empty($multi_values)) {
148 echo $multi_values;
150 echo '</div>';
152 if (strlen($table) && ! isset($num_tables) && ! PMA_Table::isMerge($db, $table)) {
153 echo '<div class="exportoptions" id="rows">';
154 echo '<h3>' . __('Rows:') . '</h3>';
155 echo '<ul>';
156 echo '<li>';
157 echo '<input type="radio" name="allrows" value="0" id="radio_allrows_0"';
158 if (isset($_GET['allrows']) && $_GET['allrows'] == 0) {
159 echo ' checked="checked"';
161 echo '/>';
162 echo '<label for ="radio_allrows_0">' . __('Dump some row(s)') . '</label>';
163 echo '<ul>';
164 echo '<li>';
165 echo '<label for="limit_to">' . __('Number of rows:') . '</label>';
166 echo '<input type="text" id="limit_to" name="limit_to" size="5" value="';
167 if (isset($_GET['limit_to'])) {
168 echo htmlspecialchars($_GET['limit_to']);
169 } elseif (isset($unlim_num_rows)) {
170 echo $unlim_num_rows;
171 } else {
172 echo PMA_Table::countRecords($db, $table);
174 echo '" onfocus="this.select()" />';
175 echo '</li>';
176 echo '<li>';
177 echo '<label for="limit_from">' . __('Row to begin at:') . '</label>';
178 echo '<input type="text" id="limit_from" name="limit_from" value="';
179 if (isset($_GET['limit_from'])) {
180 echo htmlspecialchars($_GET['limit_from']);
181 } else {
182 echo '0';
184 echo '" size="5" onfocus="this.select()" />';
185 echo '</li>';
186 echo '</ul>';
187 echo '</li>';
188 echo '<li>';
189 echo '<input type="radio" name="allrows" value="1" id="radio_allrows_1"';
190 if (! isset($_GET['allrows']) || $_GET['allrows'] == 1) {
191 echo ' checked="checked"';
193 echo '/>';
194 echo ' <label for="radio_allrows_1">' . __('Dump all rows') . '</label>';
195 echo '</li>';
196 echo '</ul>';
197 echo '</div>';
200 if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
201 echo '<div class="exportoptions" id="output_quick_export">';
202 echo '<h3>' . __('Output:') . '</h3>';
203 echo '<ul>';
204 echo '<li>';
205 echo '<input type="checkbox" name="quick_export_onserver" value="saveit" ';
206 echo 'id="checkbox_quick_dump_onserver" ';
207 PMA_exportCheckboxCheck('quick_export_onserver');
208 echo '/>';
209 echo '<label for="checkbox_quick_dump_onserver">';
210 printf(
211 __('Save on server in the directory <b>%s</b>'),
212 htmlspecialchars(PMA_Util::userDir($cfg['SaveDir']))
214 echo '</label>';
215 echo '</li>';
216 echo '<li>';
217 echo '<input type="checkbox" name="quick_export_onserverover" ';
218 echo 'value="saveitover" id="checkbox_quick_dump_onserverover" ';
219 PMA_exportCheckboxCheck('quick_export_onserver_overwrite');
220 echo '/>';
221 echo '<label for="checkbox_quick_dump_onserverover">';
222 echo __('Overwrite existing file(s)');
223 echo '</label>';
224 echo '</li>';
225 echo '</ul>';
226 echo '</div>';
229 echo '<div class="exportoptions" id="output">';
230 echo '<h3>' . __('Output:') . '</h3>';
231 echo '<ul id="ul_output">';
232 echo '<li>';
233 echo '<input type="radio" name="output_format" value="sendit" ';
234 echo 'id="radio_dump_asfile" ';
235 if (!isset($_GET['repopulate'])) {
236 PMA_exportCheckboxCheck('asfile');
238 echo '/>';
239 echo '<label for="radio_dump_asfile">' . __('Save output to a file') . '</label>';
240 echo '<ul id="ul_save_asfile">';
241 if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
242 echo '<li>';
243 echo '<input type="checkbox" name="onserver" value="saveit" ';
244 echo 'id="checkbox_dump_onserver" ';
245 PMA_exportCheckboxCheck('onserver');
246 echo '/>';
247 echo '<label for="checkbox_dump_onserver">';
248 printf(
249 __('Save on server in the directory <b>%s</b>'),
250 htmlspecialchars(PMA_Util::userDir($cfg['SaveDir']))
252 echo '</label>';
253 echo '</li>';
254 echo '<li>';
255 echo '<input type="checkbox" name="onserverover" value="saveitover"';
256 echo ' id="checkbox_dump_onserverover" ';
257 PMA_exportCheckboxCheck('onserver_overwrite');
258 echo '/>';
259 echo '<label for="checkbox_dump_onserverover">';
260 echo __('Overwrite existing file(s)');
261 echo '</label>';
262 echo '</li>';
264 echo '<li>';
265 echo '<label for="filename_template" class="desc">';
266 echo __('File name template:');
267 $trans = new PMA_Message;
268 $trans->addMessage(__('@SERVER@ will become the server name'));
269 if ($export_type == 'database' || $export_type == 'table') {
270 $trans->addMessage(__(', @DATABASE@ will become the database name'));
271 if ($export_type == 'table') {
272 $trans->addMessage(__(', @TABLE@ will become the table name'));
276 $msg = new PMA_Message(
277 __('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.')
279 $msg->addParam(
280 '<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php'))
281 . '" target="documentation" title="' . __('Documentation') . '">',
282 false
284 $msg->addParam('</a>', false);
285 $msg->addParam($trans);
286 $doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
287 $msg->addParam(
288 '<a href="'. $doc_url . '" target="documentation">',
289 false
291 $msg->addParam('</a>', false);
293 echo PMA_Util::showHint($msg);
294 echo '</label>';
295 echo '<input type="text" name="filename_template" id="filename_template" ';
296 echo ' value="';
297 if (isset($_GET['filename_template'])) {
298 echo htmlspecialchars($_GET['filename_template']);
299 } else {
300 if ($export_type == 'database') {
301 echo htmlspecialchars(
302 $GLOBALS['PMA_Config']->getUserValue(
303 'pma_db_filename_template',
304 $GLOBALS['cfg']['Export']['file_template_database']
307 } elseif ($export_type == 'table') {
308 echo htmlspecialchars(
309 $GLOBALS['PMA_Config']->getUserValue(
310 'pma_table_filename_template',
311 $GLOBALS['cfg']['Export']['file_template_table']
314 } else {
315 echo htmlspecialchars(
316 $GLOBALS['PMA_Config']->getUserValue(
317 'pma_server_filename_template',
318 $GLOBALS['cfg']['Export']['file_template_server']
323 echo '"';
324 echo '/>';
325 echo '<input type="checkbox" name="remember_template" ';
326 echo 'id="checkbox_remember_template" ';
327 PMA_exportCheckboxCheck('remember_file_template');
328 echo '/>';
329 echo '<label for="checkbox_remember_template">';
330 echo __('use this for future exports');
331 echo '</label>';
332 echo '</li>';
333 // charset of file
334 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE) {
335 echo ' <li><label for="select_charset_of_file" class="desc">'
336 . __('Character set of the file:') . '</label>' . "\n";
337 reset($cfg['AvailableCharsets']);
338 echo '<select id="select_charset_of_file" name="charset_of_file" size="1">';
339 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
340 echo '<option value="' . $temp_charset . '"';
341 if (isset($_GET['charset_of_file'])
342 && ($_GET['charset_of_file'] != $temp_charset)
344 echo '';
345 } elseif ((empty($cfg['Export']['charset']) && $temp_charset == 'utf-8')
346 || $temp_charset == $cfg['Export']['charset']
348 echo ' selected="selected"';
350 echo '>' . $temp_charset . '</option>';
351 } // end foreach
352 echo '</select></li>';
353 } // end if
355 if (isset($_GET['compression'])) {
356 $selected_compression = $_GET['compression'];
357 } elseif (isset($cfg['Export']['compression'])) {
358 $selected_compression = $cfg['Export']['compression'];
359 } else {
360 $selected_compression = "none";
363 // zip, gzip and bzip2 encode features
364 $is_zip = ($cfg['ZipDump'] && @function_exists('gzcompress'));
365 $is_gzip = ($cfg['GZipDump'] && @function_exists('gzencode'));
366 $is_bzip2 = ($cfg['BZipDump'] && @function_exists('bzcompress'));
367 if ($is_zip || $is_gzip || $is_bzip2) {
368 echo '<li>';
369 echo '<label for="compression" class="desc">' . __('Compression:') . '</label>';
370 echo '<select id="compression" name="compression">';
371 echo '<option value="none">' . __('None') . '</option>';
372 if ($is_zip) {
373 echo '<option value="zip" ';
374 if ($selected_compression == "zip") {
375 echo 'selected="selected"';
377 echo '>' . __('zipped') . '</option>';
379 if ($is_gzip) {
380 echo '<option value="gzip" ';
381 if ($selected_compression == "gzip") {
382 echo 'selected="selected"';
384 echo '>' . __('gzipped') . '</option>';
386 if ($is_bzip2) {
387 echo '<option value="bzip2" ';
388 if ($selected_compression == "bzip2") {
389 echo 'selected="selected"';
391 echo '>' . __('bzipped') . '</option>';
393 echo '</select>';
394 echo '</li>';
395 } else {
396 echo '<input type="hidden" name="compression" value="'
397 . htmlspecialchars($selected_compression) . '" />';
399 echo '</ul>';
400 echo '</li>';
401 echo '<li>';
402 echo '<input type="radio" id="radio_view_as_text" name="output_format" '
403 . 'value="astext" ';
404 if (isset($_GET['repopulate']) || $GLOBALS['cfg']['Export']['asfile'] == false) {
405 echo 'checked="checked"';
407 echo '/>';
408 echo '<label for="radio_view_as_text">'
409 . __('View output as text') . '</label></li>';
410 echo '</ul>';
411 echo '</div>';
413 echo '<div class="exportoptions" id="format">';
414 echo '<h3>' . __('Format:') . '</h3>';
415 echo PMA_pluginGetChoice('Export', 'what', $export_list, 'format');
416 echo '</div>';
418 echo '<div class="exportoptions" id="format_specific_opts">';
419 echo '<h3>' . __('Format-specific options:') . '</h3>';
420 echo '<p class="no_js_msg" id="scroll_to_options_msg">';
421 echo __('Scroll down to fill in the options for the selected format and ignore the options for other formats.');
422 echo '</p>';
423 echo PMA_pluginGetOptions('Export', $export_list);
424 echo '</div>';
426 if (function_exists('PMA_set_enc_form')) {
427 // Encoding setting form appended by Y.Kawada
428 // Japanese encoding setting
429 echo '<div class="exportoptions" id="kanji_encoding">';
430 echo '<h3>' . __('Encoding Conversion:') . '</h3>';
431 echo PMA_set_enc_form(' ');
432 echo '</div>';
435 echo '<div class="exportoptions" id="submit">';
437 echo PMA_Util::getExternalBug(
438 __('SQL compatibility mode'), 'mysql', '50027', '14515'
441 echo '<input type="submit" value="' . __('Go') . '" id="buttonGo" />';
442 echo '</div>';
443 echo '</form>';