r46808 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46807‎ | r46808 | r46809 >
Date:19:01, 4 February 2009
Author:ialex
Status:deferred
Tags:
Comment:
* (bug 17231) Transcluding special pages on wikis using language conversion no longer affects the page title
* Whitespaces tweaks in LanguageConverter.php
Please feel free to correct this if it's not the correct solution ;)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -357,10 +357,10 @@
358358 * prepare manual conversion table
359359 * @private
360360 */
361 - function prepareManualConv($convRule){
 361+ function prepareManualConv( $convRule ){
362362 // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
363363 $title = $convRule->getTitle();
364 - if($title){
 364+ if( $title ){
365365 $this->mTitleFromFlag = true;
366366 $this->mTitleDisplay = $title;
367367 }
@@ -368,20 +368,20 @@
369369 //apply manual conversion table to global table
370370 $convTable = $convRule->getConvTable();
371371 $action = $convRule->getRulesAction();
372 - foreach($convTable as $v=>$t) {
373 - if( !in_array($v,$this->mVariants) )continue;
 372+ foreach( $convTable as $v => $t ) {
 373+ if( !in_array( $v, $this->mVariants ) )continue;
374374 if( $action=="add" ) {
375 - foreach($t as $from=>$to) {
 375+ foreach( $t as $from => $to ) {
376376 // to ensure that $from and $to not be left blank
377377 // so $this->translate() could always return a string
378 - if ($from || $to)
 378+ if ( $from || $to )
379379 // more efficient than array_merge(), about 2.5 times.
380380 $this->mManualAddTables[$v][$from] = $to;
381381 }
382382 }
383 - elseif ( $action=="remove" ) {
384 - foreach($t as $from=>$to) {
385 - if ($from || $to)
 383+ elseif ( $action == "remove" ) {
 384+ foreach ( $t as $from=>$to ) {
 385+ if ( $from || $to )
386386 $this->mManualRemoveTables[$v][$from] = $to;
387387 }
388388 }
@@ -416,11 +416,13 @@
417417 return $text;
418418 }
419419
420 - if($wgDisableLangConversion)
 420+ if ( $wgDisableLangConversion )
421421 return $text;
422422
423423 $text = $this->convert( $text );
424 - $parser->mOutput->setTitleText( $this->mTitleDisplay );
 424+
 425+ if ( $this->mTitleFromFlag )
 426+ $parser->mOutput->setTitleText( $this->mTitleDisplay );
425427 return $text;
426428 }
427429
@@ -428,7 +430,7 @@
429431 * convert title
430432 * @private
431433 */
432 - function convertTitle($text){
 434+ function convertTitle( $text ){
433435 global $wgDisableTitleConversion, $wgUser;
434436
435437 // check for global param and __NOTC__ tag
@@ -438,7 +440,7 @@
439441 }
440442
441443 // use the title from the T flag if any
442 - if($this->mTitleFromFlag){
 444+ if( $this->mTitleFromFlag ){
443445 $this->mTitleFromFlag = false;
444446 return $this->mTitleDisplay;
445447 }
@@ -471,7 +473,7 @@
472474 * @return string converted text
473475 * @public
474476 */
475 - function convert( $text , $isTitle=false) {
 477+ function convert( $text, $isTitle = false ) {
476478
477479 $mw =& MagicWord::get( 'notitleconvert' );
478480 if( $mw->matchAndRemove( $text ) )
@@ -483,36 +485,36 @@
484486
485487 // no conversion if redirecting
486488 $mw =& MagicWord::get( 'redirect' );
487 - if( $mw->matchStart( $text ))
 489+ if( $mw->matchStart( $text ) )
488490 return $text;
489491
490492 // for title convertion
491 - if ($isTitle) return $this->convertTitle($text);
 493+ if ( $isTitle ) return $this->convertTitle( $text );
492494
493495 $plang = $this->getPreferredVariant();
494 - $tarray = StringUtils::explode($this->mMarkup['end'], $text);
 496+ $tarray = StringUtils::explode( $this->mMarkup['end'], $text );
495497 $text = '';
496498
497499 $marks = array();
498 - foreach($tarray as $txt) {
499 - $marked = explode($this->mMarkup['begin'], $txt, 2);
500 - if (array_key_exists(1, $marked)) {
 500+ foreach ( $tarray as $txt ) {
 501+ $marked = explode( $this->mMarkup['begin'], $txt, 2 );
 502+ if ( array_key_exists( 1, $marked ) ) {
501503 $crule = new ConverterRule($marked[1], $this);
502 - $crule->parse($plang);
 504+ $crule->parse( $plang );
503505 $marked[1] = $crule->getDisplay();
504 - $this->prepareManualConv($crule);
 506+ $this->prepareManualConv( $crule );
505507 }
506508 else
507509 $marked[0] .= $this->mMarkup['end'];
508 - array_push($marks, $marked);
 510+ array_push( $marks, $marked );
509511 }
510512 $this->applyManualConv();
511 - foreach ($marks as $marked) {
 513+ foreach ( $marks as $marked ) {
512514 if( $this->mDoContentConvert )
513 - $text .= $this->autoConvert($marked[0],$plang);
 515+ $text .= $this->autoConvert( $marked[0], $plang );
514516 else
515517 $text .= $marked[0];
516 - if( array_key_exists(1, $marked) )
 518+ if( array_key_exists( 1, $marked ) )
517519 $text .= $marked[1];
518520 }
519521 // Remove the last delimiter (wasn't real)
Index: trunk/phase3/RELEASE-NOTES
@@ -137,6 +137,8 @@
138138 * (bug 17283) Remove double URL escaping in show/hide links for log entries
139139 and RevisionDeleteForm::__construct
140140 * (bug 17105) Numeric table sorting broken
 141+* (bug 17231) Transcluding special pages on wikis using language conversion no
 142+ longer affects the page title
141143
142144 == API changes in 1.15 ==
143145 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions

Status & tagging log