Adapt importexport for etemplate2

This commit is contained in:
Nathan Gray 2013-11-01 22:04:43 +00:00
parent 1e786ec974
commit 7f98f428a0
30 changed files with 719 additions and 559 deletions

View File

@ -16,6 +16,7 @@ require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_textbox.inc
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_grid.inc.php'; require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_grid.inc.php';
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_checkbox.inc.php'; require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_checkbox.inc.php';
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.contact_widget.inc.php'; require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.contact_widget.inc.php';
include_once EGW_INCLUDE_ROOT.'/importexport/inc/class.importexport_widget_filter.inc.php';
/** /**
* eTemplate widget baseclass * eTemplate widget baseclass

View File

@ -60,8 +60,7 @@ class importexport_definitions_ui
$GLOBALS['egw']->translation->add_app(self::_appname); $GLOBALS['egw']->translation->add_app(self::_appname);
$GLOBALS['egw_info']['flags']['currentapp'] = self::_appname; $GLOBALS['egw_info']['flags']['currentapp'] = self::_appname;
$GLOBALS['egw_info']['flags']['include_xajax'] = true; $this->etpl = new etemplate_new();
$this->etpl = new etemplate();
$this->clock = html::image(self::_appname,'clock'); $this->clock = html::image(self::_appname,'clock');
$this->steps = array( $this->steps = array(
'wizard_step10' => lang('Choose an application'), 'wizard_step10' => lang('Choose an application'),
@ -163,7 +162,6 @@ class importexport_definitions_ui
'no_cat' => true, 'no_cat' => true,
'no_filter' => true, 'no_filter' => true,
'no_filter2' => true, 'no_filter2' => true,
'header_right' => 'importexport.definition_index.add',
'csv_fields' => false, // Disable CSV export, uses own export 'csv_fields' => false, // Disable CSV export, uses own export
'default_cols' => '!actions', // switch legacy actions column and row off by default 'default_cols' => '!actions', // switch legacy actions column and row off by default
'row_id' => 'definition_id', 'row_id' => 'definition_id',
@ -189,7 +187,7 @@ class importexport_definitions_ui
} }
if($msg) $content['msg'] = $msg; if($msg) $content['msg'] = $msg;
$etpl = new etemplate(self::_appname.'.definition_index'); $etpl = new etemplate_new(self::_appname.'.definition_index');
return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv );
} }
@ -489,32 +487,19 @@ class importexport_definitions_ui
function wizard($content = null, $msg='') function wizard($content = null, $msg='')
{ {
$GLOBALS['egw_info']['flags']['java_script'] .=
"<script type='text/javascript'>
function xajax_eT_wrapper_init() {
//window.resizeTo(document.documentElement.scrollWidth+20,document.documentElement.offsetHeight+40);
window.moveTo(screen.availWidth/2 - window.outerWidth/2,
screen.availHeight/2 - window.outerHeight/2);
}
</script>";
$this->etpl->read('importexport.wizardbox'); $this->etpl->read('importexport.wizardbox');
$this->wizard_content_template =& $this->etpl->children[0]['data'][1]['A'][2][1]['name'];
if(is_array($content) &&! $content['edit']) if(is_array($content) &&! $content['edit'])
{ {
if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true));
foreach($content as $key => $val) error_log(" $key : ".array2string($val));
// fetch plugin object // fetch plugin object
if($content['plugin'] && $content['application']) if($content['plugin'] && $content['application'])
{ {
$wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']); $wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']);
// we need to deal with the wizard object if exists // we need to deal with the wizard object if exists
if (file_exists(EGW_SERVER_ROOT . '/'. $content['application'].'/importexport/class.wizard_'. $content['plugin'].'.inc.php')) if (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php"))
{
error_log('Deprecated location for importexport wizard. Please move it to app/inc/ and rename it to follow new conventions');
}
elseif (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php"))
{ {
$wizard_plugin = $wizard_name; $wizard_plugin = $wizard_name;
} }
@ -539,7 +524,8 @@ class importexport_definitions_ui
} }
// post process submitted step // post process submitted step
if($content['step']) { if($content['step'])
{
if(!$this->can_edit($content)) if(!$this->can_edit($content))
{ {
// Each step changes definition, reload it // Each step changes definition, reload it
@ -549,30 +535,28 @@ class importexport_definitions_ui
} }
if(!key_exists($content['step'],$this->steps)) if(!key_exists($content['step'],$this->steps))
{ {
$next_step = $this->plugin->$content['step']($content); $next_step = $this->plugin->$content['step']($content,$sel_options,$readonlys,$preserv);
} }
else else
{ {
$next_step = $this->$content['step']($content); $next_step = $this->$content['step']($content,$sel_options,$readonlys,$preserv);
} }
} else { }
else
{
die('Cannot find next step'); die('Cannot find next step');
} }
// pre precess next step // pre precess next step
$sel_options = $readonlys = $preserv = array(); $sel_options = $readonlys = $preserv = array();
// Override next button on step 30, to do a regular submit for the file upload
if($next_step == 'wizard_step30')
{
$this->etpl->set_cell_attribute('button[next]', 'onclick', '');
}
// Disable finish button if required fields are missing // Disable finish button if required fields are missing
if(!$content['name'] || !$content['type'] || !$content['plugin']) { if(!$content['name'] || !$content['type'] || !$content['plugin'])
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][finish]');"); {
$readonlys['button[finish]'] = true;
} }
do { do
{
if(!key_exists($next_step,$this->steps)) if(!key_exists($next_step,$this->steps))
{ {
$this->wizard_content_template = $this->plugin->$next_step($content,$sel_options,$readonlys,$preserv); $this->wizard_content_template = $this->plugin->$next_step($content,$sel_options,$readonlys,$preserv);
@ -598,20 +582,24 @@ class importexport_definitions_ui
{ {
$readonlys[$this->wizard_content_template] = true; $readonlys[$this->wizard_content_template] = true;
$preserve = $content; $preserve = $content;
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][finish]');"); $readonlys['button[finish]'] = true;
} }
$html = $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,1); unset($content['button']);
$content['wizard_content'] = $this->wizard_content_template;
error_log('------- STARTING EXEC --------');
$this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv);
error_log('------- DONE EXEC --------');
} }
else else
{ {
// initial content // initial content
$GLOBALS['egw']->js->set_onload("xajax_eT_wrapper_init();");
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][previous]');");
$sel_options = $readonlys = $preserv = array(); $sel_options = $readonlys = $preserv = array();
$readonlys['button[previous]'] = true;
if($content['edit']) if($content['edit'])
{
unset ($content['edit']); unset ($content['edit']);
}
$this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv); $this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv);
@ -619,62 +607,11 @@ class importexport_definitions_ui
{ {
$readonlys[$this->wizard_content_template] = true; $readonlys[$this->wizard_content_template] = true;
$preserve = $content; $preserve = $content;
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][finish]');"); $readonlys['button[finish]'] = true;
} }
$html = $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,1); $content['wizard_content'] = $this->wizard_content_template;
} $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv);
if(class_exists('xajaxResponse'))
{
$this->response = new xajaxResponse();
egw_framework::include_css_js_response();
if ($content['closewindow'])
{
$this->response->addScript("opener.location.reload();");
$this->response->addScript("window.close();");
// If Browser can't close window we display a "close" buuton and
// need to disable normal buttons
$this->response->addAssign('exec[button][previous]','style.display', 'none');
$this->response->addAssign('exec[button][next]','style.display', 'none');
$this->response->addAssign('exec[button][finish]','style.display', 'none');
$this->response->addAssign('exec[button][cancel]','style.display', 'none');
}
$this->response->addAssign('contentbox', 'innerHTML', $html);
if (($onload = $GLOBALS['egw']->js->set_onload('')))
{
$this->response->addScript($onload);
}
$this->response->addAssign('picturebox', 'style.display', 'none');
$this->response->addScript("set_style_by_class('div','popupManual','display','inline');
popup_resize();
");
return $this->response->getXML();
}
else
{
$GLOBALS['egw']->js->set_onload("document.getElementById('picturebox').style.display = 'none';");
egw_framework::validate_file('.', 'etemplate', 'etemplate');
egw_framework::validate_file('.', 'etemplate', 'etemplate');
common::egw_header();
echo '<div id="divMain">'."\n";
echo '<div><h3>{Im|Ex}port Wizard</h3></div>';
// adding a manual icon to every popup
if ($GLOBALS['egw_info']['user']['apps']['manual'])
{
$manual = new etemplate('etemplate.popup.manual');
echo $manual->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,1);
unset($manual);
}
echo '<div id="contentbox">';
echo $html;
echo '</div></div>'."\n";
echo '<style type="text/css">#picturebox { position: absolute; right: 27px; top: 24px; }</style>'."\n";
echo '<div id="picturebox">'. $this->clock. '</div>';
return;
} }
} }
@ -735,7 +672,7 @@ class importexport_definitions_ui
$sel_options['application'][$appname] = lang($appname); $sel_options['application'][$appname] = lang($appname);
} }
} }
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][previous]');"); $readonlys['button[previous]'] = true;
$content['step'] = 'wizard_step10'; $content['step'] = 'wizard_step10';
$preserv = $content; $preserv = $content;
unset ($preserv['button']); unset ($preserv['button']);
@ -766,9 +703,7 @@ class importexport_definitions_ui
return $this->get_step($content['step'],1); return $this->get_step($content['step'],1);
case 'previous' : case 'previous' :
unset ($content['plugin']); unset ($content['plugin']);
if(is_object($this->response)) { $readonlys['button[previous]'] = true;
$this->response->addScript("disable_button('exec[button][previous]');");
}
return $this->get_step($content['step'],-1); return $this->get_step($content['step'],-1);
case 'finish': case 'finish':
return 'wizard_finish'; return 'wizard_finish';
@ -900,8 +835,9 @@ class importexport_definitions_ui
// Set owner for non-admins // Set owner for non-admins
$content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']); $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']);
//if(!$GLOBALS['egw_info']['user']['apps']['admin'] && !$GLOBALS['egw']->acl->check('share_definition', EGW_ACL_READ, 'importexport')) { $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0',$content['allowed_users']) || $content['allowed_users'] == 'all';
if(!$GLOBALS['egw']->acl->check('share_definition', EGW_ACL_READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) { if(!$GLOBALS['egw']->acl->check('share_definition', EGW_ACL_READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin'])
{
$content['allowed_users'] = array(); $content['allowed_users'] = array();
$readonlys['allowed_users'] = true; $readonlys['allowed_users'] = true;
$readonlys['just_me'] = true; $readonlys['just_me'] = true;
@ -919,10 +855,8 @@ class importexport_definitions_ui
$content['no_all_users'] = true; $content['no_all_users'] = true;
} }
unset ($preserv['button']); unset ($preserv['button']);
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][next]');");
if(is_object($this->response)) { $readonlys['button[next]'] = true;
$this->response->addAssign('exec[button][next]','style.display', 'none');
}
return 'importexport.wizard_chooseallowedusers'; return 'importexport.wizard_chooseallowedusers';
} }
} }
@ -939,7 +873,8 @@ class importexport_definitions_ui
$bodefinitions->save($content); $bodefinitions->save($content);
// This message is displayed if browser cant close window // This message is displayed if browser cant close window
$content['msg'] = lang('ImportExport wizard finished successfully!'); $content['msg'] = lang('ImportExport wizard finished successfully!');
$content['closewindow'] = true; egw_framework::refresh_opener('','importexport');
egw_framework::window_close();
return 'importexport.wizard_close'; return 'importexport.wizard_close';
} }

View File

@ -48,7 +48,7 @@ class importexport_export_ui {
$readonlys = array(); $readonlys = array();
$preserv = array(); $preserv = array();
$et = new etemplate(self::_appname. '.export_dialog'); $et = new etemplate_new(self::_appname. '.export_dialog');
$_appname = $_content['appname'] ? $_content['appname'] : $_GET['appname']; $_appname = $_content['appname'] ? $_content['appname'] : $_GET['appname'];
$_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition']; $_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition'];
$_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin']; $_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin'];
@ -68,7 +68,7 @@ class importexport_export_ui {
$content['appname'] = $_appname; $content['appname'] = $_appname;
$preserv['appname'] = $_appname; $preserv['appname'] = $_appname;
if(empty($_appname)) { if(empty($_appname)) {
$this->js->set_onload('$j("tr.select_definition").css("display","none");'); $et.setElementAttribute('select_definition','disabled',true);
} }
// Check for preferred definition // Check for preferred definition
@ -148,7 +148,7 @@ class importexport_export_ui {
if(!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; if(!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter'];
$sel_options['delimiter'][$content['delimiter']] = lang('Use default') . ' "' . $sel_options['delimiter'][$content['delimiter']] . '"'; $sel_options['delimiter'][$content['delimiter']] = lang('Use default') . ' "' . $sel_options['delimiter'][$content['delimiter']] . '"';
if(!$_content['delimiter']) $this->js->set_onload('jQuery(\'[other_delimiter]\').hide();'); if(!$_content['delimiter']) $et->setElementAttribute('other_delimiter','disabled',true);
// Other delimiter (options) // Other delimiter (options)
if($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter']; if($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter'];
@ -223,11 +223,6 @@ class importexport_export_ui {
} }
} }
} }
} elseif (!$_selection) {
$this->js->set_onload("
disable_button('exec[preview]');
disable_button('exec[export]');
");
} }
$preserv['old_definition'] = $content['definition']; $preserv['old_definition'] = $content['definition'];
@ -258,19 +253,13 @@ class importexport_export_ui {
if(!$_application && !$selected_plugin) { if(!$_application && !$selected_plugin) {
$content['plugin_selectors_html'] = $content['plugin_options_html'] = $content['plugin_selectors_html'] = $content['plugin_options_html'] =
lang('You need to select an app and format first!'); lang('You need to select an app and format first!');
$this->js->set_onload("document.getElementById('importexport.export_dialog.options_tab-tab').style.visibility='hidden';"); $readonlys[$tabs] = array('selection_tab' => true, 'options_tab' => true);
$this->js->set_onload("document.getElementById('importexport.export_dialog.selection_tab-tab').style.visibility='hidden';");
} }
// disable preview box if($_content['preview'] || $_content['export'])
$this->js->set_onload('$j(\'tr.preview-box\').hide();');
//xajax_eT_wrapper submit
if(class_exists('xajaxResponse'))
{ {
//error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true)); //error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true));
$response = new xajaxResponse(); $response = egw_json_response::get();
if ($_content['definition'] == 'expert') { if ($_content['definition'] == 'expert') {
$definition = new importexport_definition(); $definition = new importexport_definition();
@ -294,7 +283,7 @@ class importexport_export_ui {
// Set filter // Set filter
// Note that because not all dates are DB dates, the plugin has to handle them // Note that because not all dates are DB dates, the plugin has to handle them
$filter = $definition->filter; $filter = array();
if(is_array($_content['filter'])) if(is_array($_content['filter']))
{ {
foreach($_content['filter'] as $key => $value) foreach($_content['filter'] as $key => $value)
@ -317,6 +306,8 @@ class importexport_export_ui {
} }
} }
} }
error_log(array2string($filter));
unset($_content['filter']); unset($_content['filter']);
$definition->filter = $filter; $definition->filter = $filter;
@ -326,8 +317,8 @@ class importexport_export_ui {
); );
if(!$definition->plugin_options['selection']) { if(!$definition->plugin_options['selection']) {
$response->addScript('alert("' . lang('No records selected') . '");'); $response->alert( lang('No records selected'));
return $response->getXML(); return;
} }
$tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export'); $tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export');
@ -352,11 +343,6 @@ class importexport_export_ui {
if(is_object($result) && method_exists($result, 'get_num_of_records')) if(is_object($result) && method_exists($result, 'get_num_of_records'))
{ {
$record_count = $result->get_num_of_records(); $record_count = $result->get_num_of_records();
if($record_count == 0)
{
$response->addScript('alert("' . lang('No matching records') . '");');
return $response->getXML();
}
} }
// Store charset to use in header // Store charset to use in header
@ -365,7 +351,6 @@ class importexport_export_ui {
if($_content['export'] == 'pressed') { if($_content['export'] == 'pressed') {
fclose($file); fclose($file);
$filename = pathinfo($tmpfname, PATHINFO_FILENAME); $filename = pathinfo($tmpfname, PATHINFO_FILENAME);
$response->addScript("xajax_eT_wrapper();");
$link_query = array( $link_query = array(
'menuaction' => 'importexport.importexport_export_ui.download', 'menuaction' => 'importexport.importexport_export_ui.download',
'_filename' => $filename, '_filename' => $filename,
@ -379,9 +364,9 @@ class importexport_export_ui {
{ {
$link_query['filename'] = $plugin_filename; $link_query['filename'] = $plugin_filename;
} }
$response->addScript("opener.location.href='". $GLOBALS['egw']->link('/index.php',$link_query)."'"); $response->redirect( $GLOBALS['egw']->link('/index.php',$link_query),true);
$response->addScript('window.setTimeout("window.close();", 100);'); egw_framework::window_close();
return $response->getXML(); return;
} }
elseif($_content['preview'] == 'pressed') { elseif($_content['preview'] == 'pressed') {
fseek($file, 0); fseek($file, 0);
@ -392,7 +377,7 @@ class importexport_export_ui {
'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
$replace = $preview = ''; $replace = $preview = '';
while(!feof($file) && $item_count < 10) { while(!feof($file) && $item_count < 30) {
$preview .= preg_replace($search,$replace,fgets($file,1024)); $preview .= preg_replace($search,$replace,fgets($file,1024));
$item_count++; $item_count++;
} }
@ -406,15 +391,10 @@ class importexport_export_ui {
$GLOBALS['egw']->translation->charset() $GLOBALS['egw']->translation->charset()
); );
if($record_count) $preview = "<div class='header'>".lang('Preview') . "<span class='count'>".(int)$record_count."</span></div>".$preview;
{
$preview = "<div class='header'>".lang('Preview') . "<span class='count'>$record_count</span></div>".$preview;
}
$response->addAssign('exec[preview-box]','innerHTML',nl2br($preview));
$response->jquery('.preview_box','show');
$response->addScript("xajax_eT_wrapper();"); $et->setElementAttribute('preview-box', 'value', nl2br($preview));
return $response->getXML(); return;
} }
//nothing else expected! //nothing else expected!
throw new Exception('Error: unexpected submit in export_dialog!'); throw new Exception('Error: unexpected submit in export_dialog!');
@ -441,7 +421,6 @@ class importexport_export_ui {
'type' => 'export', 'type' => 'export',
'application' => $_appname 'application' => $_appname
)); ));
$response->addScript("clear_options('exec[definition]');");
foreach ((array)$definitions->get_definitions() as $identifier) { foreach ((array)$definitions->get_definitions() as $identifier) {
try { try {
$definition = new importexport_definition($identifier); $definition = new importexport_definition($identifier);
@ -457,109 +436,33 @@ class importexport_export_ui {
} }
unset($definitions); unset($definitions);
$response->addScript("selectbox_add_option('exec[definition]','" . lang('Expert options') . "', 'expert',".($selected_plugin == $title ? 'true' : 'false').");"); $response->addScript("selectbox_add_option('exec[definition]','" . lang('Expert options') . "', 'expert',".($selected_plugin == $title ? 'true' : 'false').");");
if($selected_plugin == 'expert') {
$this->ajax_get_plugins($_appname, $response);
} else {
$response->jquery('tr.select_plugin','hide');
}
$response->addScript('export_dialog.change_definition(document.getElementById("exec[definition]"));');
$response->addScript('$j("tr.select_definition").css("display","table-row");');
return $no_return ? '' : $response->getXML();
} }
public function ajax_get_plugins($_appname, xajaxResponse &$response = null) { public function ajax_get_definition_description($_definition) {
if(!is_null($response)) {
$no_return = true;
} else {
$response = new xajaxResponse();
}
if (!$_appname) {
$response->jquery('tr.select_plugin','hide');
return $no_return ? '' : $response->getXML();
}
(array)$plugins = importexport_helper_functions::get_plugins($_appname,'export'); $_response = egw_json_response::get();
$sel_options['plugin'] = ''; $description = '';
$response->addScript("clear_options('exec[plugin]');"); if ($_definition)
foreach ($plugins[$_appname]['export'] as $plugin => $plugin_name) { {
if (!$selected_plugin) $selected_plugin = $plugin;
$response->addScript("selectbox_add_option('exec[plugin]','$plugin_name', '$plugin',".($selected_plugin == $plugin ? 'true' : 'false').");");
}
$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->addScript('$j("tr.select_plugin").css("display","table-row");');
return $no_return ? '' : $response->getXML();
}
public function ajax_get_definition_description($_definition, xajaxResponse &$response=null) {
$no_return = !is_null($response);
if(is_null($response)) {
$response = new xajaxResponse();
}
if (!$_definition) return $response->getXML();
$_object = new importexport_definition($_definition); $_object = new importexport_definition($_definition);
if (is_a($_object, 'importexport_definition')) { if (is_a($_object, 'importexport_definition')) {
$description = $_object->description; $description = $_object->description;
$response->assign('exec[plugin_description]','innerHTML',$description);
} }
unset ($_object); unset ($_object);
}
return $no_return ? '' : $response->getXML(); $_response->assign('importexport-export_dialog_plugin_description','innerHTML',$description);
} }
public function ajax_get_plugin_description($_plugin,&$_response=false) { public function ajax_get_plugin_description($_plugin) {
$no_return = !is_null($_response); $_respone = egw_json_response::get();
if(is_null($_response)) {
$_response = new xajaxResponse();
}
if (!$_plugin) return $no_return ? '' : $response->getXML();
$plugin_object = new $_plugin; $plugin_object = new $_plugin;
if (is_a($plugin_object, 'importexport_iface_export_plugin')) { if (is_a($plugin_object, 'importexport_iface_export_plugin')) {
$description = $plugin_object->get_description(); $description = $plugin_object->get_description();
$_response->addAssign('exec[plugin_description]','innerHTML',$description);
if (isset($definition->plugin_options['selection'])) {
$_response->addScript("document.getElementById('importexport.export_dialog.selection_tab-tab').style.visibility='hidden';");
}
$this->ajax_get_plugin_options($_plugin, $_response);
}
unset ($plugin_object);
return $no_return ? '' : $response->getXML();
}
public function ajax_get_plugin_options($_plugin,&$response=false, $definition = '') {
$no_return = !is_null($response);
if(is_null($response)) {
$response = new xajaxResponse();
}
if (!$_plugin) return $no_return ? '' : $response->getXML();
$plugin_object = new $_plugin;
if (is_a($plugin_object, 'importexport_iface_export_plugin')) {
$options = $plugin_object->get_options_etpl();
ob_start();
$template = new etemplate($options);
/*
$template->exec('importexport.importexport_export_ui.dialog', array(), array(), array(), array(), 2);
$html = ob_get_clean();
ob_end_clean();
*/
$html = $template->exec('importexport.importexport_export_ui.dialog', array(), array(), array(), array(), 1);
$html = preg_replace('|<input.+id="etemplate_exec_id".*/>|',
'',
$html
);
$response->addAssign('importexport.export_dialog.options_tab', 'innerHTML', $html);
} }
$_response->addAssign('importexport-export_dialog_plugin_description','innerHTML',$description);
unset ($plugin_object); unset ($plugin_object);
return $no_return ? '' : $response->getXML();
} }
/** /**
@ -594,40 +497,4 @@ class importexport_export_ui {
// Try to avoid any extra finishing output // Try to avoid any extra finishing output
common::egw_exit(); common::egw_exit();
} }
public function ajax_get_plugin_selectors($_plugin,&$response=false, $definition = '') {
$no_return = !is_null($response);
if(is_null($response)) {
$response = new xajaxResponse();
}
if (!$_plugin) return $no_return ? '' : $response->getXML();
$plugin_object = new $_plugin;
if (is_a($plugin_object, 'importexport_iface_export_plugin')) {
$options = $plugin_object->get_selectors_etpl();
ob_start();
etemplate::$name_vars='exec';
$template = new etemplate($options);
$html = $template->exec('importexport.importexport_export_ui.dialog', array(), array(), array(), array(), 1);
//$html = ob_get_clean();
ob_end_clean();
$pattern = array(
'|<input.+id="etemplate_exec_id".*/>|',
'|<input(.+)name="exec[0-9]*\[|'
);
$html = preg_replace($pattern,
array('', '<input\\1name="exec['),
$html
);
$response->addAssign('importexport.export_dialog.selection_tab', 'innerHTML', $html);
}
unset ($plugin_object);
return $no_return ? '' : $response->getXML();
}
public function ajax_get_template($_name) {
}
} // end class uiexport } // end class uiexport

