From: Rob Church Date: Sun, 30 Apr 2006 18:02:03 +0000 (+0000) Subject: Add "raw suffix" magic word for some magic words, e.g. {{NUMBEROFUSERS|R}} will produ... X-Git-Tag: 1.31.0-rc.0~57303 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=35670dacb953a62e1d23ecaad13fc0c8c6eaff36;p=lhc%2Fweb%2Fwiklou.git Add "raw suffix" magic word for some magic words, e.g. {{NUMBEROFUSERS|R}} will produce a count minus formatting --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f790e0a1e1..14a5cd27a0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 54f4b0adb6..0345cd2f7e 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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 ) ); diff --git a/includes/Parser.php b/includes/Parser.php index c331144591..c9c96d62b3 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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, ':' ); diff --git a/languages/Language.php b/languages/Language.php index 70ca629768..4051a5fbf2 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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) {