Add "raw suffix" magic word for some magic words, e.g. {{NUMBEROFUSERS|R}} will produ...
authorRob Church <robchurch@users.mediawiki.org>
Sun, 30 Apr 2006 18:02:03 +0000 (18:02 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sun, 30 Apr 2006 18:02:03 +0000 (18:02 +0000)
RELEASE-NOTES
includes/MagicWord.php
includes/Parser.php
languages/Language.php

index f790e0a..14a5cd2 100644 (file)
@@ -155,7 +155,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 5284) Special redirect pages should remember parameters
 * Suppress 7za output on dumpBackup
 * (bug 5338) Reject extra initial colons in title
- (bug 5487) Escape self-closed HTML pair tags.
+* (bug 5487) Escape self-closed HTML pair tags
+* Add "raw suffix" magic word for some magic words, e.g. {{NUMBEROFUSERS|R}} will
+  produce a count minus formatting
 
 == Compatibility ==
 
index 54f4b0a..0345cd2 100644 (file)
@@ -82,6 +82,7 @@ $magicWords = array(
        'MAG_SUBJECTPAGENAME',
        'MAG_SUBJECTPAGENAMEE', 
        'MAG_NUMBEROFUSERS',
+       'MAG_RAWSUFFIX',
 );
 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
        wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
@@ -126,6 +127,7 @@ $wgVariableIDs = array(
        MAG_SUBJECTPAGENAME,
        MAG_SUBJECTPAGENAMEE,
        MAG_NUMBEROFUSERS,
+       MAG_RAWSUFFIX,
 );
 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
        wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
index c331144..c9c96d6 100644 (file)
@@ -2664,6 +2664,39 @@ class Parser
                        }
                }               
 
+               # NUMBEROFUSERS, NUMBEROFARTICLES, and NUMBEROFFILES
+               if( !$found ) {
+                       $mwWordsToCheck = array( MAG_NUMBEROFUSERS => 'wfNumberOfUsers', MAG_NUMBEROFARTICLES => 'wfNumberOfArticles', MAG_NUMBEROFFILES => 'wfNumberOfFiles' );
+                       foreach( $mwWordsToCheck as $word => $func ) {
+                               $mwCurrentWord =& MagicWord::get( $word );
+                               if( $mwCurrentWord->matchStartAndRemove( $part1 ) ) {
+                                       $mwRawSuffix =& MagicWord::get( MAG_RAWSUFFIX );
+                                       if( $mwRawSuffix->match( $args[0] ) ) {
+                                               # Raw and unformatted
+                                               $text = $linestart . call_user_func( $func );
+                                       } else {
+                                               # Formatted according to the content default
+                                               $text = $linestart . $wgContLang->formatNum( call_user_func( $func ) );
+                                       }
+                                       $found = true;
+                               }
+                       }
+               }
+               
+                       /*$mwNumUsers =& MagicWord::get( MAG_NUMBEROFUSERS );
+                       if( $mwNumUsers->matchStartAndRemove( $part1 ) ) {
+                               $mwRawSuffix =& MagicWord::get( MAG_RAWSUFFIX );
+                               if( $mwRawSuffix->match( $args[0] ) ) {
+                                       # Raw and unformatted
+                                       $text = $linestart . wfNumberOfUsers();
+                               } else {
+                                       # Default; formatted form
+                                       $text = $linestart . $wgContLang->formatNum( wfNumberOfUsers() );
+                               }
+                               $found = true;
+                       }
+               }*/
+
                # Extensions
                if ( !$found && substr( $part1, 0, 1 ) == '#' ) {
                        $colonPos = strpos( $part1, ':' );
index 70ca629..4051a5f 100644 (file)
@@ -280,6 +280,7 @@ $wgLanguageNamesEn =& $wgLanguageNames;
        MAG_UC                   => array( 0,    'UC:'                    ),
        MAG_RAW                  => array( 0,    'RAW:'                   ),
        MAG_DISPLAYTITLE         => array( 1,    'DISPLAYTITLE'           ),
+       MAG_RAWSUFFIX                    => array( 1,    'R'                                      ),
 );
 
 if (!$wgCachedMessageArrays) {