Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -22,7 +22,6 @@ |
23 | 23 | var $mTablesLoaded = false; |
24 | 24 | var $mTables; |
25 | 25 | var $mNamespaceTables; |
26 | | - var $mTitleDisplay=''; |
27 | 26 | var $mDoTitleConvert=true, $mDoContentConvert=true; |
28 | 27 | var $mManualLevel; // 'bidirectional' 'unidirectional' 'disable' for each variants |
29 | 28 | var $mTitleFromFlag = false; |
— | — | @@ -32,6 +31,8 @@ |
33 | 32 | var $mFlags; |
34 | 33 | var $mDescCodeSep = ':',$mDescVarSep = ';'; |
35 | 34 | var $mUcfirst = false; |
| 35 | + var $mTitleOriginal = ''; |
| 36 | + var $mTitleDisplay = ''; |
36 | 37 | |
37 | 38 | const CACHE_VERSION_KEY = 'VERSION 6'; |
38 | 39 | |
— | — | @@ -439,8 +440,9 @@ |
440 | 441 | |
441 | 442 | $text = $this->convert( $text ); |
442 | 443 | |
443 | | - if ( $this->mTitleFromFlag ) |
444 | | - $parser->mOutput->setTitleText( $this->mTitleDisplay ); |
| 444 | + $this->convertTitle(); |
| 445 | + $parser->mOutput->setTitleText( $this->mTitleDisplay ); |
| 446 | + |
445 | 447 | return $text; |
446 | 448 | } |
447 | 449 | |
— | — | @@ -461,35 +463,37 @@ |
462 | 464 | } |
463 | 465 | |
464 | 466 | /** |
| 467 | + * Pre convert title. Store the original title $this->mTitleOrginal; |
| 468 | + * store the default converted title to $this->mTitleDisplay. |
| 469 | + * @private |
| 470 | + */ |
| 471 | + function preConvertTitle( $text, $variant ){ |
| 472 | + $this->mTitleOriginal = $text; |
| 473 | + |
| 474 | + $text = $this->convertNamespace( $text, $variant ); |
| 475 | + $this->mTitleDisplay = $this->convert( $text ); |
| 476 | + } |
| 477 | + |
| 478 | + /** |
465 | 479 | * convert title |
466 | 480 | * @private |
467 | 481 | */ |
468 | | - function convertTitle( $text, $variant ){ |
469 | | - global $wgDisableTitleConversion, $wgUser; |
470 | | - |
471 | | - // check for global param and __NOTC__ tag |
472 | | - if( $wgDisableTitleConversion || !$this->mDoTitleConvert || $wgUser->getOption('noconvertlink') == 1 ) { |
473 | | - $this->mTitleDisplay = $text; |
474 | | - return $text; |
475 | | - } |
476 | | - |
477 | | - // use the title from the T flag if any |
478 | | - if( $this->mTitleFromFlag ){ |
479 | | - $this->mTitleFromFlag = false; |
480 | | - return $this->mTitleDisplay; |
481 | | - } |
482 | | - |
483 | | - global $wgRequest; |
| 482 | + function convertTitle(){ |
| 483 | + global $wgDisableTitleConversion, $wgUser, $wgRequest; |
484 | 484 | $isredir = $wgRequest->getText( 'redirect', 'yes' ); |
485 | 485 | $action = $wgRequest->getText( 'action' ); |
486 | 486 | $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' ); |
487 | | - if ( $isredir == 'no' || $action == 'edit' || $action == 'submit' || $linkconvert == 'no' ) { |
488 | | - return $text; |
489 | | - } else { |
490 | | - $text = $this->convertNamespace( $text, $variant ); |
491 | | - $this->mTitleDisplay = $this->convert( $text ); |
492 | | - return $this->mTitleDisplay; |
| 487 | + |
| 488 | + // check for the global variable, __NOTC__ magic word, and user setting |
| 489 | + if( $wgDisableTitleConversion || !$this->mDoTitleConvert || |
| 490 | + $wgUser->getOption('noconvertlink') == 1 ) { |
| 491 | + $this->mTitleDisplay = $this->mTitleOriginal; |
493 | 492 | } |
| 493 | + |
| 494 | + // check for GET params |
| 495 | + elseif ( $isredir == 'no' || $action == 'edit' || $linkconvert == 'no' ) { |
| 496 | + $this->mTitleDisplay = $this->mTitleOriginal; |
| 497 | + } |
494 | 498 | } |
495 | 499 | |
496 | 500 | /** |
— | — | @@ -526,7 +530,10 @@ |
527 | 531 | $plang = $this->getPreferredVariant(); |
528 | 532 | |
529 | 533 | // for title convertion |
530 | | - if ( $isTitle ) return $this->convertTitle( $text, $plang ); |
| 534 | + if ( $isTitle ) { |
| 535 | + $this->preConvertTitle( $text, $plang ); |
| 536 | + return $text; |
| 537 | + } |
531 | 538 | |
532 | 539 | $tarray = StringUtils::explode( $this->mMarkup['end'], $text ); |
533 | 540 | $text = ''; |