OutputPage,ResourceLoaderStartupModule: Separate internal from public config vars
Change-Id: Ic54d3b36fb379d77139b21b46db7da9f78869e37
This commit is contained in:
parent
dd2ec47f45
commit
ae08640853
2 changed files with 49 additions and 28 deletions
|
|
@ -3302,7 +3302,27 @@ class OutputPage extends ContextSource {
|
|||
|
||||
$user = $this->getUser();
|
||||
|
||||
// Internal variables for MediaWiki core
|
||||
$vars = [
|
||||
// @internal For mediawiki.page.startup
|
||||
'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
|
||||
|
||||
// @internal For jquery.tablesorter
|
||||
'wgSeparatorTransformTable' => $compactSeparatorTransTable,
|
||||
'wgDigitTransformTable' => $compactDigitTransTable,
|
||||
'wgDefaultDateFormat' => $lang->getDefaultDateFormat(),
|
||||
'wgMonthNames' => $lang->getMonthNamesArray(),
|
||||
'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
|
||||
|
||||
// @internal For debugging purposes
|
||||
'wgRequestId' => WebRequest::getRequestId(),
|
||||
|
||||
// @internal For mw.loader
|
||||
'wgCSPNonce' => $this->CSP->getNonce(),
|
||||
];
|
||||
|
||||
// Start of supported and stable config vars (for use by extensions/gadgets).
|
||||
$vars += [
|
||||
'wgCanonicalNamespace' => $canonicalNamespace,
|
||||
'wgCanonicalSpecialPageName' => $canonicalSpecialPageName,
|
||||
'wgNamespaceNumber' => $title->getNamespace(),
|
||||
|
|
@ -3317,20 +3337,11 @@ class OutputPage extends ContextSource {
|
|||
'wgUserName' => $user->isAnon() ? null : $user->getName(),
|
||||
'wgUserGroups' => $user->getEffectiveGroups(),
|
||||
'wgCategories' => $this->getCategories(),
|
||||
'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
|
||||
'wgPageContentLanguage' => $lang->getCode(),
|
||||
'wgPageContentModel' => $title->getContentModel(),
|
||||
'wgSeparatorTransformTable' => $compactSeparatorTransTable,
|
||||
'wgDigitTransformTable' => $compactDigitTransTable,
|
||||
'wgDefaultDateFormat' => $lang->getDefaultDateFormat(),
|
||||
'wgMonthNames' => $lang->getMonthNamesArray(),
|
||||
'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
|
||||
'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
|
||||
'wgRelevantArticleId' => $relevantTitle->getArticleID(),
|
||||
'wgRequestId' => WebRequest::getRequestId(),
|
||||
'wgCSPNonce' => $this->CSP->getNonce(),
|
||||
];
|
||||
|
||||
if ( $user->isLoggedIn() ) {
|
||||
$vars['wgUserId'] = $user->getId();
|
||||
$vars['wgUserEditCount'] = $user->getEditCount();
|
||||
|
|
@ -3341,34 +3352,31 @@ class OutputPage extends ContextSource {
|
|||
// the client side.
|
||||
$vars['wgUserNewMsgRevisionId'] = $user->getNewMessageRevisionId();
|
||||
}
|
||||
|
||||
$contLang = $services->getContentLanguage();
|
||||
if ( $contLang->hasVariants() ) {
|
||||
$vars['wgUserVariant'] = $contLang->getPreferredVariant();
|
||||
}
|
||||
// Same test as SkinTemplate
|
||||
$vars['wgIsProbablyEditable'] = $this->userCanEditOrCreate( $user, $title );
|
||||
|
||||
$vars['wgRelevantPageIsProbablyEditable'] = $relevantTitle &&
|
||||
$this->userCanEditOrCreate( $user, $relevantTitle );
|
||||
|
||||
foreach ( $title->getRestrictionTypes() as $type ) {
|
||||
// Following keys are set in $vars:
|
||||
// wgRestrictionCreate, wgRestrictionEdit, wgRestrictionMove, wgRestrictionUpload
|
||||
$vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
|
||||
}
|
||||
|
||||
if ( $title->isMainPage() ) {
|
||||
$vars['wgIsMainPage'] = true;
|
||||
}
|
||||
|
||||
if ( $this->mRedirectedFrom ) {
|
||||
$vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
|
||||
}
|
||||
|
||||
if ( $relevantUser ) {
|
||||
$vars['wgRelevantUserName'] = $relevantUser->getName();
|
||||
}
|
||||
// End of stable config vars
|
||||
|
||||
if ( $this->mRedirectedFrom ) {
|
||||
// @internal For skin JS
|
||||
$vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
|
||||
}
|
||||
|
||||
// Allow extensions to add their custom variables to the mw.config map.
|
||||
// Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
|
||||
|
|
|
|||
|
|
@ -82,24 +82,21 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
|
|||
|
||||
// Build list of variables
|
||||
$skin = $context->getSkin();
|
||||
|
||||
// Start of supported and stable config vars (for use by extensions/gadgets).
|
||||
$vars = [
|
||||
'debug' => $context->getDebug(),
|
||||
'skin' => $skin,
|
||||
'stylepath' => $conf->get( 'StylePath' ),
|
||||
'wgUrlProtocols' => wfUrlProtocols(),
|
||||
'wgArticlePath' => $conf->get( 'ArticlePath' ),
|
||||
'wgScriptPath' => $conf->get( 'ScriptPath' ),
|
||||
'wgScript' => $conf->get( 'Script' ),
|
||||
'wgSearchType' => $conf->get( 'SearchType' ),
|
||||
'wgVariantArticlePath' => $conf->get( 'VariantArticlePath' ),
|
||||
// Force object to avoid "empty" associative array from
|
||||
// becoming [] instead of {} in JS (T36604)
|
||||
'wgActionPaths' => (object)$conf->get( 'ActionPaths' ),
|
||||
'wgServer' => $conf->get( 'Server' ),
|
||||
'wgServerName' => $conf->get( 'ServerName' ),
|
||||
'wgUserLanguage' => $context->getLanguage(),
|
||||
'wgContentLanguage' => $contLang->getCode(),
|
||||
'wgTranslateNumerals' => $conf->get( 'TranslateNumerals' ),
|
||||
'wgVersion' => $conf->get( 'Version' ),
|
||||
'wgEnableAPI' => true, // Deprecated since MW 1.32
|
||||
'wgEnableWriteAPI' => true, // Deprecated since MW 1.32
|
||||
|
|
@ -109,20 +106,36 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
|
|||
'wgSiteName' => $conf->get( 'Sitename' ),
|
||||
'wgDBname' => $conf->get( 'DBname' ),
|
||||
'wgWikiID' => WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ),
|
||||
'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ),
|
||||
'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
|
||||
'wgCommentByteLimit' => null,
|
||||
'wgCommentCodePointLimit' => CommentStore::COMMENT_CHARACTER_LIMIT,
|
||||
'wgExtensionAssetsPath' => $conf->get( 'ExtensionAssetsPath' ),
|
||||
// MediaWiki sets cookies to have this prefix by default
|
||||
];
|
||||
// End of stable config vars.
|
||||
|
||||
// Internal variables for use by MediaWiki core and/or ResourceLoader.
|
||||
$vars += [
|
||||
// @internal For mediawiki.widgets
|
||||
'wgUrlProtocols' => wfUrlProtocols(),
|
||||
// @internal For mediawiki.page.watch
|
||||
// Force object to avoid "empty" associative array from
|
||||
// becoming [] instead of {} in JS (T36604)
|
||||
'wgActionPaths' => (object)$conf->get( 'ActionPaths' ),
|
||||
// @internal For mediawiki.language
|
||||
'wgTranslateNumerals' => $conf->get( 'TranslateNumerals' ),
|
||||
// @internal For mediawiki.Title
|
||||
'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ),
|
||||
// @internal For mediawiki.cookie
|
||||
'wgCookiePrefix' => $conf->get( 'CookiePrefix' ),
|
||||
'wgCookieDomain' => $conf->get( 'CookieDomain' ),
|
||||
'wgCookiePath' => $conf->get( 'CookiePath' ),
|
||||
'wgCookieExpiration' => $conf->get( 'CookieExpiration' ),
|
||||
'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
|
||||
// @internal For mediawiki.Title
|
||||
'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
|
||||
'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ),
|
||||
// @internal For mediawiki.ForeignUpload
|
||||
'wgForeignUploadTargets' => $conf->get( 'ForeignUploadTargets' ),
|
||||
'wgEnableUploads' => $conf->get( 'EnableUploads' ),
|
||||
'wgCommentByteLimit' => null,
|
||||
'wgCommentCodePointLimit' => CommentStore::COMMENT_CHARACTER_LIMIT,
|
||||
];
|
||||
|
||||
Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars, $skin, $conf ] );
|
||||
|
|
|
|||
Loading…
Reference in a new issue