X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fparser%2FCoreParserFunctions.php;h=0c745c9f18497efd77ed16dfbb7ae9f06b53b89c;hb=18a53cb48bc5848e490f3bc1c444e26ef8bc8299;hp=8ab5c31433c2145069de71512e0106600c3d4b1e;hpb=937fb7eedcca1af78785e8e156b7ff69b1447101;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 8ab5c31433..0c745c9f18 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -90,13 +90,13 @@ class CoreParserFunctions { /** * @param Parser $parser - * @param string $part1 + * @param string $part1 Message key + * @param mixed ...$params To pass to wfMessage() * @return array */ - public static function intFunction( $parser, $part1 = '' /*, ... */ ) { + public static function intFunction( $parser, $part1 = '', ...$params ) { if ( strval( $part1 ) !== '' ) { - $args = array_slice( func_get_args(), 2 ); - $message = wfMessage( $part1, $args ) + $message = wfMessage( $part1, $params ) ->inLanguage( $parser->getOptions()->getUserLangObj() ); return [ $message->plain(), 'noparse' => false ]; } else { @@ -113,7 +113,7 @@ class CoreParserFunctions { */ public static function formatDate( $parser, $date, $defaultPref = null ) { $lang = $parser->getFunctionLang(); - $df = DateFormatter::getInstance( $lang ); + $df = MediaWikiServices::getInstance()->getDateFormatterFactory()->get( $lang ); $date = trim( $date ); @@ -313,11 +313,10 @@ class CoreParserFunctions { /** * @param Parser $parser * @param string $username + * @param string ...$forms What to output for each gender * @return string */ - public static function gender( $parser, $username ) { - $forms = array_slice( func_get_args(), 2 ); - + public static function gender( $parser, $username, ...$forms ) { // Some shortcuts to avoid loading user data unnecessarily if ( count( $forms ) === 0 ) { return ''; @@ -327,7 +326,6 @@ class CoreParserFunctions { $username = trim( $username ); - // default $gender = User::getDefaultOption( 'gender' ); // allow prefix and normalize (e.g. "*foo" -> "*foo" ). @@ -352,10 +350,10 @@ class CoreParserFunctions { /** * @param Parser $parser * @param string $text + * @param string ...$forms What to output for each number (singular, dual, plural, etc.) * @return string */ - public static function plural( $parser, $text = '' ) { - $forms = array_slice( func_get_args(), 2 ); + public static function plural( $parser, $text = '', ...$forms ) { $text = $parser->getFunctionLang()->parseFormattedNumber( $text ); settype( $text, ctype_digit( $text ) ? 'int' : 'float' ); return $parser->getFunctionLang()->convertPlural( $text, $forms ); @@ -516,6 +514,7 @@ class CoreParserFunctions { public static function numberofusers( $parser, $raw = null ) { return self::formatRaw( SiteStats::users(), $raw, $parser->getFunctionLang() ); } + public static function numberofactiveusers( $parser, $raw = null ) { return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getFunctionLang() ); } @@ -547,6 +546,7 @@ class CoreParserFunctions { $parser->getFunctionLang() ); } + public static function numberingroup( $parser, $name = '', $raw = null ) { return self::formatRaw( SiteStats::numberingroup( strtolower( $name ) ), @@ -571,6 +571,7 @@ class CoreParserFunctions { } return str_replace( '_', ' ', $t->getNsText() ); } + public static function namespacee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -578,6 +579,7 @@ class CoreParserFunctions { } return wfUrlencode( $t->getNsText() ); } + public static function namespacenumber( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -585,6 +587,7 @@ class CoreParserFunctions { } return $t->getNamespace(); } + public static function talkspace( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canHaveTalkPage() ) { @@ -592,6 +595,7 @@ class CoreParserFunctions { } return str_replace( '_', ' ', $t->getTalkNsText() ); } + public static function talkspacee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canHaveTalkPage() ) { @@ -599,6 +603,7 @@ class CoreParserFunctions { } return wfUrlencode( $t->getTalkNsText() ); } + public static function subjectspace( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -606,6 +611,7 @@ class CoreParserFunctions { } return str_replace( '_', ' ', $t->getSubjectNsText() ); } + public static function subjectspacee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -628,6 +634,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getText() ); } + public static function pagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -635,6 +642,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getPartialURL() ); } + public static function fullpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canHaveTalkPage() ) { @@ -642,6 +650,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getPrefixedText() ); } + public static function fullpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canHaveTalkPage() ) { @@ -649,6 +658,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getPrefixedURL() ); } + public static function subpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -656,6 +666,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getSubpageText() ); } + public static function subpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -663,6 +674,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getSubpageUrlForm() ); } + public static function rootpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -670,6 +682,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getRootText() ); } + public static function rootpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -677,6 +690,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getRootText() ) ) ); } + public static function basepagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -684,6 +698,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getBaseText() ); } + public static function basepagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -691,6 +706,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getBaseText() ) ) ); } + public static function talkpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canHaveTalkPage() ) { @@ -698,6 +714,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() ); } + public static function talkpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canHaveTalkPage() ) { @@ -705,6 +722,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() ); } + public static function subjectpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) { @@ -712,6 +730,7 @@ class CoreParserFunctions { } return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() ); } + public static function subjectpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) {