Backport 32510 - 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:48:18 +00:00
parent dfbd512e14
commit 7b87beb9d9
3 changed files with 23 additions and 9 deletions

View File

@ -154,11 +154,18 @@ class importexport_export_ui {
$content['plugin_selectors_html'] = $plugin_object->get_selectors_html();
} else {
$options = $plugin_object->get_selectors_etpl();
$content['selection'] = (array)$options['content'];
$sel_options += (array)$options['sel_options'];
$readonlys['selection'] = (array)$options['readonlys'];
$preserv['selection'] = (array)$options['preserv'];
$content['plugin_selectors_template'] = $options['name'];
if(is_array($options)) {
$content['selection'] = (array)$options['content'];
$sel_options += (array)$options['sel_options'];
$readonlys['selection'] = (array)$options['readonlys'];
$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) {
$this->js->set_onload("
@ -226,7 +233,7 @@ class importexport_export_ui {
if($_content['export'] == 'pressed') {
fclose($file);
$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);');
return $response->getXML();
}
@ -413,9 +420,9 @@ class importexport_export_ui {
if (!is_readable($tmpfname)) die();
$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'].'"');
$file = fopen($tmpfname,'r');
while(!feof($file))

View File

@ -65,6 +65,13 @@ interface importexport_iface_export_plugin {
*/
public static function get_filesuffix();
/**
* returns mime type for exported file
*
* @return string mimetype
*/
public static function get_mimetype();
/**
* return etemplate components for options.
* @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']) {
$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'];
}