fix some spacing
[lhc/web/wiklou.git] / includes / parser / CoreParserFunctions.php
index b77309b..a274aa5 100644 (file)
@@ -269,12 +269,14 @@ class CoreParserFunctions {
        /**
         * @param $parser Parser
         * @param string $num
-        * @param null $raw
-        * @return
+        * @param string $arg
+        * @return string
         */
-       static function formatnum( $parser, $num = '', $raw = null) {
-               if ( self::isRaw( $raw ) ) {
+       static function formatnum( $parser, $num = '', $arg = null ) {
+               if ( self::matchAgainstMagicword( 'rawsuffix', $arg ) ) {
                        $func = array( $parser->getFunctionLang(), 'parseFormattedNumber' );
+               } elseif ( self::matchAgainstMagicword( 'nocommafysuffix', $arg ) ) {
+                       $func = array( $parser->getFunctionLang(), 'formatNumNoSeparators' );
                } else {
                        $func = array( $parser->getFunctionLang(), 'formatNum' );
                }
@@ -386,20 +388,23 @@ class CoreParserFunctions {
                return '';
        }
 
-       static function isRaw( $param ) {
-               static $mwRaw;
-               if ( !$mwRaw ) {
-                       $mwRaw =& MagicWord::get( 'rawsuffix' );
-               }
-               if ( is_null( $param ) ) {
+       /**
+        * Matches the given value against the value of given magic word
+        *
+        * @param string $magicword magic word key
+        * @param mixed $value value to match
+        * @return boolean true on successful match
+        */
+       static private function matchAgainstMagicword( $magicword, $value ) {
+               if ( strval( $value ) === '' ) {
                        return false;
-               } else {
-                       return $mwRaw->match( $param );
                }
+               $mwObject = MagicWord::get( $magicword );
+               return $mwObject->match( $value );
        }
 
        static function formatRaw( $num, $raw ) {
-               if( self::isRaw( $raw ) ) {
+               if( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
                        return $num;
                } else {
                        global $wgContLang;
@@ -422,7 +427,7 @@ class CoreParserFunctions {
                return self::formatRaw( SiteStats::images(), $raw );
        }
        static function numberofadmins( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::numberingroup('sysop'), $raw );
+               return self::formatRaw( SiteStats::numberingroup( 'sysop' ), $raw );
        }
        static function numberofedits( $parser, $raw = null ) {
                return self::formatRaw( SiteStats::edits(), $raw );
@@ -437,7 +442,6 @@ class CoreParserFunctions {
                return self::formatRaw( SiteStats::numberingroup( strtolower( $name ) ), $raw );
        }
 
-
        /**
         * Given a title, return the namespace name that would be given by the
         * corresponding magic word
@@ -585,7 +589,7 @@ class CoreParserFunctions {
                static $cache = array();
 
                // split the given option to its variable
-               if( self::isRaw( $arg1 ) ) {
+               if( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) {
                        //{{pagesincategory:|raw[|type]}}
                        $raw = $arg1;
                        $type = $magicWords->matchStartToEnd( $arg2 );
@@ -800,7 +804,7 @@ class CoreParserFunctions {
 
        // Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}}
        // or {{filepath|300px}}, {{filepath|200x300px}}, {{filepath|nowiki|200x300px}}, {{filepath|200x300px|nowiki}}
-       public static function filepath( $parser, $name='', $argA='', $argB='' ) {
+       public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
                $file = wfFindFile( $name );
 
                if( $argA == 'nowiki' ) {