Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | * to internalParse() which does all the real work. |
305 | 305 | */ |
306 | 306 | |
307 | | - global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion, $wgUser, $wgRequest; |
| 307 | + global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion; |
308 | 308 | $fname = __METHOD__.'-' . wfGetCaller(); |
309 | 309 | wfProfileIn( __METHOD__ ); |
310 | 310 | wfProfileIn( $fname ); |
— | — | @@ -377,16 +377,16 @@ |
378 | 378 | */ |
379 | 379 | if ( !( $wgDisableLangConversion |
380 | 380 | || $wgDisableTitleConversion |
381 | | - || $wgRequest->getText( 'redirect', 'yes' ) == 'no' |
382 | | - || $wgRequest->getText( 'linkconvert', 'yes' ) == 'no' |
383 | 381 | || isset( $this->mDoubleUnderscores['nocontentconvert'] ) |
384 | 382 | || isset( $this->mDoubleUnderscores['notitleconvert'] ) |
385 | | - || $wgUser->getOption( 'noconvertlink' ) == 1 ) ) { |
| 383 | + || $this->mOutput->getDisplayTitle() !== false ) ) |
| 384 | + { |
386 | 385 | $convruletitle = $wgContLang->getConvRuleTitle(); |
387 | 386 | if ( $convruletitle ) { |
388 | 387 | $this->mOutput->setTitleText( $convruletitle ); |
389 | 388 | } else { |
390 | | - $this->mOutput->setTitleText( $wgContLang->convert( $title->getPrefixedText(), true ) ); |
| 389 | + $titleText = $wgContLang->convertTitle( $title ); |
| 390 | + $this->mOutput->setTitleText( $titleText ); |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | var $mMetatags = array(), $mKeywords = array(), $mLinktags = array(); |
11 | 11 | var $mExtStyles = array(); |
12 | 12 | var $mPagetitle = '', $mBodytext = '', $mDebugtext = ''; |
13 | | - var $mHTMLtitle = '', $mHTMLtitleFromPagetitle = true, $mIsarticle = true, $mPrintable = false; |
| 13 | + var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false; |
14 | 14 | var $mSubtitle = '', $mRedirect = '', $mStatusCode; |
15 | 15 | var $mLastModified = '', $mETag = false; |
16 | 16 | var $mCategoryLinks = array(), $mCategories = array(), $mLanguageLinks = array(); |
— | — | @@ -447,17 +447,9 @@ |
448 | 448 | /** |
449 | 449 | * "HTML title" means the contents of <title>. |
450 | 450 | * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file. |
451 | | - * If $name is from page title, it can only override names which are also from page title, |
452 | | - * but if it is not from page title, it can override all other names. |
453 | 451 | */ |
454 | | - public function setHTMLTitle( $name, $frompagetitle = false ) { |
455 | | - if ( $frompagetitle && $this->mHTMLtitleFromPagetitle ) { |
456 | | - $this->mHTMLtitle = $name; |
457 | | - } |
458 | | - elseif ( $this->mHTMLtitleFromPagetitle ) { |
459 | | - $this->mHTMLtitle = $name; |
460 | | - $this->mHTMLtitleFromPagetitle = false; |
461 | | - } |
| 452 | + public function setHTMLTitle( $name ) { |
| 453 | + $this->mHTMLtitle = $name; |
462 | 454 | } |
463 | 455 | |
464 | 456 | /** |
— | — | @@ -1104,11 +1096,6 @@ |
1105 | 1097 | $this->mTemplateIds[$ns] = $dbks; |
1106 | 1098 | } |
1107 | 1099 | } |
1108 | | - // Page title |
1109 | | - $title = $parserOutput->getTitleText(); |
1110 | | - if ( $title != '' ) { |
1111 | | - $this->setPageTitle( $title ); |
1112 | | - } |
1113 | 1100 | |
1114 | 1101 | // Hooks registered in the object |
1115 | 1102 | global $wgParserOutputHooks; |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -956,6 +956,12 @@ |
957 | 957 | } |
958 | 958 | } |
959 | 959 | |
| 960 | + # Adjust the title if it was set by displaytitle, -{T|}- or language conversion |
| 961 | + $titleText = $this->mParserOutput->getTitleText(); |
| 962 | + if ( strval( $titleText ) !== '' ) { |
| 963 | + $wgOut->setPageTitle( $titleText ); |
| 964 | + } |
| 965 | + |
960 | 966 | # Now that we've filled $this->mParserOutput, we know whether |
961 | 967 | # there are any __NOINDEX__ tags on the page |
962 | 968 | $policy = $this->getRobotPolicy( 'view' ); |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -516,24 +516,6 @@ |
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
520 | | - * Convert namespace. |
521 | | - * @param $title String: the title included namespace |
522 | | - * @return Array of string |
523 | | - * @private |
524 | | - */ |
525 | | - function convertNamespace( $title, $variant ) { |
526 | | - $splittitle = explode( ':', $title, 2 ); |
527 | | - if ( count( $splittitle ) < 2 ) { |
528 | | - return $title; |
529 | | - } |
530 | | - if ( isset( $this->mNamespaceTables[$variant][$splittitle[0]] ) ) { |
531 | | - $splittitle[0] = $this->mNamespaceTables[$variant][$splittitle[0]]; |
532 | | - } |
533 | | - $ret = implode( ':', $splittitle ); |
534 | | - return $ret; |
535 | | - } |
536 | | - |
537 | | - /** |
538 | 520 | * Convert text to different variants of a language. The automatic |
539 | 521 | * conversion is done in autoConvert(). Here we parse the text |
540 | 522 | * marked with -{}-, which specifies special conversions of the |
— | — | @@ -547,19 +529,34 @@ |
548 | 530 | * @param $text String: text to be converted |
549 | 531 | * @return String: converted text |
550 | 532 | */ |
551 | | - public function convert( $text, $istitle = false ) { |
| 533 | + public function convert( $text ) { |
552 | 534 | global $wgDisableLangConversion; |
553 | 535 | if ( $wgDisableLangConversion ) return $text; |
554 | 536 | |
555 | 537 | $variant = $this->getPreferredVariant(); |
556 | 538 | |
557 | | - if( $istitle ) { |
558 | | - $text = $this->convertNamespace( $text, $variant ); |
559 | | - } |
560 | | - |
561 | 539 | return $this->recursiveConvertTopLevel( $text, $variant ); |
562 | 540 | } |
563 | 541 | |
| 542 | + /** |
| 543 | + * Convert a Title object to a readable string in the preferred variant |
| 544 | + */ |
| 545 | + public function convertTitle( $title ) { |
| 546 | + $variant = $this->getPreferredVariant(); |
| 547 | + if ( $title->getNamespace() === NS_MAIN ) { |
| 548 | + $text = ''; |
| 549 | + } else { |
| 550 | + $text = $title->getNsText(); |
| 551 | + if ( isset( $this->mNamespaceTables[$variant][$text] ) ) { |
| 552 | + $text = $this->mNamespaceTables[$variant][$text]; |
| 553 | + } |
| 554 | + $text .= ':'; |
| 555 | + } |
| 556 | + $text .= $title->getText(); |
| 557 | + $text = $this->autoConvert( $text, $variant ); |
| 558 | + return $text; |
| 559 | + } |
| 560 | + |
564 | 561 | protected function recursiveConvertTopLevel( $text, $variant, $depth = 0 ) { |
565 | 562 | $startPos = 0; |
566 | 563 | $out = ''; |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -36,7 +36,8 @@ |
37 | 37 | var $mLang; |
38 | 38 | function FakeConverter( $langobj ) { $this->mLang = $langobj; } |
39 | 39 | function autoConvertToAllVariants( $text ) { return $text; } |
40 | | - function convert( $t, $i ) { return $t; } |
| 40 | + function convert( $t ) { return $t; } |
| 41 | + function convertTitle( $t ) { return $t->getPrefixedText(); } |
41 | 42 | function getVariants() { return array( $this->mLang->getCode() ); } |
42 | 43 | function getPreferredVariant() { return $this->mLang->getCode(); } |
43 | 44 | function getConvRuleTitle() { return false; } |
— | — | @@ -2606,10 +2607,15 @@ |
2607 | 2608 | } |
2608 | 2609 | |
2609 | 2610 | # convert text to different variants of a language. |
2610 | | - function convert( $text, $isTitle = false ) { |
2611 | | - return $this->mConverter->convert( $text, $isTitle ); |
| 2611 | + function convert( $text ) { |
| 2612 | + return $this->mConverter->convert( $text ); |
2612 | 2613 | } |
2613 | 2614 | |
| 2615 | + # Convert a Title object to a string in the preferred variant |
| 2616 | + function convertTitle( $title ) { |
| 2617 | + return $this->mConverter->convertTitle( $title ); |
| 2618 | + } |
| 2619 | + |
2614 | 2620 | # Check if this is a language with variants |
2615 | 2621 | function hasVariants() { |
2616 | 2622 | return sizeof( $this->getVariants() ) > 1; |