View File

@ -633,19 +633,19 @@ class importexport_helper_functions {
// This isn't quite right - there's only 2 options and you can select both // This isn't quite right - there's only 2 options and you can select both
$settings['type'] = 'select-bool'; $settings['type'] = 'select-bool';
$settings['rows'] = 1; $settings['rows'] = 1;
$settings['enhance'] = true; $settings['tags'] = true;
break; break;
case 'select-cat': case 'select-cat':
$settings['rows'] = "5,,,$app_name"; $settings['rows'] = "5,,,$app_name";
$settings['enhance'] = true; $settings['tags'] = true;
break; break;
case 'select-account': case 'select-account':
$settings['rows'] = '5,both'; $settings['rows'] = '5,both';
$settings['enhance'] = true; $settings['tags'] = true;
break; break;
case 'select': case 'select':
$settings['rows'] = 5; $settings['rows'] = 5;
$settings['enhance'] = true; $settings['tags'] = true;
break; break;
} }
} }

View File

@ -43,6 +43,8 @@
$appname = $_GET['appname'] ? $_GET['appname'] : $content['appname']; $appname = $_GET['appname'] ? $_GET['appname'] : $content['appname'];
$definition = $_GET['definition'] ? $_GET['definition'] : $content['definition']; $definition = $_GET['definition'] ? $_GET['definition'] : $content['definition'];
$template = new etemplate_new('importexport.import_dialog');
// Load application's translations // Load application's translations
if($appname) if($appname)
{ {
@ -115,10 +117,15 @@
$this->message .= '<b>' . lang('Import aborted').":</b><br />\n"; $this->message .= '<b>' . lang('Import aborted').":</b><br />\n";
$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
} }
if(count($check_message))
{
$this->message .= implode($check_message, "<br />\n") . "<br />\n"; $this->message .= implode($check_message, "<br />\n") . "<br />\n";
}
if($content['dry-run']) if($content['dry-run'])
{ {
echo $this->preview($plugin, $file, $definition_obj); $preview = $this->preview($plugin, $file, $definition_obj);
$template->setElementAttribute('preview', 'value', $preview);
if(trim($this->message) == '') return;
} }
else else
{ {
@ -138,7 +145,10 @@
$this->message .= lang('%1 records processed', $count); $this->message .= lang('%1 records processed', $count);
// Refresh opening window // Refresh opening window
if(!$content['dry-run']) $GLOBALS['egw']->js->set_onload("window.opener.egw_refresh('".lang('%1 records processed',$count) . "','$appname',null,null,'$appname');"); if(!$content['dry-run'])
{
egw_framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
}
$total_processed = 0; $total_processed = 0;
foreach($plugin->get_results() as $action => $a_count) { foreach($plugin->get_results() as $action => $a_count) {
$this->message .= "<br />\n" . lang($action) . ": $a_count"; $this->message .= "<br />\n" . lang($action) . ": $a_count";
@ -197,7 +207,6 @@
if($_GET['appname']) $readonlys['appname'] = true; if($_GET['appname']) $readonlys['appname'] = true;
$template = new etemplate('importexport.import_dialog');
$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2); $template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
} }
@ -317,7 +326,7 @@
if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
$this->message .= "<br />\n"; $this->message .= "<br />\n";
} }
return '<h2>' . lang('Preview') . ' - ' . $plugin->get_name() . '</h2>' . $preview; return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview;
} }
/** /**

View File

@ -26,7 +26,7 @@
protected static $template; protected static $template;
public function __construct() { public function __construct() {
$this->template = new etemplate(); $this->template = new etemplate_new();
} }
public function index($content = array()) { public function index($content = array()) {

View File

@ -21,68 +21,55 @@
* *
* Most text fields are ignored. * Most text fields are ignored.
*/ */
class filter_widget extends customfields_widget class importexport_widget_filter extends etemplate_widget_transformer
{ {
public $prefix = ''; protected static $prefix = '';
public $human_name = array(
'filter' => 'Import|Export filter' protected static $transformation = array(
'type' => 'customfields'
); );
public function __construct($ui, $appname = null)
{
$this->advanced_search = true;
parent::__construct($ui, $appname);
}
/** /**
* pre-processing of the extension * Adapt the settings to custom fields widget
* *
* This function is called before the extension gets rendered * @param string $cname
*
* @param string $form_name form-name of the control
* @param mixed &$value value / existing content, can be modified
* @param array &$cell array with the widget, can be modified for ui-independent widgets
* @param array &$readonlys names of widgets as key, to be made readonly
* @param mixed &$extension_data data the extension can store persisten between pre- and post-process
* @param etemplate &$tmpl reference to the template we belong too
* @return boolean true if extra label is allowed, false otherwise
*/ */
public function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,$tmpl) public function beforeSendToClient($cname)
{ {
$form_name = self::form_name($cname, $this->id);
if($this->getElementAttribute($form_name, 'customfields'))
{
// Already done?
return;
}
$value =& self::get_array(self::$request->content, $form_name, true);
$fields = $value['fields']; $fields = $value['fields'];
unset($value['fields']); unset($value['fields']);
$relative_dates = $this->attrs['relative_dates'];
list($relative_dates) = explode(',',$cell['size']); $this->setElementAttribute($form_name, 'prefix', self::$prefix);
if($cell['relative_dates']) $relative_dates = true;
// Fallback, so there's something there... // Fallback, so there's something there...
if(!is_array($fields)) if(!is_array($fields))
{ {
$cell['type'] = 'label'; error_log("$this has no fields");
$cell['label'] = 'No fields'; self::$transformation = array(
return True; 'type' => 'label',
'label' => 'No fields'
);
return parent::beforeSendToClient($cname);
} }
error_log(array2string(array_keys($fields)));
// making the cell an empty grid
$cell['type'] = 'grid';
$cell['data'] = array(array());
$cell['rows'] = $cell['cols'] = 0;
$cell['size'] = '';
$n = 1; $n = 1;
foreach($fields as $lname => $field) foreach($fields as $lname => &$field)
{ {
$new_row = null; boetemplate::add_child($cell,$new_row); $type =& $field['type'];
$row_class = 'row';
boetemplate::add_child($cell,$label =& boetemplate::empty_cell('label','',array(
'label' => $field['label'],
'no_lang' => substr(lang($field['label']),-1) == '*' ? 2 : 0,
'span' => $field['type'] === 'label' ? '2' : '',
)));
switch($field['type']) // No filters are required
$field['needed'] = false;
switch($type)
{ {
case 'date': case 'date':
case 'date-time': case 'date-time':
@ -90,7 +77,13 @@ class filter_widget extends customfields_widget
$options = ''; $options = '';
if($relative_dates) if($relative_dates)
{ {
$input = self::do_relative_date($lname, $value, $options, $readonly); $type = 'select';
$field['values'] = array('', lang('all'));
foreach(importexport_helper_functions::$relative_dates as $label => $values)
{
$field['values'][$label] = lang($label);
}
$this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'tags', TRUE);
} }
else else
{ {
@ -119,19 +112,7 @@ class filter_widget extends customfields_widget
} }
$options = array_merge($options, array_intersect_key($field['values'], array_flip(ajax_select_widget::$known_options))); $options = array_merge($options, array_intersect_key($field['values'], array_flip(ajax_select_widget::$known_options)));
$input = boetemplate::empty_cell('ajax_select', $lname, array(
'readonly' => $readonly,
'no_lang' => True,
'size' => $options
));
break;
case 'link-entry':
$input =& boetemplate::empty_cell('link-entry',$this->prefix.$lname,array(
'size' => $field['type'] == 'link-entry' ? '' : $field['type'],
));
// register post-processing of link widget to get eg. needed/required validation
etemplate_old::$request->set_to_process(etemplate_old::form_name($form_name,$this->prefix.$lname), 'ext-link');
break; break;
case 'select': case 'select':
default: default:
@ -151,51 +132,37 @@ class filter_widget extends customfields_widget
// We don't want the 'All' or 'Select...' if it's there // We don't want the 'All' or 'Select...' if it's there
unset($field['values']['']); unset($field['values']['']);
$this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'empty_label', '');
$input =& boetemplate::empty_cell($field['type'],$lname,array( $this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'tags', TRUE);
'sel_options' => $field['values'], $this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'multiple', TRUE);
'size' => $field['rows'],
'enhance' => true,
'no_lang' => True,
));
} }
elseif (in_array($field['type'], array_keys(egw_link::app_list()))) else
{ {
// Link entry to a specific app
$input =& boetemplate::empty_cell('link-entry',$lname,array(
'size' => $field['type'] == 'link-entry' ? '' : $field['type'],
));
// register post-processing of link widget to get eg. needed/required validation
etemplate_old::$request->set_to_process(etemplate_old::form_name($form_name,$lname), 'ext-link');
} else {
error_log('Trying to filter with unsupported field type: ' . $field['type']); error_log('Trying to filter with unsupported field type: ' . $field['type']);
$input =& boetemplate::empty_cell($field['type'],$lname,array( }
'sel_options' => $field['values'],
'size' => $field['rows'],
'no_lang' => True,
));
} }
} error_log($type);
$cell['data'][0]['c'.$n++] = $row_class.',top';
if (!is_null($input)) $widget = self::factory($type, '<'.$type.' type="'.$type.'" id="'.self::$prefix.$lname.'"/>', self::$prefix.$lname);
if(method_exists($widget, 'beforeSendToClient'))
{ {
if ($readonly) $input['readonly'] = true; $widget->id = self::$prefix.$lname;
$widget->attrs['type'] = $type;
$input['needed'] = $cell['needed'] || $field['needed']; if($type == 'link-to')
if (!empty($field['help']) && $row_class != 'th')
{ {
$input['help'] = $field['help']; $widget->attrs['only_app'] = $field['type'];
$input['no_lang'] = substr(lang($help),-1) == '*' ? 2 : 0;
} }
boetemplate::add_child($cell,$input); $widget->beforeSendToClient($cname);
unset($input);
} }
unset($label); unset($widget);
} }
$this->setElementAttribute($form_name, 'customfields', $fields);
$this->setElementAttribute($form_name, 'fields',array_fill_keys(array_keys($fields), true));
error_log($this);
parent::beforeSendToClient($cname);
return false; return false;
} }
@ -258,4 +225,24 @@ error_log('Trying to filter with unsupported field type: ' . $field['type']);
boetemplate::add_child($input, $to); boetemplate::add_child($input, $to);
return $input; return $input;
} }
public function validate($cname, array $expand, array $content, &$validated=array())
{
$form_name = self::form_name($cname, $this->id, $expand);
error_log('Validating ' . $form_name);
if (!$this->is_readonly($cname, $form_name))
{
$value_in = self::get_array($content, $form_name);
$valid =& self::get_array($validated, $this->id ? $form_name : $field, true);
foreach($value_in as $key => $value)
{
// Client side cf widget automatically prefixes #
$valid[substr($key,strlen(self::$prefix))] = $value;
}
}
}
} }
// Register, or it won't be found
etemplate_widget::registerWidget('importexport_widget_filter', array('filter'));

