From 7f540ad450666e0d7efc31bdbe9d3c6b88a56465 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 12 Oct 2010 22:45:55 +0000 Subject: [PATCH] - Add ability for plugin to specify mimetype - Fix basic export csv wizard header option (wasn't loaded properly) --- .../inc/class.importexport_export_ui.inc.php | 23 ++++++++++++------- ...lass.importexport_helper_functions.inc.php | 1 + ...s.importexport_iface_export_plugin.inc.php | 7 ++++++ ...portexport_wizard_basic_export_csv.inc.php | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/importexport/inc/class.importexport_export_ui.inc.php b/importexport/inc/class.importexport_export_ui.inc.php index 9f51c140c1..8bd1bdf821 100644 --- a/importexport/inc/class.importexport_export_ui.inc.php +++ b/importexport/inc/class.importexport_export_ui.inc.php @@ -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)) diff --git a/importexport/inc/class.importexport_helper_functions.inc.php b/importexport/inc/class.importexport_helper_functions.inc.php index e1a8d05229..47eb044c6a 100755 --- a/importexport/inc/class.importexport_helper_functions.inc.php +++ b/importexport/inc/class.importexport_helper_functions.inc.php @@ -315,6 +315,7 @@ class importexport_helper_functions { ); $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; $types = $_type == 'all' ? array('import','export') : (array)$_type; + $plugins = self::_get_plugins($appnames, $types); foreach($plugins as $appname => $types) { if(!in_array($appname, $appnames)) unset($plugins['appname']); diff --git a/importexport/inc/class.importexport_iface_export_plugin.inc.php b/importexport/inc/class.importexport_iface_export_plugin.inc.php index d725ae0928..0e61e7e6c6 100644 --- a/importexport/inc/class.importexport_iface_export_plugin.inc.php +++ b/importexport/inc/class.importexport_iface_export_plugin.inc.php @@ -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 diff --git a/importexport/inc/class.importexport_wizard_basic_export_csv.inc.php b/importexport/inc/class.importexport_wizard_basic_export_csv.inc.php index 38ca5d9700..87894f6a6f 100644 --- a/importexport/inc/class.importexport_wizard_basic_export_csv.inc.php +++ b/importexport/inc/class.importexport_wizard_basic_export_csv.inc.php @@ -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']; }