r37635 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37634‎ | r37635 | r37636 >
Date:07:09, 14 July 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
Support French number formatting (spaces in numbers) and multi-character separators for thousands and for
decimals
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php
@@ -43,7 +43,7 @@
4444
4545 $parts = preg_split('/([-+]?\s*\d+(?:\\' . $kiloseparator . '\d\d\d)*' .
4646 '(?:\\' . $decseparator . '\d+)?\s*(?:[eE][-+]?\d+)?)/u',
47 - trim(str_replace(array(' ',' '), '', $value)),
 47+ trim(str_replace(array(' ',' ', ' '), '', $value)),
4848 2, PREG_SPLIT_DELIM_CAPTURE);
4949
5050 if (count($parts) >= 2) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -633,7 +633,6 @@
634634 */
635635 function smwfNumberFormat($value, $decplaces=3) {
636636 $decseparator = wfMsgForContent('smw_decseparator');
637 - $kiloseparator = wfMsgForContent('smw_kiloseparator');
638637
639638 // If number is a trillion or more, then switch to scientific
640639 // notation. If number is less than 0.0000001 (i.e. twice decplaces),
@@ -672,10 +671,11 @@
673672 $value = str_replace('.', $decseparator, $value);
674673 }
675674 } else {
676 - // Format to some level of precision;
677 - // this does rounding and locale formatting.
678 - $value = number_format($value, $decplaces, $decseparator, wfMsgForContent('smw_kiloseparator'));
679 -
 675+ // Format to some level of precision; number_format does rounding and locale formatting,
 676+ // x and y are used temporarily since number_format supports only single characters for either
 677+ $value = number_format($value, $decplaces, 'x', 'y');
 678+ $value = str_replace(array('x','y'),array($decseparator, wfMsgForContent('smw_kiloseparator')),$value);
 679+
680680 // Make it more readable by removing ending .000 from nnn.000
681681 // Assumes substr is faster than a regular expression replacement.
682682 $end = $decseparator . str_repeat('0', $decplaces);

Status & tagging log