From 9db190c7e736ec8d063187d4241b59feaf7dc2d1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 22 Jun 2011 11:28:20 +0200 Subject: update to MediaWiki 1.17.0 --- includes/parser/CoreParserFunctions.php | 64 ++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 17 deletions(-) (limited to 'includes/parser/CoreParserFunctions.php') diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 8abcc04f..94949221 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -1,4 +1,9 @@ setFunctionHook( 'int', array( __CLASS__, 'intFunction' ), SFH_NO_HASH ); @@ -81,7 +86,7 @@ class CoreParserFunctions { static function intFunction( $parser, $part1 = '' /*, ... */ ) { if ( strval( $part1 ) !== '' ) { $args = array_slice( func_get_args(), 2 ); - $message = wfMsgGetKey( $part1, true, false, false ); + $message = wfMsgGetKey( $part1, true, $parser->getOptions()->getUserLang(), false ); $message = wfMsgReplaceArgs( $message, $args ); $message = $parser->replaceVariables( $message ); // like $wgMessageCache->transform() return $message; @@ -95,7 +100,7 @@ class CoreParserFunctions { $date = trim( $date ); - $pref = $parser->mOptions->getDateFormat(); + $pref = $parser->getOptions()->getDateFormat(); // Specify a different default date format other than the the normal default // iff the user has 'default' for their setting @@ -124,8 +129,37 @@ class CoreParserFunctions { return wfUrlencode( str_replace( ' ', '_', self::ns( $parser, $part1 ) ) ); } - static function urlencode( $parser, $s = '' ) { - return urlencode( $s ); + /** + * urlencodes a string according to one of three patterns: (bug 22474) + * + * By default (for HTTP "query" strings), spaces are encoded as '+'. + * Or to encode a value for the HTTP "path", spaces are encoded as '%20'. + * For links to "wiki"s, or similar software, spaces are encoded as '_', + * + * @param $parser Parser object + * @param $s String: The text to encode. + * @param $arg String (optional): The type of encoding. + */ + static function urlencode( $parser, $s = '', $arg = null ) { + static $magicWords = null; + if ( is_null( $magicWords ) ) { + $magicWords = new MagicWordArray( array( 'url_path', 'url_query', 'url_wiki' ) ); + } + switch( $magicWords->matchStartToEnd( $arg ) ) { + + // Encode as though it's a wiki page, '_' for ' '. + case 'url_wiki': + return wfUrlencode( str_replace( ' ', '_', $s ) ); + + // Encode for an HTTP Path, '%20' for ' '. + case 'url_path': + return rawurlencode( $s ); + + // Encode for HTTP query, '+' for ' '. + case 'url_query': + default: + return urlencode( $s ); + } } static function lcfirst( $parser, $s = '' ) { @@ -214,7 +248,7 @@ class CoreParserFunctions { $user = User::newFromName( $user ); if ( $user ) { $gender = $user->getOption( 'gender' ); - } elseif ( $parser->mOptions->getInterfaceMessage() ) { + } elseif ( $parser->getOptions()->getInterfaceMessage() ) { global $wgUser; $gender = $wgUser->getOption( 'gender' ); } @@ -553,17 +587,14 @@ class CoreParserFunctions { } static function anchorencode( $parser, $text ) { - $a = urlencode( $text ); - $a = strtr( $a, array( '%' => '.', '+' => '_' ) ); - # leave colons alone, however - $a = str_replace( '.3A', ':', $a ); - return $a; + return substr( $parser->guessSectionNameFromWikiText( $text ), 1); } static function special( $parser, $text ) { - $title = SpecialPage::getTitleForAlias( $text ); - if ( $title ) { - return $title->getPrefixedText(); + list( $page, $subpage ) = SpecialPage::resolveAliasWithSubpage( $text ); + if ( $page ) { + $title = SpecialPage::getTitleFor( $page, $subpage ); + return $title; } else { return wfMsgForContent( 'nosuchspecialpage' ); } @@ -579,7 +610,7 @@ class CoreParserFunctions { return ''; else return( '' . - wfMsg( 'duplicate-defaultsort', + wfMsgForContent( 'duplicate-defaultsort', htmlspecialchars( $old ), htmlspecialchars( $text ) ) . '' ); @@ -602,7 +633,6 @@ class CoreParserFunctions { * Parser function to extension tag adaptor */ public static function tagObj( $parser, $frame, $args ) { - $xpath = false; if ( !count( $args ) ) { return ''; } @@ -617,7 +647,7 @@ class CoreParserFunctions { $stripList = $parser->getStripList(); if ( !in_array( $tagName, $stripList ) ) { return '' . - wfMsg( 'unknown_extension_tag', $tagName ) . + wfMsgForContent( 'unknown_extension_tag', $tagName ) . ''; } -- cgit v1.2.3-54-g00ecf