public static function makeName( $ns, $title, $fragment = '', $interwiki = '',
$canonicalNamespace = false
) {
- global $wgContLang;
-
if ( $canonicalNamespace ) {
$namespace = MWNamespace::getCanonicalName( $ns );
} else {
- $namespace = $wgContLang->getNsText( $ns );
+ $namespace = MediaWikiServices::getInstance()->getContentLanguage()->getNsText( $ns );
}
$name = $namespace == '' ? $title : "$namespace:$title";
if ( strval( $interwiki ) != '' ) {
* @return string Namespace text
*/
public function getSubjectNsText() {
- global $wgContLang;
- return $wgContLang->getNsText( MWNamespace::getSubject( $this->mNamespace ) );
+ return MediaWikiServices::getInstance()->getContentLanguage()->
+ getNsText( MWNamespace::getSubject( $this->mNamespace ) );
}
/**
* @return string Namespace text
*/
public function getTalkNsText() {
- global $wgContLang;
- return $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) );
+ return MediaWikiServices::getInstance()->getContentLanguage()->
+ getNsText( MWNamespace::getTalk( $this->mNamespace ) );
}
/**
* @return string The prefixed text
*/
private function prefix( $name ) {
- global $wgContLang;
-
$p = '';
if ( $this->isExternal() ) {
$p = $this->mInterwiki . ':';
if ( $nsText === false ) {
// See T165149. Awkward, but better than erroneously linking to the main namespace.
- $nsText = $wgContLang->getNsText( NS_SPECIAL ) . ":Badtitle/NS{$this->mNamespace}";
+ $nsText = MediaWikiServices::getInstance()->getContentLanguage()->
+ getNsText( NS_SPECIAL ) . ":Badtitle/NS{$this->mNamespace}";
}
$p .= $nsText . ':';
$titleRef = $this;
Hooks::run( 'GetLocalURL::Article', [ &$titleRef, &$url ] );
} else {
- global $wgVariantArticlePath, $wgActionPaths, $wgContLang;
+ global $wgVariantArticlePath, $wgActionPaths;
$url = false;
$matches = [];
if ( $url === false
&& $wgVariantArticlePath
&& preg_match( '/^variant=([^&]*)$/', $query, $matches )
- && $this->getPageLanguage()->equals( $wgContLang )
+ && $this->getPageLanguage()->equals(
+ MediaWikiServices::getInstance()->getContentLanguage() )
&& $this->getPageLanguage()->hasVariants()
) {
$variant = urldecode( $matches[1] );
*/
private function checkSiteConfigPermissions( $action, $user, $errors, $rigor, $short ) {
if ( $action != 'patrol' ) {
+ $error = null;
// Sitewide CSS/JSON/JS changes, like all NS_MEDIAWIKI changes, also require the
// editinterface right. That's implemented as a restriction so no check needed here.
if ( $this->isSiteCssConfigPage() && !$user->isAllowed( 'editsitecss' ) ) {
- $errors[] = [ 'sitecssprotected', $action ];
+ $error = [ 'sitecssprotected', $action ];
} elseif ( $this->isSiteJsonConfigPage() && !$user->isAllowed( 'editsitejson' ) ) {
- $errors[] = [ 'sitejsonprotected', $action ];
+ $error = [ 'sitejsonprotected', $action ];
} elseif ( $this->isSiteJsConfigPage() && !$user->isAllowed( 'editsitejs' ) ) {
- $errors[] = [ 'sitejsprotected', $action ];
+ $error = [ 'sitejsprotected', $action ];
+ }
+
+ if ( $error ) {
+ if ( $user->isAllowed( 'editinterface' ) ) {
+ // Most users / site admins will probably find out about the new, more restrictive
+ // permissions by failing to edit something. Give them more info.
+ // TODO remove this a few release cycles after 1.32
+ $error = [ 'interfaceadmin-info', wfMessage( $error[0], $error[1] ) ];
+ }
+ $errors[] = $error;
}
}
* @return string Containing capitalized title
*/
public static function capitalize( $text, $ns = NS_MAIN ) {
- global $wgContLang;
-
if ( MWNamespace::isCapitalized( $ns ) ) {
- return $wgContLang->ucfirst( $text );
+ return MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $text );
} else {
return $text;
}
* $parent => $currentarticle
*/
public function getParentCategories() {
- global $wgContLang;
-
$data = [];
$titleKey = $this->getArticleID();
);
if ( $res->numRows() > 0 ) {
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
foreach ( $res as $row ) {
- // $data[] = Title::newFromText($wgContLang->getNsText ( NS_CATEGORY ).':'.$row->cl_to);
- $data[$wgContLang->getNsText( NS_CATEGORY ) . ':' . $row->cl_to] = $this->getFullText();
+ // $data[] = Title::newFromText( $contLang->getNsText ( NS_CATEGORY ).':'.$row->cl_to);
+ $data[$contLang->getNsText( NS_CATEGORY ) . ':' . $row->cl_to] =
+ $this->getFullText();
}
}
return $data;
// message content will be displayed, same for language subpages-
// Use always content language to avoid loading hundreds of languages
// to get the link color.
- global $wgContLang;
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
list( $name, ) = MessageCache::singleton()->figureMessage(
- $wgContLang->lcfirst( $this->getText() )
+ $contLang->lcfirst( $this->getText() )
);
- $message = wfMessage( $name )->inLanguage( $wgContLang )->useDatabase( false );
+ $message = wfMessage( $name )->inLanguage( $contLang )->useDatabase( false );
return $message->exists();
}
* @return string|bool
*/
public function getDefaultMessageText() {
- global $wgContLang;
-
if ( $this->getNamespace() != NS_MEDIAWIKI ) { // Just in case
return false;
}
list( $name, $lang ) = MessageCache::singleton()->figureMessage(
- $wgContLang->lcfirst( $this->getText() )
+ MediaWikiServices::getInstance()->getContentLanguage()->lcfirst( $this->getText() )
);
$message = wfMessage( $name )->inLanguage( $lang )->useDatabase( false );
* @return string XML 'id' name
*/
public function getNamespaceKey( $prepend = 'nstab-' ) {
- global $wgContLang;
// Gets the subject namespace of this title
$subjectNS = MWNamespace::getSubject( $this->getNamespace() );
// Prefer canonical namespace name for HTML IDs
$namespaceKey = $this->getSubjectNsText();
}
// Makes namespace key lowercase
- $namespaceKey = $wgContLang->lc( $namespaceKey );
+ $namespaceKey = MediaWikiServices::getInstance()->getContentLanguage()->lc( $namespaceKey );
// Uses main
if ( $namespaceKey == '' ) {
$namespaceKey = 'main';
/**
* Get the language in which the content of this page is written in
- * wikitext. Defaults to $wgContLang, but in certain cases it can be
+ * wikitext. Defaults to content language, but in certain cases it can be
* e.g. $wgLang (such as special pages, which are in the user language).
*
* @since 1.18
/**
* Get the language in which the content of this page is written when
- * viewed by user. Defaults to $wgContLang, but in certain cases it can be
+ * viewed by user. Defaults to content language, but in certain cases it can be
* e.g. $wgLang (such as special pages, which are in the user language).
*
* @since 1.20