diff --git a/libraries/plugin_interface.lib.php b/libraries/plugin_interface.lib.php
index f4b9888f32..2a83cf0a67 100644
--- a/libraries/plugin_interface.lib.php
+++ b/libraries/plugin_interface.lib.php
@@ -199,13 +199,16 @@ function PMA_pluginGetChoice($section, $name, &$list, $cfgname = null)
$plugin_name = strtolower(substr(get_class($plugin), strlen($section)));
$ret .= ''. "\n";
}
+
return $ret;
}
@@ -439,6 +442,7 @@ function PMA_pluginGetOptions($section, &$list)
$ret .= '
' . PMA_getString($plugin->getProperties()->getText())
. '
';
+ $no_options = true;
if ($plugin->getProperties()->getOptions() != null
&& count($plugin->getProperties()->getOptions()) > 0
) {
diff --git a/libraries/plugins/export/README b/libraries/plugins/export/README
index 3d69bc1bd7..47d0c4fd4f 100644
--- a/libraries/plugins/export/README
+++ b/libraries/plugins/export/README
@@ -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;
}
/**
diff --git a/libraries/plugins/import/ImportCsv.class.php b/libraries/plugins/import/ImportCsv.class.php
index b0cf2e8f67..2817409508 100644
--- a/libraries/plugins/import/ImportCsv.class.php
+++ b/libraries/plugins/import/ImportCsv.class.php
@@ -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 '
- . '(if this is unchecked, the first line will become part of the'
- . ' data)'
+ $leaf = new BoolPropertyItem();
+ $leaf->setName("col_names");
+ $leaf->setText(
+ __(
+ 'The first line of the file contains the table column names'
+ . ' (if this is unchecked, the first line will become part'
+ . ' of the data)'
)
);
+ $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
*
diff --git a/libraries/plugins/import/ImportDocsql.class.php b/libraries/plugins/import/ImportDocsql.class.php
index 17d8288842..e0f440653b 100644
--- a/libraries/plugins/import/ImportDocsql.class.php
+++ b/libraries/plugins/import/ImportDocsql.class.php
@@ -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 = '';
diff --git a/libraries/plugins/import/ImportLdi.class.php b/libraries/plugins/import/ImportLdi.class.php
index 09eab78a12..3780a21e8d 100644
--- a/libraries/plugins/import/ImportLdi.class.php
+++ b/libraries/plugins/import/ImportLdi.class.php
@@ -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
diff --git a/libraries/plugins/import/ImportMediawiki.class.php b/libraries/plugins/import/ImportMediawiki.class.php
index 8ed5e52be7..e6ce2e0e96 100644
--- a/libraries/plugins/import/ImportMediawiki.class.php
+++ b/libraries/plugins/import/ImportMediawiki.class.php
@@ -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;
}
/**
diff --git a/libraries/plugins/import/ImportOds.class.php b/libraries/plugins/import/ImportOds.class.php
index c275de6491..d1879ef0b6 100644
--- a/libraries/plugins/import/ImportOds.class.php
+++ b/libraries/plugins/import/ImportOds.class.php
@@ -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 (if this is unchecked, the first line will become part of the data)')
- ),
- array(
- 'type' => 'bool',
- 'name' => 'empty_rows',
- 'text' => __('Do not import empty rows')
- ),
- array(
- 'type' => 'bool',
- 'name' => 'recognize_percentages',
- 'text' => __('Import percentages as proper decimals (ex. 12.00% to .12)')
- ),
- array(
- 'type' => 'bool',
- 'name' => 'recognize_currency',
- 'text' => __('Import currencies (ex. $5.00 to 5.00)')
- ),
- 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'
+ . ' (if this is unchecked, the first line will become part'
+ . ' of the data)'
+ )
);
+ $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 (ex. 12.00% to .12)'
+ )
+ );
+ $generalOptions->addProperty($leaf);
+ $leaf = new BoolPropertyItem();
+ $leaf->setName("recognize_currency");
+ $leaf->setText(__('Import currencies (ex. $5.00 to 5.00)'));
+ $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;
}
/**
diff --git a/libraries/plugins/import/ImportShp.class.php b/libraries/plugins/import/ImportShp.class.php
index 7f35135e03..e05d368464 100644
--- a/libraries/plugins/import/ImportShp.class.php
+++ b/libraries/plugins/import/ImportShp.class.php
@@ -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)
diff --git a/libraries/plugins/import/ImportSql.class.php b/libraries/plugins/import/ImportSql.class.php
index d25c71139a..5f0f1e0b48 100644
--- a/libraries/plugins/import/ImportSql.class.php
+++ b/libraries/plugins/import/ImportSql.class.php
@@ -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 AUTO_INCREMENT 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 AUTO_INCREMENT 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
diff --git a/libraries/plugins/import/ImportXml.class.php b/libraries/plugins/import/ImportXml.class.php
index 496a4ddc4f..7d84dd2bc4 100644
--- a/libraries/plugins/import/ImportXml.class.php
+++ b/libraries/plugins/import/ImportXml.class.php
@@ -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;
}
/**
diff --git a/libraries/plugins/import/README b/libraries/plugins/import/README
index 8e840658a1..fae847f064 100644
--- a/libraries/plugins/import/README
+++ b/libraries/plugins/import/README
@@ -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;
}
/**
diff --git a/libraries/properties/plugins/ExportPluginProperties.class.php b/libraries/properties/plugins/ExportPluginProperties.class.php
index b8f8465da8..51f9d7da79 100644
--- a/libraries/properties/plugins/ExportPluginProperties.class.php
+++ b/libraries/properties/plugins/ExportPluginProperties.class.php
@@ -55,7 +55,6 @@ class ExportPluginProperties extends PluginPropertyItem
*/
private $_mimeType;
-
/**
* Whether to force or not
*
diff --git a/libraries/properties/plugins/ImportPluginProperties.class.php b/libraries/properties/plugins/ImportPluginProperties.class.php
index 24ff567d61..e377fc7b0d 100644
--- a/libraries/properties/plugins/ImportPluginProperties.class.php
+++ b/libraries/properties/plugins/ImportPluginProperties.class.php
@@ -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;
+ }
}
?>
\ No newline at end of file