mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
- Fix broken encodings by using export_csv's fputcsv
- Include set charset in HTTP header
This commit is contained in:
parent
7b2fd55d83
commit
d4cda9a91a
@ -174,7 +174,7 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
}
|
||||
$mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record );
|
||||
$mapping = $this->translation->convert( $mapping, $this->translation->charset(), $this->csv_charset );
|
||||
fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );
|
||||
self::fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );
|
||||
}
|
||||
|
||||
// Check for limit
|
||||
@ -196,7 +196,7 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
}
|
||||
}
|
||||
|
||||
fputcsv( $this->handle, $this->record, $this->csv_options['delimiter'], $this->csv_options['enclosure'] );
|
||||
self::fputcsv( $this->handle, $this->record, $this->csv_options['delimiter'], $this->csv_options['enclosure'] );
|
||||
$this->num_of_records++;
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
|
||||
/**
|
||||
* The php build in fputcsv function is buggy, so we need an own one :-(
|
||||
* Buggy how?
|
||||
* It ignores encoding, and outputs in UTF-8 / system charset
|
||||
*
|
||||
* @param resource $filePointer
|
||||
* @param array $dataArray
|
||||
|
@ -271,6 +271,7 @@ class importexport_export_ui {
|
||||
if (! $charset = $definition->plugin_options['charset']) {
|
||||
$charset = $GLOBALS['egw']->translation->charset();
|
||||
}
|
||||
if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
|
||||
$plugin_object = new $definition->plugin;
|
||||
$plugin_object->export( $file, $definition );
|
||||
|
||||
@ -280,6 +281,8 @@ class importexport_export_ui {
|
||||
// save prefs, but do NOT invalid the cache (unnecessary)
|
||||
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
||||
|
||||
// Store charset to use in header
|
||||
egw_cache::setSession('importexport', $tmpfname, $charset, 100);
|
||||
|
||||
if($_content['export'] == 'pressed') {
|
||||
fclose($file);
|
||||
@ -306,10 +309,9 @@ class importexport_export_ui {
|
||||
fclose($file);
|
||||
unlink($tmpfname);
|
||||
|
||||
// NOTE: $definition->plugin_options['charset'] may not be set,
|
||||
// but it's the best guess atm.
|
||||
// Convert back to system charset for display
|
||||
$preview = $GLOBALS['egw']->translation->convert( $preview,
|
||||
$definition->plugin_options['charset'],
|
||||
$charset,
|
||||
$GLOBALS['egw']->translation->charset()
|
||||
);
|
||||
|
||||
@ -483,9 +485,13 @@ class importexport_export_ui {
|
||||
// Turn off all output buffering
|
||||
while (@ob_end_clean());
|
||||
|
||||
header('Content-type: ' . $_GET['_type'] ? $_GET['_type'] : 'application/text');
|
||||
header('Content-Disposition: attachment; filename="'.$nicefname.'.'.$_GET['_suffix'].'"');
|
||||
$file = fopen($tmpfname,'rb');
|
||||
|
||||
// Get charset
|
||||
$charset = egw_cache::getSession('importexport', $tmpfname);
|
||||
|
||||
header('Content-type: ' . ($_GET['_type'] ? $_GET['_type'] : 'application/text') . ($charset ? '; charset='.$charset : ''));
|
||||
header('Content-Disposition: attachment; filename="'.$nicefname.'.'.$_GET['_suffix'].'"');
|
||||
fpassthru($file);
|
||||
|
||||
unlink($tmpfname);
|
||||
|
Loading…
Reference in New Issue
Block a user