* @param array $categories Mapping category name => sort key
*/
public function addCategoryLinks( array $categories ) {
- global $wgContLang;
-
if ( !$categories ) {
return;
}
'OutputPageMakeCategoryLinks',
[ &$outputPage, $categories, &$this->mCategoryLinks ] )
) {
- $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ $services = MediaWikiServices::getInstance();
+ $linkRenderer = $services->getLinkRenderer();
foreach ( $categories as $category => $type ) {
// array keys will cast numeric category names to ints, so cast back to string
$category = (string)$category;
if ( !$title ) {
continue;
}
- $wgContLang->findVariantLink( $category, $title, true );
+ $services->getContentLanguage()->findVariantLink( $category, $title, true );
if ( $category != $origcategory && array_key_exists( $category, $categories ) ) {
continue;
}
- $text = $wgContLang->convertHtml( $title->getText() );
+ $text = $services->getContentLanguage()->convertHtml( $title->getText() );
$this->mCategories[$type][] = $title->getText();
$this->mCategoryLinks[$type][] = $linkRenderer->makeLink( $title, new HtmlArmor( $text ) );
}
* @since 1.24
* @param ParserOutput $parserOutput
*/
- public function addParserOutputMetadata( $parserOutput ) {
+ public function addParserOutputMetadata( ParserOutput $parserOutput ) {
$this->mLanguageLinks =
array_merge( $this->mLanguageLinks, $parserOutput->getLanguageLinks() );
$this->addCategoryLinks( $parserOutput->getCategories() );
* @param ParserOutput $parserOutput
* @param array $poOptions Options to ParserOutput::getText()
*/
- public function addParserOutputContent( $parserOutput, $poOptions = [] ) {
+ public function addParserOutputContent( ParserOutput $parserOutput, $poOptions = [] ) {
$this->addParserOutputText( $parserOutput, $poOptions );
$this->addModules( $parserOutput->getModules() );
* @param ParserOutput $parserOutput
* @param array $poOptions Options to ParserOutput::getText()
*/
- public function addParserOutputText( $parserOutput, $poOptions = [] ) {
+ public function addParserOutputText( ParserOutput $parserOutput, $poOptions = [] ) {
$text = $parserOutput->getText( $poOptions );
// Avoid PHP 7.1 warning of passing $this by reference
$outputPage = $this;
* @param ParserOutput $parserOutput
* @param array $poOptions Options to ParserOutput::getText()
*/
- function addParserOutput( $parserOutput, $poOptions = [] ) {
+ function addParserOutput( ParserOutput $parserOutput, $poOptions = [] ) {
$this->addParserOutputMetadata( $parserOutput );
$this->addParserOutputText( $parserOutput, $poOptions );
}
*
* @param string $text
* @param bool $linestart Is this the start of a line?
- * @param bool $interface Use interface language ($wgLang instead of
- * $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL.
- * This also disables LanguageConverter.
+ * @param bool $interface Use interface language (instead of content language) while parsing
+ * language sensitive magic words like GRAMMAR and PLURAL. This also disables
+ * LanguageConverter.
* @param Language|null $language Target language object, will override $interface
* @throws MWException
* @return string HTML
*
* @param string $text
* @param bool $linestart Is this the start of a line?
- * @param bool $interface Use interface language ($wgLang instead of
- * $wgContLang) while parsing language sensitive magic
- * words like GRAMMAR and PLURAL
+ * @param bool $interface Use interface language (instead of content language) while parsing
+ * language sensitive magic words like GRAMMAR and PLURAL
* @return string HTML
*/
public function parseInline( $text, $linestart = true, $interface = false ) {
* @throws MWException
*/
public function output( $return = false ) {
- global $wgContLang;
-
if ( $this->mDoNothing ) {
return $return ? '' : null;
}
ob_start();
$response->header( 'Content-type: ' . $config->get( 'MimeType' ) . '; charset=UTF-8' );
- $response->header( 'Content-language: ' . $wgContLang->getHtmlCode() );
+ $response->header( 'Content-language: ' .
+ MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() );
if ( !$this->mArticleBodyOnly ) {
$sk = $this->getSkin();
* @return string The doctype, opening "<html>", and head element.
*/
public function headElement( Skin $sk, $includeStyle = true ) {
- global $wgContLang;
-
$userdir = $this->getLanguage()->getDir();
- $sitedir = $wgContLang->getDir();
+ $sitedir = MediaWikiServices::getInstance()->getContentLanguage()->getDir();
$pieces = [];
$pieces[] = Html::htmlHeader( Sanitizer::mergeAttributes(
* @return array
*/
public function getJSVars() {
- global $wgContLang;
-
$curRevisionId = 0;
$articleId = 0;
$canonicalSpecialPageName = false; # T23115
$vars['wgUserNewMsgRevisionId'] = $user->getNewMessageRevisionId();
}
- if ( $wgContLang->hasVariants() ) {
- $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ if ( $contLang->hasVariants() ) {
+ $vars['wgUserVariant'] = $contLang->getPreferredVariant();
}
// Same test as SkinTemplate
$vars['wgIsProbablyEditable'] = $title->quickUserCan( 'edit', $user )