- Add ability for plugin to specify mimetype

- Fix basic export csv wizard header option (wasn't loaded properly)
This commit is contained in:
Nathan Gray 2010-10-12 22:45:55 +00:00
parent cc2bee8dd0
commit 7f540ad450
4 changed files with 24 additions and 9 deletions

View File

@ -154,11 +154,18 @@ class importexport_export_ui {
$content['plugin_selectors_html'] = $plugin_object->get_selectors_html(); $content['plugin_selectors_html'] = $plugin_object->get_selectors_html();
} else { } else {
$options = $plugin_object->get_selectors_etpl(); $options = $plugin_object->get_selectors_etpl();
$content['selection'] = (array)$options['content']; if(is_array($options)) {
$sel_options += (array)$options['sel_options']; $content['selection'] = (array)$options['content'];
$readonlys['selection'] = (array)$options['readonlys']; $sel_options += (array)$options['sel_options'];
$preserv['selection'] = (array)$options['preserv']; $readonlys['selection'] = (array)$options['readonlys'];
$content['plugin_selectors_template'] = $options['name']; $preserv['selection'] = (array)$options['preserv'];
$content['plugin_selectors_template'] = $options['name'];
} else {
$content['plugin_selectors_template'] = $options;
}
}
if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) {
$readonlys[$tabs]['selection_tab'] = true;
} }
} elseif (!$_selection) { } elseif (!$_selection) {
$this->js->set_onload(" $this->js->set_onload("
@ -226,7 +233,7 @@ class importexport_export_ui {
if($_content['export'] == 'pressed') { if($_content['export'] == 'pressed') {
fclose($file); fclose($file);
$response->addScript("xajax_eT_wrapper();"); $response->addScript("xajax_eT_wrapper();");
$response->addScript("opener.location.href='". $GLOBALS['egw']->link('/index.php','menuaction=importexport.importexport_export_ui.download&_filename='. $tmpfname.'&_appname='. $definition->application). "&_suffix=". $plugin_object->get_filesuffix(). "';"); $response->addScript("opener.location.href='". $GLOBALS['egw']->link('/index.php','menuaction=importexport.importexport_export_ui.download&_filename='. $tmpfname.'&_appname='. $definition->application). "&_suffix=". $plugin_object->get_filesuffix(). "&_type=".$plugin_object->get_mimetype() ."';");
$response->addScript('window.setTimeout("window.close();", 100);'); $response->addScript('window.setTimeout("window.close();", 100);');
return $response->getXML(); return $response->getXML();
} }
@ -413,9 +420,9 @@ class importexport_export_ui {
if (!is_readable($tmpfname)) die(); if (!is_readable($tmpfname)) die();
$appname = $_GET['_appname']; $appname = $_GET['_appname'];
$nicefname = 'egw_export_'.$appname.'-'.date('y-m-d'); $nicefname = 'egw_export_'.$appname.'-'.date('Y-m-d');
header('Content-type: application/text'); header('Content-type: ' . $_GET['_type'] ? $_GET['_type'] : 'application/text');
header('Content-Disposition: attachment; filename="'.$nicefname.'.'.$_GET['_suffix'].'"'); header('Content-Disposition: attachment; filename="'.$nicefname.'.'.$_GET['_suffix'].'"');
$file = fopen($tmpfname,'r'); $file = fopen($tmpfname,'r');
while(!feof($file)) while(!feof($file))

View File

@ -315,6 +315,7 @@ class importexport_helper_functions {
); );
$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
$types = $_type == 'all' ? array('import','export') : (array)$_type; $types = $_type == 'all' ? array('import','export') : (array)$_type;
$plugins = self::_get_plugins($appnames, $types);
foreach($plugins as $appname => $types) { foreach($plugins as $appname => $types) {
if(!in_array($appname, $appnames)) unset($plugins['appname']); if(!in_array($appname, $appnames)) unset($plugins['appname']);

View File

@ -65,6 +65,13 @@ interface importexport_iface_export_plugin {
*/ */
public static function get_filesuffix(); public static function get_filesuffix();
/**
* returns mime type for exported file
*
* @return string mimetype
*/
public static function get_mimetype();
/** /**
* return etemplate components for options. * return etemplate components for options.
* @abstract We can't deal with etemplate objects here, as an uietemplate * @abstract We can't deal with etemplate objects here, as an uietemplate

View File

@ -153,7 +153,7 @@ class importexport_wizard_basic_export_csv
if(!$content['charset'] && $content['plugin_options']['charset']) { if(!$content['charset'] && $content['plugin_options']['charset']) {
$content['charset'] = $content['plugin_options']['charset']; $content['charset'] = $content['plugin_options']['charset'];
} }
if(!array_key_exists($content, 'begin_with_fieldnames') && array_key_exists($content['plugin_options'], 'begin_with_fieldnames')) { if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) {
$content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames']; $content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames'];
} }