Index: trunk/phase3/includes/CategoryPage.php |
— | — | @@ -506,19 +506,18 @@ |
507 | 507 | * @private |
508 | 508 | */ |
509 | 509 | function formatList( $articles, $articles_start_char, $cutoff = 6 ) { |
| 510 | + $list = ''; |
510 | 511 | if ( count ( $articles ) > $cutoff ) { |
511 | 512 | $list = self::columnList( $articles, $articles_start_char ); |
512 | 513 | } elseif ( count( $articles ) > 0 ) { |
513 | 514 | // for short lists of articles in categories. |
514 | 515 | $list = self::shortList( $articles, $articles_start_char ); |
515 | 516 | } |
516 | | - global $wgBetterDirectionality; |
| 517 | + global $wgBetterDirectionality, $wgTitle; |
517 | 518 | if( $wgBetterDirectionality ) { |
518 | | - global $wgOut, $wgContLang; |
519 | | - $getPageLang = $wgOut->parserOptions()->getTargetLanguage(); |
520 | | - $pageLang = ( $getPageLang ? Language::factory( $getPageLang ) : $wgContLang ); |
521 | | - $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
522 | | - $list = Html::rawElement( 'div', $realBodyAttribs, $list ); |
| 519 | + $pageLang = $wgTitle->getPageLanguage(); |
| 520 | + $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
| 521 | + $list = Html::rawElement( 'div', $attribs, $list ); |
523 | 522 | } |
524 | 523 | |
525 | 524 | return $list; |
Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -936,14 +936,12 @@ |
937 | 937 | * @return string |
938 | 938 | */ |
939 | 939 | static function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) { |
940 | | - global $wgBetterDirectionality; |
| 940 | + global $wgBetterDirectionality, $wgTitle; |
941 | 941 | $dirclass = ''; |
942 | 942 | if( $wgBetterDirectionality ) { |
943 | | - global $wgContLang, $wgOut, $wgTitle; |
944 | 943 | // shared.css sets diff in interface language/dir, |
945 | 944 | // but the actual content should be in the page language/dir |
946 | | - $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $wgTitle ); |
947 | | - $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); |
| 945 | + $pageLang = $wgTitle->getPageLanguage(); |
948 | 946 | $dirclass = ' diff-contentalign-'.$pageLang->alignStart(); |
949 | 947 | } |
950 | 948 | $header = "<table class='diff $dirclass'>"; |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -66,17 +66,7 @@ |
67 | 67 | function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; } |
68 | 68 | function getTidy() { return $this->mTidy; } |
69 | 69 | function getInterfaceMessage() { return $this->mInterfaceMessage; } |
70 | | - function getTargetLanguage( $title = null ) { |
71 | | - if ( $title && $title->isCssOrJsPage() ) { |
72 | | - return Language::factory( 'en' ); // css/js should always be LTR |
73 | | - } elseif ( $title && $title->getNamespace() == NS_MEDIAWIKI ) { |
74 | | - // Parse mediawiki messages with correct target language |
75 | | - list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() ); |
76 | | - $obj = wfGetLangObj( $lang ); |
77 | | - return $obj; |
78 | | - } |
79 | | - return $this->mTargetLanguage; |
80 | | -} |
| 70 | + function getTargetLanguage() { return $this->mTargetLanguage; } |
81 | 71 | function getMaxIncludeSize() { return $this->mMaxIncludeSize; } |
82 | 72 | function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; } |
83 | 73 | function getMaxPPExpandDepth() { return $this->mMaxPPExpandDepth; } |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -1817,8 +1817,7 @@ |
1818 | 1818 | |
1819 | 1819 | global $wgBetterDirectionality, $wgContLang; |
1820 | 1820 | if( $wgBetterDirectionality ) { |
1821 | | - $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle ); |
1822 | | - $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); |
| 1821 | + $pageLang = $this->mTitle->getPageLanguage(); |
1823 | 1822 | $attribs['lang'] = $pageLang->getCode(); |
1824 | 1823 | $attribs['dir'] = $pageLang->getDir(); |
1825 | 1824 | } |
— | — | @@ -2066,6 +2065,12 @@ |
2067 | 2066 | |
2068 | 2067 | wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) ); |
2069 | 2068 | |
| 2069 | + // In which language to parse the page |
| 2070 | + // (Should this still be only for MediaWiki pages, or for all pages?) |
| 2071 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 2072 | + $parserOptions->setTargetLanguage( $this->mTitle->getPageLanguage() ); |
| 2073 | + } |
| 2074 | + $parserOptions->setTargetLanguage( $this->mTitle->getPageLanguage() ); |
2070 | 2075 | $parserOptions->setTidy( true ); |
2071 | 2076 | $parserOptions->enableLimitReport(); |
2072 | 2077 | $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ), |
— | — | @@ -2091,12 +2096,11 @@ |
2092 | 2097 | '<h2 id="mw-previewheader">' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>" . |
2093 | 2098 | $wgOut->parse( $note ) . $conflict . "</div>\n"; |
2094 | 2099 | |
2095 | | - global $wgBetterDirectionality, $wgContLang; |
| 2100 | + global $wgBetterDirectionality; |
2096 | 2101 | if( $wgBetterDirectionality ) { |
2097 | | - $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle ); |
2098 | | - $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); |
2099 | | - $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
2100 | | - $previewHTML = Html::rawElement( 'div', $realBodyAttribs, $previewHTML ); |
| 2102 | + $pageLang = $this->mTitle->getPageLanguage(); |
| 2103 | + $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
| 2104 | + $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML ); |
2101 | 2105 | } |
2102 | 2106 | wfProfileOut( __METHOD__ ); |
2103 | 2107 | return $previewhead . $previewHTML . $this->previewTextAfterContent; |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -67,6 +67,7 @@ |
68 | 68 | var $mRedirect = null; // /< Is the article at this title a redirect? |
69 | 69 | var $mNotificationTimestamp = array(); // /< Associative array of user ID -> timestamp/false |
70 | 70 | var $mBacklinkCache = null; // /< Cache of links to this title |
| 71 | + var $mPageLanguage; |
71 | 72 | // @} |
72 | 73 | |
73 | 74 | |
— | — | @@ -4221,6 +4222,26 @@ |
4222 | 4223 | } |
4223 | 4224 | return $unprefixed; |
4224 | 4225 | } |
| 4226 | + |
| 4227 | + /** |
| 4228 | + * Get the language this page is written in |
| 4229 | + * Defaults to $wgContLang |
| 4230 | + * |
| 4231 | + * @return object Language |
| 4232 | + */ |
| 4233 | + public function getPageLanguage() { |
| 4234 | + global $wgContLang; |
| 4235 | + $this->mPageLanguage = $wgContLang; |
| 4236 | + if ( $this->isCssOrJsPage() ) { |
| 4237 | + // css/js should always be LTR and is, in fact, English |
| 4238 | + $this->mPageLanguage = Language::factory( 'en' ); |
| 4239 | + } elseif ( $this->getNamespace() == NS_MEDIAWIKI ) { |
| 4240 | + // Parse mediawiki messages with correct target language |
| 4241 | + list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->getText() ); |
| 4242 | + $this->mPageLanguage = wfGetLangObj( $lang ); |
| 4243 | + } |
| 4244 | + return $this->mPageLanguage; |
| 4245 | + } |
4225 | 4246 | } |
4226 | 4247 | |
4227 | 4248 | /** |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -461,8 +461,7 @@ |
462 | 462 | if( $this->getTitle()->getNamespace() != NS_SPECIAL && |
463 | 463 | in_array( $action, array( 'view', 'render', 'print' ) ) && |
464 | 464 | ( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) { |
465 | | - $getPageLang = $out->parserOptions()->getTargetLanguage( $this->getTitle() ); |
466 | | - $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); |
| 465 | + $pageLang = $this->getTitle()->getPageLanguage(); |
467 | 466 | $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); |
468 | 467 | $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); |
469 | 468 | } |