bug #2929958 Cannot import (French interface)
[phpmyadmin/last10db.git] / libraries / display_import.lib.php
blob2d854ad4088e3f62c0cd5bc7be7ac4bd401c1605
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
15 require_once './libraries/file_listing.php';
16 require_once './libraries/plugin_interface.lib.php';
17 require_once './libraries/display_import_ajax.lib.php';
19 /* Scan for plugins */
20 $import_list = PMA_getPlugins('./libraries/import/', $import_type);
22 /* Fail if we didn't find any plugin */
23 if (empty($import_list)) {
24 PMA_Message::error('strCanNotLoadImportPlugins')->display();
25 require './libraries/footer.inc.php';
29 <iframe id="import_upload_iframe" name="import_upload_iframe" width="1" height="1" style="display: none" src="import.php"></iframe>
30 <div id="import_form_status" style="display: none;"></div>
31 <div id="importmain">
32 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
33 <script type="text/javascript">
34 //<![CDATA[
35 <!--
36 // Mootools code for handling Ajax requests
37 window.addEvent('load', function() {
38 // webkit fix from 3rd source, but it does not work sometimes (??) --
39 // toms
40 ////////////////////////////// {{{{{
41 Request.HTML.implement({
43 processHTML: function(text) {
44 var match = text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
45 text = (match) ? match[1] : text;
47 var container = new Element('div');
49 return $try(function(){
50 var root = '<root>' + text + '</root>', doc;
51 doc = new DOMParser().parseFromString(root, 'text/html');
52 root = doc.getElementsByTagName('root')[0];
53 for (var i = 0, k = root.childNodes.length; i < k; i++){
54 var child = Element.clone(root.childNodes[i], true, true);
55 if (child) container.grab(child);
57 return container;
58 }) || container.set('html', text);
61 });
63 ////////////////////////// }}}}}
64 // add event when user click on "Go" button
65 $('buttonGo').addEvent('click', function() {
66 $('upload_form_form').setStyle("display", "none"); // hide form
67 $('upload_form_status').setStyle("display", "inline"); // show progress bar
68 $('upload_form_status_info').setStyle("display", "inline"); // - || -
69 <?php
70 if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
72 $('upload_form_status').set('html', '<div class="upload_progress_bar_outer"><div id="status" class="upload_progress_bar_inner"></div></div>'); // add the progress bar
74 var finished = false;
75 var percent = 0.0;
76 var total = 0;
77 var complete = 0;
79 var perform_upload;
80 var periodical_upload;
82 var request_upload = new Request({
83 url: 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>', // the "&" is causing problems for webkit browsers
84 method: 'get',
85 update: 'upload_form_status',
86 onComplete: function(response) {
87 objectsReturned = JSON.decode(response);
89 $each(objectsReturned, function(item, index) {
91 if (index=="finished") {
92 finished = item;
93 if (finished==true) {
94 $clear(periodical_upload);
95 $('importmain').setStyle('display', 'none');
96 $('import_form_status').setStyle('display', 'inline');
97 $('import_form_status').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportProceedingFile; ?> ');
98 $('import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error
99 //]]>
100 <?php
101 // reload the left sidebar when the import is finished
102 $GLOBALS['reload']=true;
103 PMA_reloadNavigation(true);
105 //<![CDATA[
106 } // if [finished==item]
107 } // if [index==finished]
108 if (index=="percent")
109 percent = item;
111 if (index=="total")
112 total = item;
113 if (index=="complete")
114 complete = item;
115 }); // [$each]
116 if (total==0 && complete==0 && percent==0) {
117 $('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat($strImportLargeFileUploading); ?>');
118 $('upload_form_status').setStyle("display", "none");
119 } else {
120 $('upload_form_status_info').set('html', ' '+Math.round(percent)+'%, '+complete+'/'+total);
121 $('status').tween('width', Math.round(percent)*2+'px');
122 } //[else]
123 } //[onComplete]
124 }); // [request]
125 perform_upload = function () {
126 request_upload.send('r=' + $time() + $random(0, 100)); // hack for IE7,8 & webkit (Safari, Chrome, Arora...)
128 periodical_upload = perform_upload.periodical(1000);
129 <?php
130 } else {
132 $('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportUploadInfoNotAvailable; ?>');
133 $('upload_form_status').setStyle("display", "none");
134 <?php
135 } //[else]
137 }); //if [click]
138 }); // if [load]
139 document.write('<form action="import.php" method="post" enctype="multipart/form-data" name="import" <?php if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") echo 'target="import_upload_iframe"'; ?>>');
141 //]]>
142 </script>
143 <noscript>
144 <form action="import.php" method="post" enctype="multipart/form-data" name="import">
145 </noscript>
146 <input type="hidden" name="<?php echo $ID_KEY; ?>" value="<?php echo $upload_id ; ?>" />
147 <?php
148 if ($import_type == 'server') {
149 echo PMA_generate_common_hidden_inputs('', '', 1);
150 } elseif ($import_type == 'database') {
151 echo PMA_generate_common_hidden_inputs($db, '', 1);
152 } else {
153 echo PMA_generate_common_hidden_inputs($db, $table, 1);
155 echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n";
156 echo PMA_pluginGetJavascript($import_list);
158 <fieldset class="options">
159 <legend><?php echo $strFileToImport; ?></legend>
161 <?php
163 if ($GLOBALS['is_upload']) {
164 $uid = uniqid("");
166 <div class="formelementrow" id="upload_form">
167 <div id="upload_form_status" style="display: none;"></div>
168 <div id="upload_form_status_info" style="display: none;"></div>
169 <div id="upload_form_form">
170 <label for="input_import_file"><?php echo $strLocationTextfile; ?></label>
171 <input style="margin: 5px" type="file" name="import_file" id="input_import_file" onchange="match_file(this.value);" />
172 <?php
173 echo PMA_displayMaximumUploadSize($max_upload_size) . "\n";
174 // some browsers should respect this :)
175 echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
177 </div>
178 </div>
179 <?php
180 } else {
181 PMA_Message::warning('strUploadsNotAllowed')->display();
183 if (!empty($cfg['UploadDir'])) {
184 $extensions = '';
185 foreach ($import_list as $key => $val) {
186 if (!empty($extensions)) {
187 $extensions .= '|';
189 $extensions .= $val['extension'];
191 $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
193 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
194 echo '<div class="formelementrow">' . "\n";
195 if ($files === FALSE) {
196 PMA_Message::error('strWebServerUploadDirectoryError')->display();
197 } elseif (!empty($files)) {
198 echo "\n";
199 echo ' <i>' . $strOr . '</i><br/><label for="select_local_import_file">' . $strWebServerUploadDirectory . '</label>&nbsp;: ' . "\n";
200 echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n";
201 echo ' <option value="">&nbsp;</option>' . "\n";
202 echo $files;
203 echo ' </select>' . "\n";
205 echo '</div>' . "\n";
206 } // end if (web-server upload directory)
208 // charset of file
209 echo '<div class="formelementrow">' . "\n";
210 if ($cfg['AllowAnywhereRecoding']) {
211 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>';
212 reset($cfg['AvailableCharsets']);
213 echo '<select id="charset_of_file" name="charset_of_file" size="1">';
214 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
215 echo '<option value="' . htmlentities($temp_charset) . '"';
216 if ((empty($cfg['Import']['charset']) && $temp_charset == $charset)
217 || $temp_charset == $cfg['Import']['charset']) {
218 echo ' selected="selected"';
220 echo '>' . htmlentities($temp_charset) . '</option>';
222 echo ' </select><br />';
223 } else {
224 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
225 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
226 } // end if (recoding)
227 echo '</div>' . "\n";
229 // zip, gzip and bzip2 encode features
230 $compressions = $strNone;
232 if ($cfg['GZipDump'] && @function_exists('gzopen')) {
233 $compressions .= ', gzip';
235 if ($cfg['BZipDump'] && @function_exists('bzopen')) {
236 $compressions .= ', bzip2';
238 if ($cfg['ZipDump'] && @function_exists('zip_open')) {
239 $compressions .= ', zip';
242 // We don't have show anything about compression, when no supported
243 if ($compressions != $strNone) {
244 echo '<div class="formelementrow">' . "\n";
245 printf($strCompressionWillBeDetected, $compressions);
246 echo '</div>' . "\n";
248 echo "\n";
250 </fieldset>
251 <fieldset class="options">
252 <legend><?php echo $strPartialImport; ?></legend>
254 <?php
255 if (isset($timeout_passed) && $timeout_passed) {
256 echo '<div class="formelementrow">' . "\n";
257 echo '<input type="hidden" name="skip" value="' . $offset . '" />';
258 echo sprintf($strTimeoutInfo, $offset) . '';
259 echo '</div>' . "\n";
262 <div class="formelementrow">
263 <input type="checkbox" name="allow_interrupt" value="yes"
264 id="checkbox_allow_interrupt" <?php echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?>/>
265 <label for="checkbox_allow_interrupt"><?php echo $strAllowInterrupt; ?></label><br />
266 </div>
268 <?php
269 if (! (isset($timeout_passed) && $timeout_passed)) {
271 <div class="formelementrow">
272 <label for="text_skip_queries"><?php echo $strSkipQueries; ?></label>
273 <input type="text" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" />
274 </div>
275 <?php
276 } else {
277 // If timeout has passed,
278 // do not show the Skip dialog to avoid the risk of someone
279 // entering a value here that would interfere with "skip"
281 <input type="hidden" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" />
282 <?php
285 </fieldset>
287 <fieldset class="options">
288 <legend><?php echo $strImportFormat; ?></legend>
289 <?php
290 // Let's show format options now
291 echo '<div style="float: left;">';
292 echo PMA_pluginGetChoice('Import', 'format', $import_list);
293 echo '</div>';
295 echo '<div style="float: left;">';
296 echo PMA_pluginGetOptions('Import', $import_list);
297 echo '</div>';
299 <div class="clearfloat"></div>
300 </fieldset>
301 <?php
302 // Encoding setting form appended by Y.Kawada
303 if (function_exists('PMA_set_enc_form')) {
304 echo PMA_set_enc_form(' ');
306 echo "\n";
308 <fieldset class="tblFooters">
309 <input type="submit" value="<?php echo $strGo; ?>" id="buttonGo" />
310 </fieldset>
311 </form>
312 </div>
313 <script type="text/javascript">
314 //<![CDATA[
315 init_options();
316 //]]>
317 </script>