Merge remote-tracking branch 'alex/plugins-and-OOP'
This commit is contained in:
commit
63f3cf7d2f
@ -199,13 +199,16 @@ function PMA_pluginGetChoice($section, $name, &$list, $cfgname = null)
|
||||
$plugin_name = strtolower(substr(get_class($plugin), strlen($section)));
|
||||
$ret .= '<input type="hidden" id="force_file_' . $plugin_name
|
||||
. '" value="';
|
||||
if ($plugin->getProperties()->getForceFile() != null) {
|
||||
if ( ! strcmp($section, 'Import')
|
||||
|| $plugin->getProperties()->getForceFile() != null
|
||||
) {
|
||||
$ret .= 'true';
|
||||
} else {
|
||||
$ret .= 'false';
|
||||
}
|
||||
$ret .= '" />'. "\n";
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -439,6 +442,7 @@ function PMA_pluginGetOptions($section, &$list)
|
||||
$ret .= '<h3>' . PMA_getString($plugin->getProperties()->getText())
|
||||
. '</h3>';
|
||||
|
||||
$no_options = true;
|
||||
if ($plugin->getProperties()->getOptions() != null
|
||||
&& count($plugin->getProperties()->getOptions()) > 0
|
||||
) {
|
||||
|
||||
@ -70,32 +70,56 @@ class Export[Name] extends ExportPlugin
|
||||
*/
|
||||
protected function setProperties()
|
||||
{
|
||||
// optional - get globals
|
||||
|
||||
// set properties
|
||||
$this->properties = array( // set name of your plugin
|
||||
'text' => __('[Name]'), // text to be displayed as choice
|
||||
'extension' => '[ext]', // extension this plugin can handle
|
||||
'options' => array(), // array of options
|
||||
'options_text' => __('Options')
|
||||
);
|
||||
$props = 'libraries/properties/';
|
||||
// include the main class for properties for the export plug-ins
|
||||
include_once "$props/plugins/ExportPluginProperties.class.php";
|
||||
// include the group properties classes
|
||||
include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
|
||||
// include the needed single property items
|
||||
include_once "$props/options/items/RadioPropertyItem.class.php";
|
||||
|
||||
$exportPluginProperties = new ExportPluginProperties();
|
||||
$exportPluginProperties->setText('[name]'); // the name of your plug-in
|
||||
$exportPluginProperties->setExtension('[ext]'); // extension this plug-in can handle
|
||||
$exportPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
// create the root group that will be the options field for
|
||||
// $exportPluginProperties
|
||||
// this will be shown as "Format specific options"
|
||||
$exportSpecificOptions = new OptionsPropertyRootGroup();
|
||||
$exportSpecificOptions->setName("Format Specific Options");
|
||||
|
||||
// general options main group
|
||||
$generalOptions = new OptionsPropertyMainGroup();
|
||||
$generalOptions->setName("general_opts");
|
||||
|
||||
// optional :
|
||||
// type - bool or text, or begin/end group_subgroup
|
||||
// create primary items and add them to the group
|
||||
// type - one of the classes listed in libraries/properties/options/items/
|
||||
// name - form element name
|
||||
// text - description in GUI
|
||||
// size - size of text element (optional)
|
||||
// len - maximal size of input (optional)
|
||||
$this->properties['options'] = array(
|
||||
// size - size of text element
|
||||
// len - maximal size of input
|
||||
// values - possible values of the item
|
||||
$leaf = new RadioPropertyItem();
|
||||
$leaf->setName("structure_or_data");
|
||||
$leaf->setValues(
|
||||
array(
|
||||
'type' => 'begin_group',
|
||||
'name' => 'general_opts'
|
||||
),
|
||||
[..],
|
||||
array(
|
||||
'type' => 'end_group'
|
||||
'structure' => __('structure'),
|
||||
'data' => __('data'),
|
||||
'structure_and_data' => __('structure and data')
|
||||
)
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
// add the main group to the root group
|
||||
$exportSpecificOptions->addProperty($generalOptions);
|
||||
|
||||
// set the options for the export plugin property item
|
||||
$exportPluginProperties->setOptions($exportSpecificOptions);
|
||||
$this->properties = $exportPluginProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -27,7 +27,7 @@ class ImportCsv extends ImportPlugin
|
||||
* @var bool
|
||||
*/
|
||||
private $_analyze;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -50,67 +50,67 @@ class ImportCsv extends ImportPlugin
|
||||
$this->_setAnalyze(true);
|
||||
}
|
||||
|
||||
$this->properties = array(
|
||||
'text' => __('CSV'),
|
||||
'extension' => 'csv',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options')
|
||||
);
|
||||
$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";
|
||||
|
||||
$this->properties['options'] = array(
|
||||
array(
|
||||
'type' => 'begin_group',
|
||||
'name' => 'general_opts'
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'replace',
|
||||
'text' => __('Replace table data with file')
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'ignore',
|
||||
'text' => __('Do not abort on INSERT error')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'terminated',
|
||||
'text' => __('Columns separated with:'),
|
||||
'size' => 2,
|
||||
'len' => 2
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'enclosed',
|
||||
'text' => __('Columns enclosed with:'),
|
||||
'size' => 2,
|
||||
'len' => 2
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'escaped',
|
||||
'text' => __('Columns escaped with:'),
|
||||
'size' => 2,
|
||||
'len' => 2
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'new_line',
|
||||
'text' => __('Lines terminated with:'),
|
||||
'size' => 2
|
||||
)
|
||||
);
|
||||
$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);
|
||||
|
||||
if ($GLOBALS['plugin_param'] !== 'table') {
|
||||
$this->properties['options'][] = array(
|
||||
'type' => 'bool',
|
||||
'name' => 'col_names',
|
||||
'text' => __(
|
||||
'The first line of the file contains the table column names <i>'
|
||||
. '(if this is unchecked, the first line will become part of the'
|
||||
. ' data)</i>'
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("col_names");
|
||||
$leaf->setText(
|
||||
__(
|
||||
'The first line of the file contains the table column names'
|
||||
. ' <i>(if this is unchecked, the first line will become part'
|
||||
. ' of the data)</i>'
|
||||
)
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
} else {
|
||||
$hint = new PMA_Message(
|
||||
__(
|
||||
@ -120,15 +120,21 @@ class ImportCsv extends ImportPlugin
|
||||
. ' and not enclosed in quotations.'
|
||||
)
|
||||
);
|
||||
$this->properties['options'][] = array(
|
||||
'type' => 'text',
|
||||
'name' => 'columns',
|
||||
'text' => __('Column names: ')
|
||||
. PMA_CommonFunctions::getInstance()->showHint($hint)
|
||||
$leaf = new TextPropertyItem();
|
||||
$leaf->setName("columns");
|
||||
$leaf->setText(
|
||||
__('Column names: ')
|
||||
. PMA_CommonFunctions::getInstance()->showHint($hint)
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
}
|
||||
|
||||
$this->properties['options'][] = array('type' => 'end_group');
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,7 +152,7 @@ class ImportCsv extends ImportPlugin
|
||||
|
||||
/**
|
||||
* Handles the whole import logic
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function doImport()
|
||||
@ -499,7 +505,7 @@ class ImportCsv extends ImportPlugin
|
||||
$sql .= ')';
|
||||
|
||||
/**
|
||||
* @todo maybe we could add original line to verbose
|
||||
* @todo maybe we could add original line to verbose
|
||||
* SQL in comment
|
||||
*/
|
||||
PMA_importRunQuery($sql, $sql);
|
||||
@ -597,11 +603,11 @@ class ImportCsv extends ImportPlugin
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the table should be analyzed, false otherwise
|
||||
*
|
||||
|
||||
@ -18,7 +18,7 @@ if ($GLOBALS['plugin_param'] !== 'database') {
|
||||
$GLOBALS['skip_import'] = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the import for the DocSQL format
|
||||
*
|
||||
@ -58,27 +58,38 @@ class ImportDocsql extends ImportPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
$this->properties = array(
|
||||
'text' => __('DocSQL'),
|
||||
'extension' => '',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options'),
|
||||
);
|
||||
$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/TextPropertyItem.class.php";
|
||||
|
||||
$this->properties['options'] = array(
|
||||
array(
|
||||
'type' => 'begin_group',
|
||||
'name' => 'general_opts'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'table',
|
||||
'text' => __('Table name')
|
||||
),
|
||||
array(
|
||||
'type' => 'end_group'
|
||||
)
|
||||
);
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText('DocSQL');
|
||||
$importPluginProperties->setExtension('');
|
||||
$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 TextPropertyItem();
|
||||
$leaf->setName("table");
|
||||
$leaf->setText(__('Table name'));
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +115,7 @@ class ImportDocsql extends ImportPlugin
|
||||
global $error, $timeout_passed, $finished;
|
||||
$cfgRelation = $this->_getCfgRelation();
|
||||
$common_functions = PMA_CommonFunctions::getInstance();
|
||||
|
||||
|
||||
$tab = $_POST['docsql_table'];
|
||||
$buffer = '';
|
||||
|
||||
|
||||
@ -56,71 +56,39 @@ class ImportLdi extends ImportPlugin
|
||||
unset($result);
|
||||
}
|
||||
|
||||
$this->properties = array(
|
||||
'text' => __('CSV using LOAD DATA'),
|
||||
// Following is nonsense, however we want to default to our
|
||||
// parser for csv
|
||||
'extension' => 'ldi',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options'),
|
||||
);
|
||||
$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";
|
||||
|
||||
$this->properties['options'] = array(
|
||||
array(
|
||||
'type' => 'begin_group',
|
||||
'name' => 'general_opts'
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'replace',
|
||||
'text' => __('Replace table data with file')
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'ignore',
|
||||
'text' => __('Do not abort on INSERT error')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'terminated',
|
||||
'text' => __('Columns terminated by'),
|
||||
'size' => 2,
|
||||
'len' => 2
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'enclosed',
|
||||
'text' => __('Columns enclosed by'),
|
||||
'size' => 2,
|
||||
'len' => 2
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'escaped',
|
||||
'text' => __('Columns escaped by'),
|
||||
'size' => 2,
|
||||
'len' => 2
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'new_line',
|
||||
'text' => __('Lines terminated by'),
|
||||
'size' => 2
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'columns',
|
||||
'text' => __('Column names')
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'local_option',
|
||||
'text' => __('Use LOCAL keyword')
|
||||
),
|
||||
array(
|
||||
'type' => 'end_group'
|
||||
)
|
||||
);
|
||||
$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'));
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,9 +114,9 @@ class ImportLdi extends ImportPlugin
|
||||
global $finished, $error, $import_file, $compression, $charset_conversion;
|
||||
global $ldi_local_option, $ldi_replace, $ldi_terminated, $ldi_enclosed,
|
||||
$ldi_escaped, $ldi_new_line, $skip_queries, $ldi_columns;
|
||||
|
||||
|
||||
$common_functions = PMA_CommonFunctions::getInstance();
|
||||
|
||||
|
||||
if ($import_file == 'none'
|
||||
|| $compression != 'none'
|
||||
|| $charset_conversion
|
||||
|
||||
@ -48,13 +48,17 @@ class ImportMediawiki extends ImportPlugin
|
||||
$this->_setAnalyze(true);
|
||||
}
|
||||
|
||||
$this->properties = array(
|
||||
'text' => __('MediaWiki Table'),
|
||||
'extension' => 'txt',
|
||||
'mime_type' => 'text/plain',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options'),
|
||||
);
|
||||
$props = 'libraries/properties/';
|
||||
include_once "$props/plugins/ImportPluginProperties.class.php";
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText(__('MediaWiki Table'));
|
||||
$importPluginProperties->setExtension('txt');
|
||||
$importPluginProperties->setMimeType('text/plain');
|
||||
$importPluginProperties->setOptions(array());
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
$this->properties = $importPluginProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -45,40 +45,59 @@ class ImportOds extends ImportPlugin
|
||||
*/
|
||||
protected function setProperties()
|
||||
{
|
||||
$this->properties = array(
|
||||
'text' => __('Open Document Spreadsheet'),
|
||||
'extension' => 'ods',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options'),
|
||||
);
|
||||
$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";
|
||||
|
||||
$this->properties['options'] = array(
|
||||
array(
|
||||
'type' => 'begin_group',
|
||||
'name' => 'general_opts'
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'col_names',
|
||||
'text' => __('The first line of the file contains the table column names <i>(if this is unchecked, the first line will become part of the data)</i>')
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'empty_rows',
|
||||
'text' => __('Do not import empty rows')
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'recognize_percentages',
|
||||
'text' => __('Import percentages as proper decimals <i>(ex. 12.00% to .12)</i>')
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'recognize_currency',
|
||||
'text' => __('Import currencies <i>(ex. $5.00 to 5.00)</i>')
|
||||
),
|
||||
array('type' => 'end_group')
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText('Open Document Spreadsheet');
|
||||
$importPluginProperties->setExtension('ods');
|
||||
$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("col_names");
|
||||
$leaf->setText(
|
||||
__('The first line of the file contains the table column names'
|
||||
. ' <i>(if this is unchecked, the first line will become part'
|
||||
. ' of the data)</i>'
|
||||
)
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("empty_rows");
|
||||
$leaf->setText(__('Do not import empty rows'));
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("recognize_percentages");
|
||||
$leaf->setText(
|
||||
__(
|
||||
'Import percentages as proper decimals <i>(ex. 12.00% to .12)</i>'
|
||||
)
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("recognize_currency");
|
||||
$leaf->setText(__('Import currencies <i>(ex. $5.00 to 5.00)</i>'));
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -45,12 +45,16 @@ class ImportShp extends ImportPlugin
|
||||
*/
|
||||
protected function setProperties()
|
||||
{
|
||||
$this->properties = array(
|
||||
'text' => __('ESRI Shape File'),
|
||||
'extension' => 'shp',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options'),
|
||||
);
|
||||
$props = 'libraries/properties/';
|
||||
include_once "$props/plugins/ImportPluginProperties.class.php";
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText(__('ESRI Shape File'));
|
||||
$importPluginProperties->setExtension('shp');
|
||||
$importPluginProperties->setOptions(array());
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
$this->properties = $importPluginProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -312,7 +316,7 @@ class ImportShp extends ImportPlugin
|
||||
* Sets $eof when $GLOBALS['finished'] is set and the buffer falls short.
|
||||
*
|
||||
* @param int $length number of bytes
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function readFromBuffer($length)
|
||||
|
||||
@ -36,12 +36,17 @@ class ImportSql extends ImportPlugin
|
||||
*/
|
||||
protected function setProperties()
|
||||
{
|
||||
$this->properties = array(
|
||||
'text' => __('SQL'),
|
||||
'extension' => 'sql',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options'),
|
||||
);
|
||||
$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/SelectPropertyItem.class.php";
|
||||
include_once "$props/options/items/BoolPropertyItem.class.php";
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText('SQL');
|
||||
$importPluginProperties->setExtension('sql');
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
$compats = PMA_DBI_getCompatibilities();
|
||||
if (count($compats) > 0) {
|
||||
@ -49,33 +54,49 @@ class ImportSql extends ImportPlugin
|
||||
foreach ($compats as $val) {
|
||||
$values[$val] = $val;
|
||||
}
|
||||
$this->properties['options'] = array(
|
||||
array('type' => 'begin_group', 'name' => 'general_opts'),
|
||||
|
||||
// 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 SelectPropertyItem();
|
||||
$leaf->setName("compatibility");
|
||||
$leaf->setText(__('SQL compatibility mode:'));
|
||||
$leaf->setValues($values);
|
||||
$leaf->setDoc(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'compatibility',
|
||||
'text' => __('SQL compatibility mode:'),
|
||||
'values' => $values,
|
||||
'doc' => array(
|
||||
'manual_MySQL_Database_Administration',
|
||||
'Server_SQL_mode',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'bool',
|
||||
'name' => 'no_auto_value_on_zero',
|
||||
'text' => __(
|
||||
'Do not use <code>AUTO_INCREMENT</code> for zero values'
|
||||
),
|
||||
'doc' => array(
|
||||
'manual_MySQL_Database_Administration',
|
||||
'Server_SQL_mode',
|
||||
'sqlmode_no_auto_value_on_zero'
|
||||
),
|
||||
),
|
||||
array('type' => 'end_group'),
|
||||
'manual_MySQL_Database_Administration',
|
||||
'Server_SQL_mode',
|
||||
)
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
$leaf = new BoolPropertyItem();
|
||||
$leaf->setName("no_auto_value_on_zero");
|
||||
$leaf->setText(
|
||||
__('Do not use <code>AUTO_INCREMENT</code> for zero values')
|
||||
);
|
||||
$leaf->setDoc(
|
||||
array(
|
||||
'manual_MySQL_Database_Administration',
|
||||
'Server_SQL_mode',
|
||||
'sqlmode_no_auto_value_on_zero'
|
||||
)
|
||||
);
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +114,7 @@ class ImportSql extends ImportPlugin
|
||||
|
||||
/**
|
||||
* Handles the whole import logic
|
||||
*
|
||||
*
|
||||
* @param &$sql_data array 2-element array with sql data
|
||||
*
|
||||
* @return void
|
||||
|
||||
@ -45,13 +45,17 @@ class ImportXml extends ImportPlugin
|
||||
*/
|
||||
protected function setProperties()
|
||||
{
|
||||
$this->properties = array(
|
||||
'text' => __('XML'),
|
||||
'extension' => 'xml',
|
||||
'mime_type' => 'text/xml',
|
||||
'options' => array(),
|
||||
'options_text' => __('Options')
|
||||
);
|
||||
$props = 'libraries/properties/';
|
||||
include_once "$props/plugins/ImportPluginProperties.class.php";
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText(__('XML'));
|
||||
$importPluginProperties->setExtension('xml');
|
||||
$importPluginProperties->setMimeType('text/xml');
|
||||
$importPluginProperties->setOptions(array());
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
$this->properties = $importPluginProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -48,32 +48,56 @@ class Import[Name] extends ImportPlugin
|
||||
*/
|
||||
protected function setProperties()
|
||||
{
|
||||
// optional - get globals
|
||||
|
||||
// set properties
|
||||
$this->properties = array( // set name of your plugin
|
||||
'text' => __('[Name]'), // text to be displayed as choice
|
||||
'extension' => '[ext]', // extension this plugin can handle
|
||||
'options' => array(), // array of options
|
||||
'options_text' => __('Options')
|
||||
);
|
||||
$props = 'libraries/properties/';
|
||||
// include the main class for properties for the import plug-ins
|
||||
include_once "$props/plugins/ImportPluginProperties.class.php";
|
||||
// include the group properties classes
|
||||
include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
|
||||
include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
|
||||
// include the needed single property items
|
||||
include_once "$props/options/items/RadioPropertyItem.class.php";
|
||||
|
||||
$importPluginProperties = new ImportPluginProperties();
|
||||
$importPluginProperties->setText('[name]'); // the name of your plug-in
|
||||
$importPluginProperties->setExtension('[ext]'); // extension this plug-in can handle
|
||||
$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");
|
||||
|
||||
// optional :
|
||||
// type - bool or text, or begin/end group_subgroup
|
||||
// create primary items and add them to the group
|
||||
// type - one of the classes listed in libraries/properties/options/items/
|
||||
// name - form element name
|
||||
// text - description in GUI
|
||||
// size - size of text element (optional)
|
||||
// len - maximal size of input (optional)
|
||||
$this->properties['options'] = array(
|
||||
// size - size of text element
|
||||
// len - maximal size of input
|
||||
// values - possible values of the item
|
||||
$leaf = new RadioPropertyItem();
|
||||
$leaf->setName("structure_or_data");
|
||||
$leaf->setValues(
|
||||
array(
|
||||
'type' => 'begin_group',
|
||||
'name' => 'general_opts'
|
||||
),
|
||||
[..],
|
||||
array(
|
||||
'type' => 'end_group'
|
||||
'structure' => __('structure'),
|
||||
'data' => __('data'),
|
||||
'structure_and_data' => __('structure and data')
|
||||
)
|
||||
);
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -55,7 +55,6 @@ class ExportPluginProperties extends PluginPropertyItem
|
||||
*/
|
||||
private $_mimeType;
|
||||
|
||||
|
||||
/**
|
||||
* Whether to force or not
|
||||
*
|
||||
|
||||
@ -48,6 +48,13 @@ class ImportPluginProperties extends PluginPropertyItem
|
||||
*/
|
||||
private $_optionsText;
|
||||
|
||||
/**
|
||||
* MIME Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_mimeType;
|
||||
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
@ -152,5 +159,27 @@ public function getItemType()
|
||||
{
|
||||
$this->_optionsText = $optionsText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the MIME type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
return $this->_mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the MIME type
|
||||
*
|
||||
* @param string $mimeType MIME type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMimeType($mimeType)
|
||||
{
|
||||
$this->_mimeType = $mimeType;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user