View File

@ -269,6 +269,8 @@ class importexport_wizard_basic_export_csv
$preserv = $content; $preserv = $content;
unset ($preserv['button']); unset ($preserv['button']);
error_log('-------');
error_log('Filter ' . array2string($content['filter']));
$content['set_filter']['fields'] = importexport_helper_functions::get_filter_fields( $content['set_filter']['fields'] = importexport_helper_functions::get_filter_fields(
$content['application'],$content['plugin'],$this $content['application'],$content['plugin'],$this
); );
@ -278,6 +280,8 @@ class importexport_wizard_basic_export_csv
$content['set_filter'][$field] = $content['filter'][$field]; $content['set_filter'][$field] = $content['filter'][$field];
} }
error_log('SET FILTER ' . array2string($content['set_filter']));
error_log('----------');
if(!$content['set_filter']['fields']) if(!$content['set_filter']['fields'])
{ {
// No fields // No fields

View File

@ -79,9 +79,7 @@ class importexport_wizard_basic_import_csv
case 'next': case 'next':
// Move sample file to temp // Move sample file to temp
if($content['file']['tmp_name']) { if($content['file']['tmp_name']) {
$csvfile = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$content['plugin']."_"); $GLOBALS['egw']->session->appsession('csvfile',$content['application'],$content['file']['tmp_name']);
move_uploaded_file($content['file']['tmp_name'], $csvfile);
$GLOBALS['egw']->session->appsession('csvfile',$content['application'],$csvfile);
} }
unset($content['file']); unset($content['file']);
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
@ -126,6 +124,7 @@ class importexport_wizard_basic_import_csv
// Process sample file for fields // Process sample file for fields
if (($handle = fopen($GLOBALS['egw']->session->appsession('csvfile',$content['application']), "rb")) !== FALSE) { if (($handle = fopen($GLOBALS['egw']->session->appsession('csvfile',$content['application']), "rb")) !== FALSE) {
$data = fgetcsv($handle, 8000, $content['fieldsep']); $data = fgetcsv($handle, 8000, $content['fieldsep']);
error_log($data);
fclose($handle); fclose($handle);
// Remove & forget file // Remove & forget file
@ -270,31 +269,24 @@ class importexport_wizard_basic_import_csv
// return from step50 // return from step50
if ($content['step'] == 'wizard_step50') if ($content['step'] == 'wizard_step50')
{ {
for($i = 0; $i <= count($content['csv_fields']); $i++) { unset($content['field_mapping']);
unset($content[$i]); unset($content['field_conversion']);
} foreach($content['mapping'] as $field)
if(!$content['csv_fields'][0]) {
array_shift($content['csv_fields']);
}
// Need to move everything down 1 to remove header, but shift will re-key
if(!$content['field_mapping'][0] || $content['field_mapping'][0] == $content['field_mapping'][1]) {
unset($content['field_mapping'][0]);
if(is_array($content['field_conversion'])) unset($content['field_conversion'][0]);
foreach(array('field_mapping', 'field_conversion') as $field) {
ksort($content[$field]);
foreach($content[$field] as $key => $value)
{ {
if($value && $value != '--NONE--') { $index = $field['index'];
$content[$field][$key-1] = $content[$field][$key]; foreach(array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest)
} {
unset($content[$field][$key]); if(trim($field[$id]) != '')
} {
ksort($content[$field]); $content[$dest][$index] = trim($field[$id]);
} }
} }
foreach($content['field_conversion'] as $field => $convert) {
if(!trim($convert)) unset($content['field_conversion'][$field]);
} }
foreach($content['csv_fields'] as $index => $title)
{
error_log("$index: $title => {$content['field_mapping'][$index]}");
}
unset($content['mapping']);
switch (array_search('pressed', $content['button'])) switch (array_search('pressed', $content['button']))
{ {
case 'next': case 'next':
@ -312,41 +304,19 @@ class importexport_wizard_basic_import_csv
{ {
$content['msg'] = $this->steps['wizard_step50']; $content['msg'] = $this->steps['wizard_step50'];
$content['step'] = 'wizard_step50'; $content['step'] = 'wizard_step50';
$content['mapping'] = array(false);
foreach($content['csv_fields'] as $index => $title)
{
$content['mapping'][] = array(
'index' => $index,
'title' => $title,
'field' => $content['field_mapping'][$index],
'conversion' => $content['field_conversion'][$index]
);
}
$preserv = $content; $preserv = $content;
$sel_options['field'] = array('--NONE--' => lang('none')) + $this->mapping_fields;
if(!$content['field_mapping'] && $content['plugin_options']) {
$content['field_mapping'] = $content['plugin_options']['field_mapping'];
$content['field_conversion'] = $content['plugin_options']['field_conversion'];
}
array_unshift($content['csv_fields'], array('row0'));
// Need to move everything down 1 to make room for header, but unshift will re-key
// which causes problems if you skip a field.
foreach(array('field_mapping', 'field_conversion') as $field) {
foreach(array_reverse($content[$field], true) as $key => $value)
{
if($value) {
$content[$field][$key+1] = $content[$field][$key];
}
unset($content[$field][$key]);
}
ksort($content[$field]);
}
$j = 1;
$i = 0;
foreach ($content['csv_fields'] as $field)
{
$content[++$i]['index'] = $i - 1;
if(strstr($field,'no_csv_')) $j++;
}
while ($j <= 3)
{
$content['csv_fields'][] = 'no_csv_'.$j;
$content['field_mapping'][] = $content['field_conversion'][] = '';
$j++;
}
$sel_options['field_mapping'] = array('--NONE--' => lang('none')) + $this->mapping_fields;
$GLOBALS['egw']->js->set_onload('$j("option[value=\'--NONE--\']:selected").closest("tr").animate({backgroundColor: "#ffff99"}, 1000);'); $GLOBALS['egw']->js->set_onload('$j("option[value=\'--NONE--\']:selected").closest("tr").animate({backgroundColor: "#ffff99"}, 1000);');
unset ($preserv['button']); unset ($preserv['button']);
return $this->step_templates[$content['step']]; return $this->step_templates[$content['step']];

97
importexport/js/app.js Normal file
View File

@ -0,0 +1,97 @@
/**
* EGroupware - Import/Export - Javascript UI
*
* @link http://www.egroupware.org
* @package importexport
* @author Nathan Gray
* @copyright (c) 2013 Nathan Gray
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* JS for Import/Export
*
* @augments AppJS
*/
app.importexport = AppJS.extend(
{
appname: 'importexport',
/**
* Constructor
*
* @memberOf app.timesheet
*/
init: function()
{
// call parent
this._super.apply(this, arguments);
},
/**
* Destructor
*/
destroy: function()
{
// call parent
this._super.apply(this, arguments);
},
/**
* This function is called when the etemplate2 object is loaded
* and ready. If you must store a reference to the et2 object,
* make sure to clean it up in destroy().
*
* @param et2 etemplate2 Newly ready object
*/
et2_ready: function(et2)
{
// call parent
this._super.apply(this, arguments);
if(this.et2.getWidgetById('export') && !this.et2.getArrayMgr("content").getEntry("definition"))
{
// et2 doesn't understand a disabled button in the normal sense
$j(this.et2.getWidgetById('export').getDOMNode()).attr('disabled','disabled');
$j(this.et2.getWidgetById('preview').getDOMNode()).attr('disabled','disabled');
}
},
export_preview: function(event, widget)
{
var preview = $j(widget.getRoot().getWidgetById('preview_box').getDOMNode());
$j('.content',preview).empty();
preview
.addClass('loading')
.show(100, jQuery.proxy(function() {
widget.clicked = true;
widget.getInstanceManager().submit(false, true);
widget.clicked = false;
$j(widget.getRoot().getWidgetById('preview_box').getDOMNode())
.removeClass('loading');
},this));
return false;
},
import_preview: function(event, widget)
{
var test = widget.getRoot().getWidgetById('dry-run');
if(!test.getValue()) return true;
// Show preview
var preview = $j(widget.getRoot().getWidgetById('preview_box').getDOMNode());
$j('.content',preview).empty();
preview
.addClass('loading')
.show(100, jQuery.proxy(function() {
widget.clicked = true;
widget.getInstanceManager().submit(false, true);
widget.clicked = false;
$j(widget.getRoot().getWidgetById('preview_box').getDOMNode())
.removeClass('loading');
},this));
return false;
}
});

View File

@ -1,37 +0,0 @@
/**
* eGroupWare
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package importexport
* @link http://www.egroupware.org
* @author Cornelius Weiss <nelius@cwtech.de>
* @copyright Cornelius Weiss <nelius@cwtech.de>
* @version $Id:$
*/
function export_dialog() {
this.change_definition = function(sel_obj) {
if(sel_obj.value == 'expert') {
xajax_doXMLHTTP('importexport.importexport_export_ui.ajax_get_plugins',document.getElementById('exec[appname]') ? document.getElementById('exec[appname]').value : this.appname);
// next two lines fix some strange layout bug
//set_style_by_class('tr','select_definition','display','none');
//set_style_by_class('tr','select_definition','display','inline');
set_style_by_class('tr','select_plugin','display','table-row');
set_style_by_class('tr','save_definition','display','inline');
document.getElementById('importexport.export_dialog.selection_tab-tab').style.visibility='visible';
document.getElementById('importexport.export_dialog.options_tab-tab').style.visibility='visible';
}
else {
xajax_doXMLHTTP('importexport.importexport_export_ui.ajax_get_definition_description',sel_obj.value);
set_style_by_class('tr','select_plugin','display','none');
set_style_by_class('tr','save_definition','display','none');
// document.getElementById('importexport.export_dialog.selection_tab-tab').style.visibility='hidden';
// document.getElementById('importexport.export_dialog.options_tab-tab').style.visibility='hidden';
enable_button('exec[export]');
enable_button('exec[preview]');
}
};
this.appname = '';
}
var export_dialog = new export_dialog();

View File

@ -1,17 +0,0 @@
/**
* 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;
}
if($j().chosen && list) {
$j(list).trigger("liszt:updated");
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
div.preview {
position: absolute;
top: 0px;
left: 0px;
width: 97%;
height: 95%;
overflow: hidden;
background-color: white;
z-index: 999;
display: none;
border: 1px solid black;
margin: 1.5%;
}
div.preview .content {
overflow: auto;
max-height: 99%;
display: block;
}
.preview_box .header, .preview .header {
font-size: 150%;
margin-bottom: 5px;
padding: 5px;
border-bottom: 1px outset;
}
.preview tr{
vertical-align: top;
}
.preview div[id$='buttons'] {
position: absolute;
bottom: 0px;
width: 100%;
margin-left: 50%;
}

View File

@ -4,13 +4,13 @@
<template id="importexport.definition_index.row" template="" lang="" group="0" version="1.9.002"> <template id="importexport.definition_index.row" template="" lang="" group="0" version="1.9.002">
<grid width="100%"> <grid width="100%">
<columns> <columns>
<column width="20px"/>
<column/> <column/>
<column/> <column width="150px"/>
<column/> <column width="150px"/>
<column/> <column width="150px"/>
<column/> <column width="10px"/>
<column/> <column width="10px" disabled="@no_actions"/>
<column disabled="@no_actions"/>
</columns> </columns>
<rows> <rows>
<row class="th"> <row class="th">
@ -59,7 +59,7 @@
<description align="center" id="msg" no_lang="1" span="all" class="message"/> <description align="center" id="msg" no_lang="1" span="all" class="message"/>
</row> </row>
<row> <row>
<nextmatch cols="6" id="nm" rows="2" options="importexport.definition_index.row"/> <nextmatch id="nm" template="importexport.definition_index.row"/>
</row> </row>
<row disabled="!@nm[selectcols]=/actions/"> <row disabled="!@nm[selectcols]=/actions/">
<hbox align="right"> <hbox align="right">
@ -68,13 +68,13 @@
</hbox> </hbox>
</row> </row>
<row> <row>
<hbox> <box>
<box class="action_popup prompt" id="owner_popup"> <box id="owner_popup" class="action_popup prompt">
<vbox>
<description value="Change owner" class="promptheader"/> <description value="Change owner" class="promptheader"/>
<vbox class="action_popup-content">
<description value="Select owner"/> <description value="Select owner"/>
<menulist class="action_popup-content"> <menulist>
<menupopup type="select-account" id="owner" options="None,accounts"/> <menupopup type="select-account" class="action_popup-content" id="owner" options="None,accounts"/>
</menulist> </menulist>
<hbox> <hbox>
<button label="Save" onclick="nm_submit_popup(this); return false;"/> <button label="Save" onclick="nm_submit_popup(this); return false;"/>
@ -82,7 +82,7 @@
</hbox> </hbox>
</vbox> </vbox>
</box> </box>
<box class="action_popup prompt" id="allowed_popup"> <box id="allowed_popup" class="action_popup prompt">
<vbox> <vbox>
<description value="Change allowed users" class="promptheader"/> <description value="Change allowed users" class="promptheader"/>
<description value="Select groups"/> <description value="Select groups"/>
@ -95,12 +95,12 @@
</hbox> </hbox>
</vbox> </vbox>
</box> </box>
</hbox> </box>
</row> </row>
</rows> </rows>
</grid> </grid>
<styles> <styles>
.redItalic { color:red; font-style:italic;} td.lr_padding { padding-left: 5px; padding-right: 5px; } td.lr_padding { padding-left: 5px; padding-right: 5px; }
.button { .button {
cursor: pointer; cursor: pointer;

View File

@ -13,8 +13,8 @@
<row> <row>
<radio label="Use search results" id="selection" options="search"/> <radio label="Use search results" id="selection" options="search"/>
</row> </row>
<row> <row disabled="@no_filter">
<radio label="Use definition filter" id="selection" onclick="\$j('div.filters').show();" options="filter"/> <radio label="Use definition filter" id="selection" onclick="jQuery('div.filters').show();" options="filter"/>
</row> </row>
</rows> </rows>
</grid> </grid>

View File

@ -30,8 +30,8 @@
</menulist> </menulist>
</row> </row>
<row> <row>
<box id="plugin_description" needed="1" span="all"> <box id="plugin_description" span="all">
<description id="description" needed="1" no_lang="1" span="all"/> <description id="description" no_lang="1" span="all"/>
</box> </box>
</row> </row>
</rows> </rows>
@ -74,7 +74,7 @@
</row> </row>
<row valign="top" disabled="!@plugin_selectors_template"> <row valign="top" disabled="!@plugin_selectors_template">
<template id="@plugin_selectors_template"/> <template id="@plugin_selectors_template"/>
<box onclick="\$j('input[value=\'filter\']').not(':checked').attr('checked',true).parent().effect('highlight',{},2000);" class="filters"> <box onclick="jQuery('input[value=\'filter\']').not(':checked').attr('checked',true).parent().effect('highlight',{},2000);" class="filters">
<filter id="filter"/> <filter id="filter"/>
</box> </box>
</row> </row>
@ -159,26 +159,24 @@
<row> <row>
<hbox span="all"> <hbox span="all">
<hbox> <hbox>
<button label="Export" id="export" onclick="xajax_eT_wrapper(this);return false;"/> <button label="Export" id="export"/>
<button label="Preview" id="preview" onclick="xajax_eT_wrapper(this);return false;"/> <button label="Preview" id="preview" onclick="app.importexport.export_preview"/>
</hbox> </hbox>
<button align="right" label="Cancel" id="cancel" onclick="window.close(); return false;"/> <button align="right" label="Cancel" id="cancel" onclick="window.close(); return false;"/>
</hbox> </hbox>
</row> </row>
<row> <row>
<box id="preview_box" span="all" class="preview_box"> <box id="preview_box" span="all" class="preview_box">
<box id="preview-box" needed="1" class="content"> <html id="preview-box" class="content"/>
<description/>
</box>
<box align="center" id="preview-box-buttons" class="preview-box-buttons"> <box align="center" id="preview-box-buttons" class="preview-box-buttons">
<button align="center" label="OK" onclick="document.getElementById(form::name('preview_box')).style.display='none'; return false;"/> <button align="center" label="OK" onclick="jQuery(this).parents('div.preview_box').css('display','none'); return false;"/>
</box> </box>
</box> </box>
</row> </row>
</rows> </rows>
</grid> </grid>
<styles> <styles>
.preview_box { div.preview_box {
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 0px; left: 0px;

View File

@ -0,0 +1,60 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.import_dialog" template="" lang="" group="0" version="1.9.005">
<grid>
<columns>
<column/>
<column/>
</columns>
<rows>
<row disabled="!@msg">
<html id="msg" span="all" class="message"/>
<description/>
</row>
<row>
<description value="Application"/>
<menulist>
<menupopup id="appname" onchange="1"/>
</menulist>
</row>
<row>
<description value="Import definition"/>
<menulist>
<menupopup id="definition"/>
</menulist>
</row>
<row>
<description value="Delimiter"/>
<hbox no_lang="1" options="0,0">
<menulist>
<menupopup id="delimiter" no_lang="1" onchange="var _this = jQuery(this); var text = _this.parent().parent().find('input'); if(_this.val() =='other') {text.val('');text.show(); text.focus();} else {text.hide();}"/>
</menulist>
<textbox id="other_delimiter" size="2" maxlength="1" class="hide"/>
</hbox>
</row>
<row>
<description value="Please select file to import"/>
<file id="file"/>
</row>
<row>
<box id="preview_box" readonly="true" span="all" class="preview">
<html id="preview" readonly="true" class="content"/>
<box align="center" id="buttons">
<buttononly align="center" label="OK" onclick="jQuery(this).parents('div.preview').css('display','none'); return false;"/>
</box>
</box>
<description/>
</row>
<row>
<hbox span="all">
<button label="Import" id="import" onclick="app.importexport.import_preview"/>
<button label="Cancel" id="cancel" onclick="window.close();"/>
<checkbox align="right" label="No notifications" id="no_notifications"/>
<checkbox align="right" label="Test only" id="dry-run"/>
</hbox>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- $Id$ --> <!-- $Id$ -->
<overlay> <overlay>
<template id="importexport.schedule_edit" template="" lang="" group="0" version="1.9.003"> <template id="importexport.schedule_edit" template="" lang="" group="0" version="1.9.004">
<grid> <grid>
<columns> <columns>
<column/> <column/>
@ -21,13 +21,13 @@
<row> <row>
<description value="Application"/> <description value="Application"/>
<menulist> <menulist>
<menupopup id="appname" onchange="xajax_doXMLHTTP('importexport.importexport_schedule_ui.ajax_get_plugins', document.getElementById(form::name('type')).value, this.value);"/> <menupopup id="appname" onchange="1"/>
</menulist> </menulist>
</row> </row>
<row> <row>
<description value="Plugin"/> <description value="Plugin"/>
<menulist> <menulist>
<menupopup id="plugin" onchange="xajax_doXMLHTTP('importexport.importexport_schedule_ui.ajax_get_definitions', document.getElementById(form::name('appname')).value, this.value);" options="Select..."/> <menupopup id="plugin" onchange="1" options="Select..."/>
</menulist> </menulist>
</row> </row>
<row> <row>

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- $Id$ --> <!-- $Id$ -->
<overlay> <overlay>
<template id="importexport.schedule_index" template="" lang="" group="0" version="1.9.001"> <template id="importexport.schedule_index" template="" lang="" group="0" version="1.9.002">
<grid> <grid width="100%">
<columns> <columns>
<column/> <column/>
</columns> </columns>
@ -73,8 +73,8 @@
<description id="times" no_lang="1"/> <description id="times" no_lang="1"/>
</vbox> </vbox>
<hbox options="0,0"> <hbox options="0,0">
<button id="edit[{$cont[id]}]" onclick="window.open(egw::link('/index.php','menuaction=importexport.importexport_schedule_ui.edit&amp;id={$cont[id]}'),'_blank','dependent=yes,width=600,height=450,scrollbars=yes,status=yes'); return false;" image="edit"/> <button id="edit[{$_cont[id]}]" onclick="window.open(egw::link('/index.php','menuaction=importexport.importexport_schedule_ui.edit&amp;id={$_cont[id]}'),'_blank','dependent=yes,width=600,height=450,scrollbars=yes,status=yes'); return false;" image="edit"/>
<button id="delete[{$cont[id]}]" image="delete"/> <button id="delete[{$_cont[id]}]" image="delete"/>
</hbox> </hbox>
</row> </row>
<row class="th" disabled="!@result"> <row class="th" disabled="!@result">

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizard_basic_export_csv.choosesepncharset" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
<column width="180px"/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1" span="all"/>
</row>
<row>
<description value="Fieldseperator"/>
<textbox id="delimiter" no_lang="1" size="1"/>
</row>
<row>
<description value="Charset of file"/>
<menulist class="width180">
<menupopup id="charset" no_lang="1"/>
</menulist>
</row>
<row>
<description value="Include header"/>
<menulist>
<menupopup id="begin_with_fieldnames"/>
</menulist>
</row>
<row>
<description value="Export data as"/>
<menulist>
<menupopup id="convert"/>
</menulist>
</row>
</rows>
</grid>
<styles>
.width180 select { width:150px;}
</styles>
</template>
</overlay>

View File

@ -11,7 +11,7 @@
<description id="msg"/> <description id="msg"/>
</row> </row>
<row> <row>
<filter id="set_filter" options="1"/> <filter id="set_filter" relative_dates="true"/>
</row> </row>
</rows> </rows>
</grid> </grid>

View File

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizard_basic_import_csv.choosesepncharset" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
<column width="180px"/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1" span="all"/>
</row>
<row>
<description value="Fieldseperator"/>
<textbox id="fieldsep" no_lang="1" size="1"/>
</row>
<row>
<description value="Charset of file"/>
<menulist class="width180">
<menupopup id="charset" no_lang="1"/>
</menulist>
</row>
<row>
<description value="Header lines to skip"/>
<textbox type="integer" id="num_header_lines" min="0"/>
</row>
<row disabled="@no_cats">
<description value="Update categories"/>
<menulist>
<menupopup id="update_cats"/>
</menulist>
</row>
<row>
<description value="Import data is"/>
<menulist>
<menupopup id="convert"/>
</menulist>
</row>
</rows>
</grid>
<styles>
.width180 select { width:150px;}
</styles>
</template>
</overlay>

View File

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizard_basic_import_csv.fieldmapping" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1" span="all"/>
</row>
<row>
<grid overflow="auto" id="mapping">
<columns>
<column/>
<column/>
<column/>
<column/>
<column/>
</columns>
<rows>
<row class="th">
<description/>
<description/>
<description value="CSV Field"/>
<description value="Target Field"/>
<description value="Translation"/>
</row>
<row>
<description value="${row}[index]" no_lang="1"/>
<description value="${row_cont[index]}" no_lang="1"/>
<description value="{$row_cont[title]}" no_lang="1"/>
<menulist>
<menupopup id="{$row}[field]" no_lang="1"/>
</menulist>
<textbox id="{$row}[conversion]"/>
</row>
</rows>
</grid>
</row>
</rows>
</grid>
<styles>
.et2_grid[id$='mapping'] td:first-child {
display:none;
}
</styles>
</template>
</overlay>

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizard_basic_import_csv.sample_file" template="" lang="" group="0" version="0.0.1">
<grid>
<columns>
<column/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1"/>
</row>
<row>
<file id="file"/>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -17,7 +17,7 @@
<checkbox label="%s All users" id="all_users"/> <checkbox label="%s All users" id="all_users"/>
</row> </row>
<row> <row>
<listbox type="select-account" id="allowed_users" rows="5" options="groups"/> <listbox type="select-account" id="allowed_users" rows="5" account_type="groups"/>
</row> </row>
</rows> </rows>
</grid> </grid>

View File

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizard_chooseapp" template="" lang="" group="0" version="0.0.1">
<grid>
<columns>
<column/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1"/>
</row>
<row>
<menulist>
<menupopup id="application" no_lang="1"/>
</menulist>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizard_choosename" template="" lang="" group="0" version="0.0.1">
<grid>
<columns>
<column/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1"/>
</row>
<row>
<textbox id="name"/>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizard_chooseplugin" template="" lang="" group="0" version="0.0.1">
<grid>
<columns>
<column/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1"/>
</row>
<row>
<menulist>
<menupopup id="plugin" no_lang="1"/>
</menulist>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.wizardbox" template="" lang="" group="0" version="0.0.2">
<grid width="100%" height="400">
<columns>
<column width="100%"/>
</columns>
<rows>
<row valign="top">
<hbox no_lang="1">
<image src="importexport"/>
<vbox>
<description/>
<box class="wizard_content">
<template id="@wizard_content"/>
</box>
</vbox>
</hbox>
</row>
<row valign="bottom">
<hbox span="all">
<hbox>
<button label="previous" id="button[previous]"/>
<button label="next" id="button[next]"/>
<button label="finish" id="button[finish]"/>
</hbox>
<button align="right" label="cancel" id="button[cancel]" onclick="window.close(); return false;"/>
</hbox>
</row>
</rows>
</grid>
<styles>
.wizard_content {
height: 365px;
width: 370px;
max-height:365px;
overflow:auto;
}
</styles>
</template>
</overlay>