From 2f2d9bd0c5f3715887bc95c8676039af222c6e8c Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 11 Sep 2011 20:32:58 +0000 Subject: [PATCH] (follow-up r96767) Make {{DEFAULTSORT:..|noerror}} and noreplace i18n-izable. Hopefully i did this right. I've never added a magic word before... --- includes/parser/CoreParserFunctions.php | 17 ++++++++++------- languages/messages/MessagesEn.php | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 54800bd2d7..fec8351370 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -678,24 +678,27 @@ class CoreParserFunctions { /** * @param $parser Parser * @param $text String The sortkey to use - * @param $arg String Either "noreplace" or "noerror" + * @param $uarg String Either "noreplace" or "noerror" (in en) * both suppress errors, and noreplace does nothing if * a default sortkey already exists. * @return string */ - public static function defaultsort( $parser, $text, $arg = '' ) { + public static function defaultsort( $parser, $text, $uarg = '' ) { + static $magicWords = null; + if ( is_null( $magicWords ) ) { + $magicWords = new MagicWordArray( array( 'defaultsort_noerror', 'defaultsort_noreplace' ) ); + } + $arg = $magicWords->matchStartToEnd( $uarg ); + $text = trim( $text ); - $arg = trim( strtolower( $arg ) ); if( strlen( $text ) == 0 ) return ''; $old = $parser->getCustomDefaultSort(); - if ( $old === false || $arg !== 'noreplace' ) { + if ( $old === false || $arg !== 'defaultsort_noreplace' ) { $parser->setDefaultSort( $text ); } - if( $old === false || $old == $text || $arg === 'noreplace' - || $arg === 'noerror' ) - { + if( $old === false || $old == $text || $arg ) { return ''; } else { return( '' . diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b50aeb8ae2..a563be7494 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -350,6 +350,8 @@ $magicWords = array( 'url_path' => array( 0, 'PATH' ), 'url_wiki' => array( 0, 'WIKI' ), 'url_query' => array( 0, 'QUERY' ), + 'defaultsort_noerror' => array( 0, 'noerror' ), + 'defaultsort_noreplace' => array( 0, 'noreplace' ), ); /** -- 2.20.1