From fd9d3315cdae6fa0ebbcb5da64743807e2e57a87 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 18 Mar 2011 15:17:25 +0000 Subject: [PATCH] * EventMgr: fixed fatal error eventmgr_merge::number_format() is not defined --- etemplate/inc/class.bo_merge.inc.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 1094d863e2..1cfca9257d 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -676,7 +676,7 @@ abstract class bo_merge if (isset($archive)) { $zip = new ZipArchive; - if ($zip->open($archive,ZIPARCHIVE::CHECKCONS) !== true) + if ($zip->open($archive,ZIPARCHIVE::CHECKCONS) !== true) { error_log(__METHOD__.__LINE__." !ZipArchive::open('$archive',ZIPARCHIVE::CHECKCONS) failed. Trying open without validating"); if ($zip->open($archive) !== true) throw new Exception("!ZipArchive::open('$archive',|ZIPARCHIVE::CHECKCONS)"); @@ -711,4 +711,27 @@ abstract class bo_merge } common::egw_exit(); } + + /** + * Format a number according to user prefs with decimal and thousands separator + * + * Reimplemented from etemplate to NOT use user prefs for Excel 2003, which gives an xml error + * + * @param int|float|string $number + * @param int $num_decimal_places=2 + * @param string $_mimetype='' + * @return string + */ + static public function number_format($number,$num_decimal_places=2,$_mimetype='') + { + if ((string)$number === '') return ''; + //error_log(__METHOD__.$_mimetype); + switch($_mimetype) + { + case 'application/xml': // Excel 2003 + case 'application/vnd.oasis.opendocument.spreadsheet': // OO.o spreadsheet + return number_format(str_replace(' ','',$number),$num_decimal_places,'.',''); + } + return etemplate::number_format($number,$num_decimal_places); + } }