Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -59,8 +59,6 @@ |
60 | 60 | * Conversion script between Tifinagh and Latin for the Tachelhit language |
61 | 61 | * (bug 16755) Add options 'noreplace' and 'noerror' to {{DEFAULTSORT:...}} |
62 | 62 | to stop it from replace an already existing default sort, and suppress error. |
63 | | -* (bug 30364) LanguageConverter now depends on the page content language |
64 | | - instead of the wiki content language |
65 | 63 | * (bug 18578) Rewrote revision delete related messages to allow better |
66 | 64 | localisation |
67 | 65 | |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | // not memoized (i.e. there return value is not cached) since |
160 | 160 | // new information might appear during processing after this |
161 | 161 | // is first called. |
162 | | - if ( $req = $this->validateVariant( $req ) ) { |
| 162 | + if ( $req ) { |
163 | 163 | return $req; |
164 | 164 | } |
165 | 165 | return $this->mMainLanguageCode; |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -2562,7 +2562,7 @@ |
2563 | 2563 | * @return mixed ParserOptions object or boolean false |
2564 | 2564 | */ |
2565 | 2565 | public function getParserOptions( $canonical = false ) { |
2566 | | - global $wgUser; |
| 2566 | + global $wgUser, $wgLanguageCode; |
2567 | 2567 | |
2568 | 2568 | if ( !$this->mParserOptions || $canonical ) { |
2569 | 2569 | $user = !$canonical ? $wgUser : new User; |
— | — | @@ -2571,7 +2571,7 @@ |
2572 | 2572 | $parserOptions->enableLimitReport(); |
2573 | 2573 | |
2574 | 2574 | if ( $canonical ) { |
2575 | | - $parserOptions->setUserLang( $this->mTitle->getPageLanguage() ); # Must be set explicitely |
| 2575 | + $parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely |
2576 | 2576 | return $parserOptions; |
2577 | 2577 | } |
2578 | 2578 | $this->mParserOptions = $parserOptions; |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1050,14 +1050,13 @@ |
1051 | 1051 | * @return string containing HMTL with redirect link |
1052 | 1052 | */ |
1053 | 1053 | public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { |
1054 | | - global $wgOut, $wgStylePath; |
| 1054 | + global $wgOut, $wgLang, $wgStylePath; |
1055 | 1055 | |
1056 | 1056 | if ( !is_array( $target ) ) { |
1057 | 1057 | $target = array( $target ); |
1058 | 1058 | } |
1059 | 1059 | |
1060 | | - $lang = $this->getTitle()->getPageLanguage(); |
1061 | | - $imageDir = $lang->getDir(); |
| 1060 | + $imageDir = $wgLang->getDir(); |
1062 | 1061 | |
1063 | 1062 | if ( $appendSubtitle ) { |
1064 | 1063 | $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) ); |
— | — | @@ -1073,7 +1072,7 @@ |
1074 | 1073 | } |
1075 | 1074 | |
1076 | 1075 | $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png'; |
1077 | | - $alt = $lang->isRTL() ? '←' : '→'; |
| 1076 | + $alt = $wgLang->isRTL() ? '←' : '→'; |
1078 | 1077 | // Automatically append redirect=no to each link, since most of them are redirect pages themselves. |
1079 | 1078 | foreach ( $target as $rt ) { |
1080 | 1079 | $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) ); |
Index: trunk/phase3/includes/parser/ParserCache.php |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | */ |
82 | 82 | function getETag( $article, $popts ) { |
83 | 83 | return 'W/"' . $this->getParserOutputKey( $article, |
84 | | - $popts->optionsHash( ParserOptions::legacyOptions(), $article->getTitle() ) ) . |
| 84 | + $popts->optionsHash( ParserOptions::legacyOptions() ) ) . |
85 | 85 | "--" . $article->getTouched() . '"'; |
86 | 86 | } |
87 | 87 | |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | $usedOptions = ParserOptions::legacyOptions(); |
132 | 132 | } |
133 | 133 | |
134 | | - return $this->getParserOutputKey( $article, $popts->optionsHash( $usedOptions, $article->getTitle() ) ); |
| 134 | + return $this->getParserOutputKey( $article, $popts->optionsHash( $usedOptions ) ); |
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
— | — | @@ -165,8 +165,7 @@ |
166 | 166 | $value = $this->mMemc->get( $parserOutputKey ); |
167 | 167 | if ( self::try116cache && !$value && strpos( $value, '*' ) !== -1 ) { |
168 | 168 | wfDebug( "New format parser cache miss.\n" ); |
169 | | - $parserOutputKey = $this->getParserOutputKey( $article, |
170 | | - $popts->optionsHash( ParserOptions::legacyOptions(), $article->getTitle() ) ); |
| 169 | + $parserOutputKey = $this->getParserOutputKey( $article, $popts->optionsHash( ParserOptions::legacyOptions() ) ); |
171 | 170 | $value = $this->mMemc->get( $parserOutputKey ); |
172 | 171 | } |
173 | 172 | if ( !$value ) { |
— | — | @@ -212,7 +211,7 @@ |
213 | 212 | $optionsKey->setContainsOldMagic( $parserOutput->containsOldMagic() ); |
214 | 213 | |
215 | 214 | $parserOutputKey = $this->getParserOutputKey( $article, |
216 | | - $popts->optionsHash( $optionsKey->mUsedOptions, $article->getTitle() ) ); |
| 215 | + $popts->optionsHash( $optionsKey->mUsedOptions ) ); |
217 | 216 | |
218 | 217 | // Save the timestamp so that we don't have to load the revision row on view |
219 | 218 | $parserOutput->mTimestamp = $article->getTimestamp(); |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -321,7 +321,7 @@ |
322 | 322 | * to internalParse() which does all the real work. |
323 | 323 | */ |
324 | 324 | |
325 | | - global $wgUseTidy, $wgAlwaysUseTidy, $wgDisableLangConversion, $wgDisableTitleConversion; |
| 325 | + global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion; |
326 | 326 | $fname = __METHOD__.'-' . wfGetCaller(); |
327 | 327 | wfProfileIn( __METHOD__ ); |
328 | 328 | wfProfileIn( $fname ); |
— | — | @@ -376,7 +376,8 @@ |
377 | 377 | # The position of the convert() call should not be changed. it |
378 | 378 | # assumes that the links are all replaced and the only thing left |
379 | 379 | # is the <nowiki> mark. |
380 | | - $text = $this->getFunctionLang()->convert( $text ); |
| 380 | + |
| 381 | + $text = $wgContLang->convert( $text ); |
381 | 382 | } |
382 | 383 | |
383 | 384 | /** |
— | — | @@ -392,11 +393,11 @@ |
393 | 394 | || isset( $this->mDoubleUnderscores['notitleconvert'] ) |
394 | 395 | || $this->mOutput->getDisplayTitle() !== false ) ) |
395 | 396 | { |
396 | | - $convruletitle = $this->getFunctionLang()->getConvRuleTitle(); |
| 397 | + $convruletitle = $wgContLang->getConvRuleTitle(); |
397 | 398 | if ( $convruletitle ) { |
398 | 399 | $this->mOutput->setTitleText( $convruletitle ); |
399 | 400 | } else { |
400 | | - $titleText = $this->getFunctionLang()->convertTitle( $title ); |
| 401 | + $titleText = $wgContLang->convertTitle( $title ); |
401 | 402 | $this->mOutput->setTitleText( $titleText ); |
402 | 403 | } |
403 | 404 | } |
— | — | @@ -1316,6 +1317,7 @@ |
1317 | 1318 | * @private |
1318 | 1319 | */ |
1319 | 1320 | function makeFreeExternalLink( $url ) { |
| 1321 | + global $wgContLang; |
1320 | 1322 | wfProfileIn( __METHOD__ ); |
1321 | 1323 | |
1322 | 1324 | $trail = ''; |
— | — | @@ -1348,7 +1350,7 @@ |
1349 | 1351 | $text = $this->maybeMakeExternalImage( $url ); |
1350 | 1352 | if ( $text === false ) { |
1351 | 1353 | # Not an image, make a link |
1352 | | - $text = Linker::makeExternalLink( $url, $this->getFunctionLang()->markNoConversion($url), true, 'free', |
| 1354 | + $text = Linker::makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', |
1353 | 1355 | $this->getExternalLinkAttribs( $url ) ); |
1354 | 1356 | # Register it in the output object... |
1355 | 1357 | # Replace unnecessary URL escape codes with their equivalent characters |
— | — | @@ -1576,6 +1578,7 @@ |
1577 | 1579 | * @return string |
1578 | 1580 | */ |
1579 | 1581 | function replaceExternalLinks( $text ) { |
| 1582 | + global $wgContLang; |
1580 | 1583 | wfProfileIn( __METHOD__ ); |
1581 | 1584 | |
1582 | 1585 | $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
— | — | @@ -1621,7 +1624,7 @@ |
1622 | 1625 | list( $dtrail, $trail ) = Linker::splitTrail( $trail ); |
1623 | 1626 | } |
1624 | 1627 | |
1625 | | - $text = $this->getFunctionLang()->markNoConversion( $text ); |
| 1628 | + $text = $wgContLang->markNoConversion( $text ); |
1626 | 1629 | |
1627 | 1630 | $url = Sanitizer::cleanUrl( $url ); |
1628 | 1631 | |
— | — | @@ -1778,6 +1781,8 @@ |
1779 | 1782 | * @private |
1780 | 1783 | */ |
1781 | 1784 | function replaceInternalLinks2( &$s ) { |
| 1785 | + global $wgContLang; |
| 1786 | + |
1782 | 1787 | wfProfileIn( __METHOD__ ); |
1783 | 1788 | |
1784 | 1789 | wfProfileIn( __METHOD__.'-setup' ); |
— | — | @@ -1801,7 +1806,7 @@ |
1802 | 1807 | $line = $a->current(); # Workaround for broken ArrayIterator::next() that returns "void" |
1803 | 1808 | $s = substr( $s, 1 ); |
1804 | 1809 | |
1805 | | - $useLinkPrefixExtension = $this->getFunctionLang()->linkPrefixExtension(); |
| 1810 | + $useLinkPrefixExtension = $wgContLang->linkPrefixExtension(); |
1806 | 1811 | $e2 = null; |
1807 | 1812 | if ( $useLinkPrefixExtension ) { |
1808 | 1813 | # Match the end of a line for a word that's not followed by whitespace, |
— | — | @@ -1827,8 +1832,8 @@ |
1828 | 1833 | $prefix = ''; |
1829 | 1834 | } |
1830 | 1835 | |
1831 | | - if ( $this->getFunctionLang()->hasVariants() ) { |
1832 | | - $selflink = $this->getFunctionLang()->autoConvertToAllVariants( $this->mTitle->getPrefixedText() ); |
| 1836 | + if ( $wgContLang->hasVariants() ) { |
| 1837 | + $selflink = $wgContLang->autoConvertToAllVariants( $this->mTitle->getPrefixedText() ); |
1833 | 1838 | } else { |
1834 | 1839 | $selflink = array( $this->mTitle->getPrefixedText() ); |
1835 | 1840 | } |
— | — | @@ -1996,7 +2001,6 @@ |
1997 | 2002 | |
1998 | 2003 | # Link not escaped by : , create the various objects |
1999 | 2004 | if ( $noforce ) { |
2000 | | - global $wgContLang; |
2001 | 2005 | |
2002 | 2006 | # Interwikis |
2003 | 2007 | wfProfileIn( __METHOD__."-interwiki" ); |
— | — | @@ -2046,7 +2050,7 @@ |
2047 | 2051 | } |
2048 | 2052 | $sortkey = Sanitizer::decodeCharReferences( $sortkey ); |
2049 | 2053 | $sortkey = str_replace( "\n", '', $sortkey ); |
2050 | | - $sortkey = $this->getFunctionLang()->convertCategoryKey( $sortkey ); |
| 2054 | + $sortkey = $wgContLang->convertCategoryKey( $sortkey ); |
2051 | 2055 | $this->mOutput->addCategory( $nt->getDBkey(), $sortkey ); |
2052 | 2056 | |
2053 | 2057 | /** |
— | — | @@ -3248,7 +3252,7 @@ |
3249 | 3253 | $function = $this->mFunctionSynonyms[1][$function]; |
3250 | 3254 | } else { |
3251 | 3255 | # Case insensitive functions |
3252 | | - $function = $this->getFunctionLang()->lc( $function ); |
| 3256 | + $function = $wgContLang->lc( $function ); |
3253 | 3257 | if ( isset( $this->mFunctionSynonyms[0][$function] ) ) { |
3254 | 3258 | $function = $this->mFunctionSynonyms[0][$function]; |
3255 | 3259 | } else { |
— | — | @@ -3324,8 +3328,8 @@ |
3325 | 3329 | } |
3326 | 3330 | $titleText = $title->getPrefixedText(); |
3327 | 3331 | # Check for language variants if the template is not found |
3328 | | - if ( $this->getFunctionLang()->hasVariants() && $title->getArticleID() == 0 ) { |
3329 | | - $this->getFunctionLang()->findVariantLink( $part1, $title, true ); |
| 3332 | + if ( $wgContLang->hasVariants() && $title->getArticleID() == 0 ) { |
| 3333 | + $wgContLang->findVariantLink( $part1, $title, true ); |
3330 | 3334 | } |
3331 | 3335 | # Do recursion depth check |
3332 | 3336 | $limit = $this->mOptions->getMaxTemplateDepth(); |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -274,12 +274,10 @@ |
275 | 275 | * settings. |
276 | 276 | * |
277 | 277 | * @since 1.17 |
278 | | - * @param $forOptions Array |
279 | | - * @param $title Title: used to get the content language of the page |
280 | 278 | * @return \string Page rendering hash |
281 | 279 | */ |
282 | | - public function optionsHash( $forOptions, $title = null ) { |
283 | | - global $wgRenderHashAppend, $wgTitle; |
| 280 | + public function optionsHash( $forOptions ) { |
| 281 | + global $wgContLang, $wgRenderHashAppend; |
284 | 282 | |
285 | 283 | $confstr = ''; |
286 | 284 | |
— | — | @@ -323,12 +321,7 @@ |
324 | 322 | |
325 | 323 | // add in language specific options, if any |
326 | 324 | // @todo FIXME: This is just a way of retrieving the url/user preferred variant |
327 | | - if( !is_null( $title ) ) { |
328 | | - $confstr .= $title->getPageLanguage()->getExtraHashOptions(); |
329 | | - } else { |
330 | | - global $wgContLang; |
331 | | - $confstr .= $wgContLang->getExtraHashOptions(); |
332 | | - } |
| 325 | + $confstr .= $wgContLang->getExtraHashOptions(); |
333 | 326 | |
334 | 327 | $confstr .= $wgRenderHashAppend; |
335 | 328 | |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1654,12 +1654,12 @@ |
1655 | 1655 | * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
1656 | 1656 | */ |
1657 | 1657 | function addAcceptLanguage() { |
1658 | | - $lang = $this->getTitle()->getPageLanguage(); |
1659 | | - if( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) { |
1660 | | - $variants = $lang->getVariants(); |
| 1658 | + global $wgContLang; |
| 1659 | + if( !$this->getRequest()->getCheck( 'variant' ) && $wgContLang->hasVariants() ) { |
| 1660 | + $variants = $wgContLang->getVariants(); |
1661 | 1661 | $aloption = array(); |
1662 | 1662 | foreach ( $variants as $variant ) { |
1663 | | - if( $variant === $lang->getCode() ) { |
| 1663 | + if( $variant === $wgContLang->getCode() ) { |
1664 | 1664 | continue; |
1665 | 1665 | } else { |
1666 | 1666 | $aloption[] = 'string-contains=' . $variant; |
— | — | @@ -2614,7 +2614,7 @@ |
2615 | 2615 | * have to be purged on configuration changes. |
2616 | 2616 | */ |
2617 | 2617 | protected function getJSVars() { |
2618 | | - global $wgUseAjax, $wgEnableMWSuggest; |
| 2618 | + global $wgUseAjax, $wgEnableMWSuggest, $wgContLang; |
2619 | 2619 | |
2620 | 2620 | $title = $this->getTitle(); |
2621 | 2621 | $ns = $title->getNamespace(); |
— | — | @@ -2640,9 +2640,8 @@ |
2641 | 2641 | 'wgCategories' => $this->getCategories(), |
2642 | 2642 | 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', |
2643 | 2643 | ); |
2644 | | - $lang = $this->getTitle()->getPageLanguage(); |
2645 | | - if ( $lang->hasVariants() ) { |
2646 | | - $vars['wgUserVariant'] = $lang->getPreferredVariant(); |
| 2644 | + if ( $wgContLang->hasVariants() ) { |
| 2645 | + $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); |
2647 | 2646 | } |
2648 | 2647 | foreach ( $title->getRestrictionTypes() as $type ) { |
2649 | 2648 | $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type ); |
— | — | @@ -2694,7 +2693,7 @@ |
2695 | 2694 | global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, |
2696 | 2695 | $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, |
2697 | 2696 | $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, |
2698 | | - $wgDisableLangConversion, $wgCanonicalLanguageLinks, |
| 2697 | + $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang, |
2699 | 2698 | $wgRightsPage, $wgRightsUrl; |
2700 | 2699 | |
2701 | 2700 | $tags = array(); |
— | — | @@ -2820,16 +2819,14 @@ |
2821 | 2820 | ) ); |
2822 | 2821 | } |
2823 | 2822 | |
2824 | | - $lang = $this->getTitle()->getPageLanguage(); |
2825 | | - |
2826 | 2823 | # Language variants |
2827 | 2824 | if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks |
2828 | | - && $lang->hasVariants() ) { |
| 2825 | + && $wgContLang->hasVariants() ) { |
2829 | 2826 | |
2830 | | - $urlvar = $lang->getURLVariant(); |
| 2827 | + $urlvar = $wgContLang->getURLVariant(); |
2831 | 2828 | |
2832 | 2829 | if ( !$urlvar ) { |
2833 | | - $variants = $lang->getVariants(); |
| 2830 | + $variants = $wgContLang->getVariants(); |
2834 | 2831 | foreach ( $variants as $_v ) { |
2835 | 2832 | $tags[] = Html::element( 'link', array( |
2836 | 2833 | 'rel' => 'alternate', |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -1012,21 +1012,16 @@ |
1013 | 1013 | array( &$this, &$content_navigation ) ); |
1014 | 1014 | } |
1015 | 1015 | |
1016 | | - $pageLang = $title->getPageLanguage(); |
1017 | | - |
1018 | 1016 | // Gets list of language variants |
1019 | | - $variants = $pageLang->getVariants(); |
| 1017 | + $variants = $wgContLang->getVariants(); |
1020 | 1018 | // Checks that language conversion is enabled and variants exist |
1021 | | - // And if it is not in the special namespace |
1022 | | - if( !$wgDisableLangConversion && count( $variants ) > 1 |
1023 | | - && $title->getNamespace() != NS_SPECIAL ) { |
1024 | | - // Gets preferred variant (note that user preference is |
1025 | | - // only possible for wiki content language variant) |
1026 | | - $preferred = $pageLang->getPreferredVariant(); |
| 1019 | + if( !$wgDisableLangConversion && count( $variants ) > 1 ) { |
| 1020 | + // Gets preferred variant |
| 1021 | + $preferred = $wgContLang->getPreferredVariant(); |
1027 | 1022 | // Loops over each variant |
1028 | 1023 | foreach( $variants as $code ) { |
1029 | 1024 | // Gets variant name from language code |
1030 | | - $varname = $pageLang->getVariantname( $code ); |
| 1025 | + $varname = $wgContLang->getVariantname( $code ); |
1031 | 1026 | // Checks if the variant is marked as disabled |
1032 | 1027 | if( $varname == 'disable' ) { |
1033 | 1028 | // Skips this variant |
Index: trunk/phase3/includes/SkinLegacy.php |
— | — | @@ -279,14 +279,13 @@ |
280 | 280 | $s = ''; |
281 | 281 | |
282 | 282 | /* show links to different language variants */ |
283 | | - global $wgDisableLangConversion, $wgLang; |
| 283 | + global $wgDisableLangConversion, $wgLang, $wgContLang; |
284 | 284 | |
285 | | - $lang = $this->getSkin()->getTitle()->getPageLanguage(); |
286 | | - $variants = $lang->getVariants(); |
| 285 | + $variants = $wgContLang->getVariants(); |
287 | 286 | |
288 | 287 | if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { |
289 | 288 | foreach ( $variants as $code ) { |
290 | | - $varname = $lang->getVariantname( $code ); |
| 289 | + $varname = $wgContLang->getVariantname( $code ); |
291 | 290 | |
292 | 291 | if ( $varname == 'disable' ) { |
293 | 292 | continue; |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -877,7 +877,7 @@ |
878 | 878 | */ |
879 | 879 | public function getLocalURL( $query = '', $variant = false ) { |
880 | 880 | global $wgArticlePath, $wgScript, $wgServer, $wgRequest; |
881 | | - global $wgVariantArticlePath; |
| 881 | + global $wgVariantArticlePath, $wgContLang; |
882 | 882 | |
883 | 883 | if ( is_array( $query ) ) { |
884 | 884 | $query = wfArrayToCGI( $query ); |
— | — | @@ -896,7 +896,7 @@ |
897 | 897 | } else { |
898 | 898 | $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
899 | 899 | if ( $query == '' ) { |
900 | | - if ( $variant != false && $this->getPageLanguage()->hasVariants() ) { |
| 900 | + if ( $variant != false && $wgContLang->hasVariants() ) { |
901 | 901 | if ( !$wgVariantArticlePath ) { |
902 | 902 | $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default |
903 | 903 | } else { |
— | — | @@ -4384,6 +4384,9 @@ |
4385 | 4385 | if ( $this->getNamespace() == NS_SPECIAL ) { |
4386 | 4386 | // special pages are in the user language |
4387 | 4387 | return $wgLang; |
| 4388 | + } elseif ( $this->isRedirect() ) { |
| 4389 | + // the arrow on a redirect page is aligned according to the user language |
| 4390 | + return $wgLang; |
4388 | 4391 | } elseif ( $this->isCssOrJsPage() ) { |
4389 | 4392 | // css/js should always be LTR and is, in fact, English |
4390 | 4393 | return wfGetLangObj( 'en' ); |