|
170 | 170 | $_SESSION['throttle_import'] = !empty($_POST['throttle_import']) ? sprintf('%d', $_POST['throttle_import']) : 0; |
171 | 171 | } |
172 | 172 |
|
| 173 | +if (isset($_GET['delimiter'])) { |
| 174 | + // Reprocess the file using the selected delimiter |
| 175 | + $_SESSION['import_field_delimiter'] = $_GET['delimiter']; |
| 176 | + $_SESSION['import_attribute'] = []; |
| 177 | + unset($_GET['delimiter']); |
| 178 | +} |
| 179 | + |
173 | 180 | if (!empty($_GET['confirm'])) { |
174 | 181 | $_SESSION['test_import'] = ''; |
175 | 182 | } |
|
354 | 361 | } |
355 | 362 | if ($request_mapping) { |
356 | 363 | $ls->addButton($GLOBALS['I18N']->get('Continue'), 'javascript:document.importform.submit()'); |
| 364 | + |
| 365 | + if (count($headers) == 1) { |
| 366 | + // try to identify the actual field delimiter from commonly-used values |
| 367 | + if (preg_match('/([,;:|])/', $headers[0], $matches)) { |
| 368 | + $delimiter = $matches[1]; |
| 369 | + $warning = s( |
| 370 | + "The file appears to be using '%s' as the field delimiter. Click Resubmit to use '%s' as the delimiter.", |
| 371 | + $delimiter, |
| 372 | + $delimiter |
| 373 | + ); |
| 374 | + $url = sprintf('import2&delimiter=%s', urlencode($delimiter)); |
| 375 | + printf('<p class="information">%s</p>%s', $warning, PageLinkButton($url, s('Resubmit'))); |
| 376 | + } else { |
| 377 | + $warning = s('The entered field delimiter might not be correct.'); |
| 378 | + printf('<p class="information">%s</p>', $warning); |
| 379 | + } |
| 380 | + } |
357 | 381 | echo '<p class="information">'.$GLOBALS['I18N']->get('Please identify the target of the following unknown columns').'</p>'; |
358 | 382 | echo '<form name="importform" method="post">'; |
359 | 383 | echo $ls->display(); |
|
0 commit comments