r96809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96808‎ | r96809 | r96810 >
Date:20:32, 11 September 2011
Author:bawolff
Status:ok (Comments)
Tags:todo 
Comment:
(follow-up r96767) Make {{DEFAULTSORT:..|noerror}} and noreplace i18n-izable.

Hopefully i did this right. I've never added a magic word before...
Modified paths:
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -678,24 +678,27 @@
679679 /**
680680 * @param $parser Parser
681681 * @param $text String The sortkey to use
682 - * @param $arg String Either "noreplace" or "noerror"
 682+ * @param $uarg String Either "noreplace" or "noerror" (in en)
683683 * both suppress errors, and noreplace does nothing if
684684 * a default sortkey already exists.
685685 * @return string
686686 */
687 - public static function defaultsort( $parser, $text, $arg = '' ) {
 687+ public static function defaultsort( $parser, $text, $uarg = '' ) {
 688+ static $magicWords = null;
 689+ if ( is_null( $magicWords ) ) {
 690+ $magicWords = new MagicWordArray( array( 'defaultsort_noerror', 'defaultsort_noreplace' ) );
 691+ }
 692+ $arg = $magicWords->matchStartToEnd( $uarg );
 693+
688694 $text = trim( $text );
689 - $arg = trim( strtolower( $arg ) );
690695 if( strlen( $text ) == 0 )
691696 return '';
692697 $old = $parser->getCustomDefaultSort();
693 - if ( $old === false || $arg !== 'noreplace' ) {
 698+ if ( $old === false || $arg !== 'defaultsort_noreplace' ) {
694699 $parser->setDefaultSort( $text );
695700 }
696701
697 - if( $old === false || $old == $text || $arg === 'noreplace'
698 - || $arg === 'noerror' )
699 - {
 702+ if( $old === false || $old == $text || $arg ) {
700703 return '';
701704 } else {
702705 return( '<span class="error">' .
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -350,6 +350,8 @@
351351 'url_path' => array( 0, 'PATH' ),
352352 'url_wiki' => array( 0, 'WIKI' ),
353353 'url_query' => array( 0, 'QUERY' ),
 354+ 'defaultsort_noerror' => array( 0, 'noerror' ),
 355+ 'defaultsort_noreplace' => array( 0, 'noreplace' ),
354356 );
355357
356358 /**

Sign-offs

UserFlagDate
Nikerabbitinspected07:34, 12 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96767(bug 16755) Add syntax to DEFAULTSORT - {{DEFAULTSORT:Foo|noerror}} and {{DEF...bawolff02:20, 11 September 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   01:27, 4 November 2011

'if( $old === false || $old == $text || $arg ) {' could use documentation.

Status & tagging log