mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
* Import/Export - allow import plugins to specify their own sub-templates
This commit is contained in:
parent
ab2b00cd13
commit
cde347a463
@ -50,6 +50,12 @@ use EGroupware\Api\Etemplate;
|
||||
Api\Header\ContentSecurityPolicy::add('script-src', "unsafe-inline");
|
||||
|
||||
$template = new Etemplate('importexport.import_dialog');
|
||||
$preserve = array();
|
||||
|
||||
if($definition)
|
||||
{
|
||||
$definition_obj = new importexport_definition($content['definition']);
|
||||
}
|
||||
|
||||
// Load application's translations
|
||||
if($appname)
|
||||
@ -58,7 +64,6 @@ use EGroupware\Api\Etemplate;
|
||||
}
|
||||
if($content['import'] && $definition) {
|
||||
try {
|
||||
$definition_obj = new importexport_definition($content['definition']);
|
||||
if($content['dry-run']) {
|
||||
// Set this so plugin doesn't do any data changes
|
||||
$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
|
||||
@ -69,6 +74,7 @@ use EGroupware\Api\Etemplate;
|
||||
$options['fieldsep'] =
|
||||
$content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter'];
|
||||
}
|
||||
$options = array_merge($options, array_diff_key($content, array_flip(array('dry-run','file','import'))));
|
||||
$definition_obj->plugin_options = $options;
|
||||
|
||||
$plugin = new $definition_obj->plugin;
|
||||
@ -216,6 +222,31 @@ use EGroupware\Api\Etemplate;
|
||||
$data['no_notifications'] = true; // switch notifications off by default
|
||||
|
||||
$sel_options = self::get_select_options($data);
|
||||
$readonlys = array();
|
||||
|
||||
if(!$definition_obj && $sel_options['definition'] && !$data['definition'])
|
||||
{
|
||||
$definition_obj = new importexport_definition(key($sel_options['definition']));
|
||||
}
|
||||
if($definition_obj)
|
||||
{
|
||||
$plugin = new $definition_obj->plugin;
|
||||
$options = $plugin->get_options_etpl($definition_obj);
|
||||
if(is_array($options))
|
||||
{
|
||||
$data['plugin_options_template'] = $options['name'];
|
||||
$data += (array)$options['content'];
|
||||
$sel_options += (array)$options['sel_options'];
|
||||
$readonlys += (array)$options['readonlys'];
|
||||
$preserve += (array)$options['preserv'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback for not returning anything - CSV
|
||||
$data['plugin_options_template'] = "importexport.import_dialog.csv";
|
||||
$data['file_type'] = 'csv';
|
||||
}
|
||||
}
|
||||
|
||||
$data['message'] = $this->message;
|
||||
Framework::includeJS('.','importexport','importexport');
|
||||
|
@ -2,6 +2,25 @@
|
||||
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="importexport.import_dialog.csv" template="" lang="" group="0" version="1.9.005">
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<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>
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
<template id="importexport.import_dialog" template="" lang="" group="0" version="1.9.005">
|
||||
<grid>
|
||||
<columns>
|
||||
@ -22,21 +41,15 @@
|
||||
<row>
|
||||
<description value="Import definition"/>
|
||||
<menulist>
|
||||
<menupopup id="definition"/>
|
||||
<menupopup id="definition" onchange="1"/>
|
||||
</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"/>
|
||||
<file id="file" accept="@file_type"/>
|
||||
</row>
|
||||
<row disabled="!@plugin_options_template">
|
||||
<template template="@plugin_options_template"/>
|
||||
</row>
|
||||
<row>
|
||||
<box id="preview_box" span="all" class="preview">
|
||||
|
Loading…
Reference in New Issue
Block a user