Merge branch 'QA_4_0'
Conflicts: ChangeLog
This commit is contained in:
commit
324e4dbe73
@ -3,6 +3,9 @@ phpMyAdmin - ChangeLog
|
||||
|
||||
4.1.0.0 (not yet released)
|
||||
|
||||
4.0.1.0 (not yet released)
|
||||
- bug #3879 Import broken for CSV using LOAD DATA
|
||||
|
||||
4.0.0.0 (not yet released)
|
||||
+ Patch #3481047 for rfe #3480477 Insert as new row enhancement
|
||||
+ Patch #3480999 Activate codemirror in the query window
|
||||
|
||||
@ -474,7 +474,8 @@ if (! $error) {
|
||||
$import_plugin = PMA_getPlugin(
|
||||
"import",
|
||||
$format,
|
||||
'libraries/plugins/import/'
|
||||
'libraries/plugins/import/',
|
||||
$import_type
|
||||
);
|
||||
if ($import_plugin == null) {
|
||||
$error = true;
|
||||
|
||||
91
libraries/plugins/import/AbstractImportCsv.class.php
Normal file
91
libraries/plugins/import/AbstractImportCsv.class.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Super class of CSV import plugins for phpMyAdmin
|
||||
*
|
||||
* @package PhpMyAdmin-Import
|
||||
* @subpackage CSV
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Get the import interface */
|
||||
require_once 'libraries/plugins/ImportPlugin.class.php';
|
||||
|
||||
/**
|
||||
* Super class of the import plugins for the CSV format
|
||||
*
|
||||
* @package PhpMyAdmin-Import
|
||||
* @subpackage CSV
|
||||
*/
|
||||
abstract class AbstractImportCsv extends ImportPlugin
|
||||
{
|
||||
/**
|
||||
* Sets the import plugin properties.
|
||||
* Called in the constructor.
|
||||
*
|
||||
* @return object OptionsPropertyMainGroup object of the plugin
|
||||
*/
|
||||
protected function setProperties()
|
||||
{
|
||||
$props = 'libraries/properties/';
|
||||
include_once "$props/plugins/ImportPluginProperties.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
|
||||
include_once "$props/options/items/BoolPropertyItem.class.php";
|
||||
include_once "$props/options/items/TextPropertyItem.class.php";
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
// create the root group that will be the options field for
|
||||
// $importPluginProperties
|
||||
// this will be shown as "Format specific options"
|
||||
$importSpecificOptions = new OptionsPropertyRootGroup();
|
||||
$importSpecificOptions->setName("Format Specific Options");
|
||||
|
||||
// general options main group
|
||||
$generalOptions = new OptionsPropertyMainGroup();
|
||||
$generalOptions->setName("general_opts");
|
||||
|
||||
// create common items and add them to the group
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("replace");
|
||||
$leaf->setText(__('Replace table data with file'));
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("terminated");
|
||||
$leaf->setText(__('Columns separated with:'));
|
||||
$leaf->setSize(2);
|
||||
$leaf->setLen(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("enclosed");
|
||||
$leaf->setText(__('Columns enclosed with:'));
|
||||
$leaf->setSize(2);
|
||||
$leaf->setLen(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("escaped");
|
||||
$leaf->setText(__('Columns escaped with:'));
|
||||
$leaf->setSize(2);
|
||||
$leaf->setLen(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("new_line");
|
||||
$leaf->setText(__('Lines terminated with:'));
|
||||
$leaf->setSize(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
// add the main group to the root group
|
||||
$importSpecificOptions->addProperty($generalOptions);
|
||||
|
||||
// set the options for the import plugin property item
|
||||
$importPluginProperties->setOptions($importSpecificOptions);
|
||||
$this->properties = $importPluginProperties;
|
||||
|
||||
return $generalOptions;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/* Get the import interface */
|
||||
require_once 'libraries/plugins/ImportPlugin.class.php';
|
||||
require_once 'libraries/plugins/import/AbstractImportCsv.class.php';
|
||||
|
||||
/**
|
||||
* Handles the import for the CSV format
|
||||
@ -20,7 +20,7 @@ require_once 'libraries/plugins/ImportPlugin.class.php';
|
||||
* @package PhpMyAdmin-Import
|
||||
* @subpackage CSV
|
||||
*/
|
||||
class ImportCsv extends ImportPlugin
|
||||
class ImportCsv extends AbstractImportCsv
|
||||
{
|
||||
/**
|
||||
* Whether to analyze tables
|
||||
@ -51,55 +51,9 @@ class ImportCsv extends ImportPlugin
|
||||
$this->_setAnalyze(true);
|
||||
}
|
||||
|
||||
$props = 'libraries/properties/';
|
||||
include_once "$props/plugins/ImportPluginProperties.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
|
||||
include_once "$props/options/items/BoolPropertyItem.class.php";
|
||||
include_once "$props/options/items/TextPropertyItem.class.php";
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText('CSV');
|
||||
$importPluginProperties->setExtension('csv');
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
// create the root group that will be the options field for
|
||||
// $importPluginProperties
|
||||
// this will be shown as "Format specific options"
|
||||
$importSpecificOptions = new OptionsPropertyRootGroup();
|
||||
$importSpecificOptions->setName("Format Specific Options");
|
||||
|
||||
// general options main group
|
||||
$generalOptions = new OptionsPropertyMainGroup();
|
||||
$generalOptions->setName("general_opts");
|
||||
// create primary items and add them to the group
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("replace");
|
||||
$leaf->setText(__('Replace table data with file'));
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("terminated");
|
||||
$leaf->setText(__('Columns separated with:'));
|
||||
$leaf->setSize(2);
|
||||
$leaf->setLen(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("enclosed");
|
||||
$leaf->setText(__('Columns enclosed with:'));
|
||||
$leaf->setSize(2);
|
||||
$leaf->setLen(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("escaped");
|
||||
$leaf->setText(__('Columns escaped with:'));
|
||||
$leaf->setSize(2);
|
||||
$leaf->setLen(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("new_line");
|
||||
$leaf->setText(__('Lines terminated with:'));
|
||||
$leaf->setSize(2);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$generalOptions = parent::setProperties();
|
||||
$this->properties->setText('CSV');
|
||||
$this->properties->setExtension('csv');
|
||||
|
||||
if ($GLOBALS['plugin_param'] !== 'table') {
|
||||
$leaf = new BoolPropertyItem();
|
||||
@ -129,13 +83,6 @@ class ImportCsv extends ImportPlugin
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
}
|
||||
|
||||
// add the main group to the root group
|
||||
$importSpecificOptions->addProperty($generalOptions);
|
||||
|
||||
// set the options for the import plugin property item
|
||||
$importPluginProperties->setOptions($importSpecificOptions);
|
||||
$this->properties = $importPluginProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +105,7 @@ class ImportCsv extends ImportPlugin
|
||||
*/
|
||||
public function doImport()
|
||||
{
|
||||
global $db, $csv_terminated, $csv_enclosed, $csv_escaped, $csv_new_line;
|
||||
global $db, $table, $csv_terminated, $csv_enclosed, $csv_escaped, $csv_new_line;
|
||||
global $error, $timeout_passed, $finished;
|
||||
|
||||
$replacements = array(
|
||||
|
||||
@ -11,7 +11,7 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/* Get the import interface */
|
||||
require_once 'libraries/plugins/ImportPlugin.class.php';
|
||||
require_once 'libraries/plugins/import/AbstractImportCsv.class.php';
|
||||
|
||||
// We need relations enabled and we work only on database
|
||||
if ($GLOBALS['plugin_param'] !== 'table') {
|
||||
@ -25,7 +25,7 @@ if ($GLOBALS['plugin_param'] !== 'table') {
|
||||
* @package PhpMyAdmin-Import
|
||||
* @subpackage LDI
|
||||
*/
|
||||
class ImportLdi extends ImportPlugin
|
||||
class ImportLdi extends AbstractImportCsv
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
@ -57,39 +57,24 @@ class ImportLdi extends ImportPlugin
|
||||
unset($result);
|
||||
}
|
||||
|
||||
$props = 'libraries/properties/';
|
||||
include_once "$props/plugins/ImportPluginProperties.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
|
||||
include_once "$props/options/items/BoolPropertyItem.class.php";
|
||||
include_once "$props/options/items/TextPropertyItem.class.php";
|
||||
$generalOptions = parent::setProperties();
|
||||
$this->properties->setText('CSV using LOAD DATA');
|
||||
$this->properties->setExtension('ldi');
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText('CSV using LOAD DATA');
|
||||
$importPluginProperties->setExtension('ldi');
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
// create the root group that will be the options field for
|
||||
// $importPluginProperties
|
||||
// this will be shown as "Format specific options"
|
||||
$importSpecificOptions = new OptionsPropertyRootGroup();
|
||||
$importSpecificOptions->setName("Format Specific Options");
|
||||
|
||||
// general options main group
|
||||
$generalOptions = new OptionsPropertyMainGroup();
|
||||
$generalOptions->setName("general_opts");
|
||||
// create primary items and add them to the group
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("replace");
|
||||
$leaf->setText(__('Replace table data with file'));
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("columns");
|
||||
$leaf->setText(__('Column names: '));
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
// add the main group to the root group
|
||||
$importSpecificOptions->addProperty($generalOptions);
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("ignore");
|
||||
$leaf->setText(__('Do not abort on INSERT error'));
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
// set the options for the import plugin property item
|
||||
$importPluginProperties->setOptions($importSpecificOptions);
|
||||
$this->properties = $importPluginProperties;
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("local_option");
|
||||
$leaf->setText(__('Use LOCAL keyword'));
|
||||
$generalOptions->addProperty($leaf);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +97,7 @@ class ImportLdi extends ImportPlugin
|
||||
*/
|
||||
public function doImport()
|
||||
{
|
||||
global $finished, $error, $import_file, $compression, $charset_conversion;
|
||||
global $finished, $error, $import_file, $compression, $charset_conversion, $table;
|
||||
global $ldi_local_option, $ldi_replace, $ldi_terminated, $ldi_enclosed,
|
||||
$ldi_escaped, $ldi_new_line, $skip_queries, $ldi_columns;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user