Backport 32068 - Fixes to get selectboxes working for IE (Stylite #8186)

This commit is contained in:
Nathan Gray 2010-09-14 21:19:58 +00:00
commit 189a7db0fa
5 changed files with 31 additions and 15 deletions

View File

@ -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'] .= '<option ' . ($selected_plugin == $title ? 'selected="selected" ' : '') .
'value="'. $title. '" >'. $title. '</option>';
$response->addScript("selectbox_add_option('exec[definition]','$title', '$value',$selected_plugin == $title);");
}
unset($definition);
}
unset($definitions);
$sel_options['definition'] .= '<option value="expert">' . lang('Expert options') . '</option';
$response->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'] .= '<option value="'. $plugin. '" >'. $plugin_name. '</option>';
$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();
}

View File

@ -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'] .= '<option value="'. $value. '" >'. $title. '</option>';
$response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);");
}
}
$response = new xajaxResponse();
$response->addAssign('exec[definition]','innerHTML',$sel_options['definition']);
return $response->getXML();
}
}

View File

@ -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'] .= '<option value="'. $value. '" >'. $title. '</option>';
$response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);");
}
}
$response = new xajaxResponse();
$response->addAssign('exec[definition]','innerHTML',$sel_options['definition']);
return $response->getXML();
}

View File

@ -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)
{

View File

@ -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;
}
}