diff --git a/importexport/inc/class.importexport_export_ui.inc.php b/importexport/inc/class.importexport_export_ui.inc.php
index b26a8ecfec..d06de90df0 100644
--- a/importexport/inc/class.importexport_export_ui.inc.php
+++ b/importexport/inc/class.importexport_export_ui.inc.php
@@ -35,6 +35,7 @@ class importexport_export_ui {
public function __construct() {
$this->js = $GLOBALS['egw']->js = is_object($GLOBALS['egw']->js) ? $GLOBALS['egw']->js : CreateObject('phpgwapi.javascript');
$this->js->validate_file('.','export_dialog','importexport');
+ $this->js->validate_file('.','importexport','importexport');
$this->user = $GLOBALS['egw_info']['user']['user_id'];
$this->export_plugins = importexport_helper_functions::get_plugins('all','export');
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
@@ -278,24 +279,23 @@ class importexport_export_ui {
'type' => 'export',
'application' => $_appname
));
+ $response->addScript("clear_options('exec[definition]');");
foreach ((array)$definitions->get_definitions() as $identifier) {
$definition = new importexport_definition($identifier);
if ($title = $definition->get_title()) {
if (!$selected_plugin) $selected_plugin = $title;
- $sel_options['definition'] .= '';
+ $response->addScript("selectbox_add_option('exec[definition]','$title', '$value',$selected_plugin == $title);");
}
unset($definition);
}
unset($definitions);
- $sel_options['definition'] .= 'addScript("selectbox_add_option('exec[definition]','" . lang('Expert options') . "', 'expert',$selected_plugin == $title);");
if($selected_plugin == 'expert') {
$this->ajax_get_plugins($_appname, $response);
} else {
$response->addScript("set_style_by_class('tr','select_plugin','display','none');");
}
- $response->addAssign('exec[definition]','innerHTML',$sel_options['definition']);
$response->addScript('export_dialog.change_definition(document.getElementById("exec[definition]"));');
$response->addScript("set_style_by_class('tr','select_definition','display','table-row');");
return $no_return ? '' : $response->getXML();
@@ -314,15 +314,15 @@ class importexport_export_ui {
(array)$plugins = importexport_helper_functions::get_plugins($_appname,'export');
$sel_options['plugin'] = '';
+ $response->addScript("clear_options('exec[plugin]');");
foreach ($plugins[$_appname]['export'] as $plugin => $plugin_name) {
if (!$selected_plugin) $selected_plugin = $plugin;
- $sel_options['plugin'] .= '';
+ $response->addScript("selectbox_add_option('exec[plugin]','$plugin_name', '$plugin',$selected_plugin == $plugin);");
}
$this->ajax_get_plugin_description($selected_plugin,$response);
$this->ajax_get_plugin_options($selected_plugin, $response, $_definition);
$this->ajax_get_plugin_selectors($selected_plugin, $response, $_definition);
- $response->addAssign('exec[plugin]','innerHTML',$sel_options['plugin']);
$response->addScript("set_style_by_class('tr','select_plugin','display','table-row');");
return $no_return ? '' : $response->getXML();
}
diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php
index 92018c529c..4c2c30d144 100644
--- a/importexport/inc/class.importexport_import_ui.inc.php
+++ b/importexport/inc/class.importexport_import_ui.inc.php
@@ -78,6 +78,7 @@
$sel_options = self::get_select_options($data);
$data['message'] = $this->message;
+ $GLOBALS['egw']->js->validate_file('.','importexport','importexport');
$template = new etemplate('importexport.import_dialog');
$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
@@ -120,13 +121,13 @@
*/
public function ajax_get_definitions($appname, $file=null) {
$options = self::get_select_options(array('appname'=>$appname, 'file'=>$file));
+ $response = new xajaxResponse();
+ $response->addScript("clear_options('exec[definition]');");
if(is_array($options['definition'])) {
foreach ($options['definition'] as $value => $title) {
- $sel_options['definition'] .= '';
+ $response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);");
}
}
- $response = new xajaxResponse();
- $response->addAssign('exec[definition]','innerHTML',$sel_options['definition']);
return $response->getXML();
}
}
diff --git a/importexport/inc/class.importexport_schedule_ui.inc.php b/importexport/inc/class.importexport_schedule_ui.inc.php
index b74e711313..27bff10230 100644
--- a/importexport/inc/class.importexport_schedule_ui.inc.php
+++ b/importexport/inc/class.importexport_schedule_ui.inc.php
@@ -111,6 +111,7 @@
}
$sel_options = self::get_select_options($data);
+ $GLOBALS['egw']->js->validate_file('.','importexport','importexport');
$GLOBALS['egw_info']['flags']['app_header'] = lang('Schedule import / export');
$this->template->read('importexport.schedule_edit');
@@ -203,8 +204,9 @@
$response = new xajaxResponse();
}
$options = self::get_select_options(array('type' => $type, 'appname'=>$appname));
- if(is_array($options['plugins'])) {
- foreach ($options['plugins'] as $value => $title) {
+ $response->addScript("clear_options('exec[plugin]');");
+ if(is_array($options['plugin'])) {
+ foreach ($options['plugin'] as $value => $title) {
$response->addScript("selectbox_add_option('exec[plugin]','$title', '$value',false);");
}
}
@@ -216,13 +218,13 @@
*/
public function ajax_get_definitions($appname, $plugin) {
$options = self::get_select_options(array('appname'=>$appname, 'plugin'=>$plugin));
+ $response = new xajaxResponse();
+ $response->addScript("clear_options('exec[definition]');");
if(is_array($options['definition'])) {
foreach ($options['definition'] as $value => $title) {
- $sel_options['definition'] .= '';
+ $response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);");
}
}
- $response = new xajaxResponse();
- $response->addAssign('exec[definition]','innerHTML',$sel_options['definition']);
return $response->getXML();
}
diff --git a/importexport/inc/class.importexport_wizard_basic_import_csv.inc.php b/importexport/inc/class.importexport_wizard_basic_import_csv.inc.php
index fa96d540b9..8e07478c6d 100644
--- a/importexport/inc/class.importexport_wizard_basic_import_csv.inc.php
+++ b/importexport/inc/class.importexport_wizard_basic_import_csv.inc.php
@@ -185,7 +185,7 @@ class importexport_wizard_basic_import_csv
array_shift($content['csv_fields']);
// Need to move everything down 1 to remove header, but shift will re-key
unset($content['field_mapping'][0]);
- unset($content['field_conversion'][0]);
+ if(is_array($content['field_conversion'])) unset($content['field_conversion'][0]);
foreach(array('field_mapping', 'field_conversion') as $field) {
foreach($content[$field] as $key => $value)
{
diff --git a/importexport/js/importexport.js b/importexport/js/importexport.js
new file mode 100644
index 0000000000..8366b2e0c4
--- /dev/null
+++ b/importexport/js/importexport.js
@@ -0,0 +1,13 @@
+/**
+* Common functions for import / export
+*/
+
+/**
+* Clear a selectbox
+*/
+function clear_options(id) {
+ var list = document.getElementById(id);
+ for(var count = list.options.length - 1; count >= 0; count--) {
+ list.options[count] = null;
+ }
+}