From: Sam Reed Date: Thu, 22 Sep 2011 11:06:48 +0000 (+0000) Subject: Fix mixed tabs and spaces from r97793 X-Git-Tag: 1.31.0-rc.0~27481 X-Git-Url: http://git.cyclocoop.org//%22%22.str_replace%28%27%22%27%2C?a=commitdiff_plain;h=fe4d325fd24c04ea5997a1b721ae79eb16befbd0;p=lhc%2Fweb%2Fwiklou.git Fix mixed tabs and spaces from r97793 Couple of minor style tweaks also --- diff --git a/languages/Language.php b/languages/Language.php index 75f3288d0f..522c44bc4d 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2612,12 +2612,11 @@ class Language { */ function commafy( $_ ) { $digitGroupingPattern = $this->digitGroupingPattern(); - + if ( !$digitGroupingPattern || $digitGroupingPattern === "###,###,###" ) { //default grouping is at thousands, use the same for ###,###,### pattern too. return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); - } - else { + } else { // Ref: http://cldr.unicode.org/translation/number-patterns $numberpart = array(); $decimalpart = array(); @@ -2625,28 +2624,27 @@ class Language { preg_match( "/\d+/", $_, $numberpart ); preg_match( "/\.\d*/", $_, $decimalpart ); $groupedNumber = ( count( $decimalpart ) > 0 ) ? $decimalpart[0]:""; - if ( $groupedNumber === $_){ - //the string does not have any number part. Eg: .12345 - return $groupedNumber; + if ( $groupedNumber === $_ ){ + //the string does not have any number part. Eg: .12345 + return $groupedNumber; } $start = $end = strlen( $numberpart[0] ); - while ( $start > 0 ) - { - $match = $matches[0][$numMatches -1] ; - $matchLen = strlen( $match ); - $start = $end - $matchLen; - if ( $start < 0 ) { - $start = 0; - } - $groupedNumber = substr( $_ , $start, $end -$start ) . $groupedNumber ; - $end = $start; - if ( $numMatches > 1 ) { - // use the last pattern for the rest of the number - $numMatches--; - } - if ( $start > 0 ) { - $groupedNumber = "," . $groupedNumber; - } + while ( $start > 0 ) { + $match = $matches[0][$numMatches -1] ; + $matchLen = strlen( $match ); + $start = $end - $matchLen; + if ( $start < 0 ) { + $start = 0; + } + $groupedNumber = substr( $_ , $start, $end -$start ) . $groupedNumber ; + $end = $start; + if ( $numMatches > 1 ) { + // use the last pattern for the rest of the number + $numMatches--; + } + if ( $start > 0 ) { + $groupedNumber = "," . $groupedNumber; + } } return $groupedNumber; }