}
}
- /**
- * Check if the edit page is using OOUI controls
- * @return bool Always true
- * @deprecated since 1.30
- */
- public function isOouiEnabled() {
- wfDeprecated( __METHOD__, '1.30' );
- return true;
- }
-
/**
* Returns if the given content model is editable.
*
if ( $namespace == NS_MEDIAWIKI ) {
# Show a warning if editing an interface message
$out->wrapWikiMsg( "<div class='mw-editinginterface'>\n$1\n</div>", 'editinginterface' );
- # If this is a default message (but not css or js),
+ # If this is a default message (but not css, json, or js),
# show a hint that it is translatable on translatewiki.net
- if ( !$this->mTitle->hasContentModel( CONTENT_MODEL_CSS )
+ if (
+ !$this->mTitle->hasContentModel( CONTENT_MODEL_CSS )
+ && !$this->mTitle->hasContentModel( CONTENT_MODEL_JSON )
&& !$this->mTitle->hasContentModel( CONTENT_MODEL_JAVASCRIPT )
) {
$defaultMessageText = $this->mTitle->getDefaultMessageText();
}
if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) {
$isUserCssConfig = $this->mTitle->isUserCssConfigPage();
+ $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage();
+ $isUserJsConfig = $this->mTitle->isUserJsConfigPage();
$warning = $isUserCssConfig
? 'usercssispublic'
- : 'userjsispublic';
+ : ( $isUserJsonConfig ? 'userjsonispublic' : 'userjsispublic' );
$out->wrapWikiMsg( '<div class="mw-userconfigpublic">$1</div>', $warning );
"<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
[ 'usercssyoucanpreview' ]
);
- }
-
- if ( $this->mTitle->isJsSubpage() && $config->get( 'AllowUserJs' ) ) {
+ } elseif ( $isUserJsonConfig /* No comparable 'AllowUserJson' */ ) {
+ $out->wrapWikiMsg(
+ "<div id='mw-userjsonyoucanpreview'>\n$1\n</div>",
+ [ 'userjsonyoucanpreview' ]
+ );
+ } elseif ( $isUserJsConfig && $config->get( 'AllowUserJs' ) ) {
$out->wrapWikiMsg(
"<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
[ 'userjsyoucanpreview' ]
if ( $level === 'user' && !$config->get( 'AllowUserCss' ) ) {
$format = false;
}
+ } elseif ( $content->getModel() == CONTENT_MODEL_JSON ) {
+ $format = 'json';
+ if ( $level === 'user' /* No comparable 'AllowUserJson' */ ) {
+ $format = false;
+ }
} elseif ( $content->getModel() == CONTENT_MODEL_JAVASCRIPT ) {
$format = 'js';
if ( $level === 'user' && !$config->get( 'AllowUserJs' ) ) {
}
# Used messages to make sure grep find them:
- # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
+ # Messages: usercsspreview, userjsonpreview, userjspreview,
+ # sitecsspreview, sitejsonpreview, sitejspreview
if ( $level && $format ) {
$note = "<div id='mw-{$level}{$format}preview'>" .
$this->context->msg( "{$level}{$format}preview" )->text() .
$previewHTML = $parserResult['html'];
$this->mParserOutput = $parserOutput;
$out->addParserOutputMetadata( $parserOutput );
+ if ( $out->userCanPreview() ) {
+ $out->addContentOverride( $this->getTitle(), $content );
+ }
if ( count( $parserOutput->getWarnings() ) ) {
$note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
$script .= '});';
+ $nonce = $wgOut->getCSPNonce();
+ $wgOut->addScript( ResourceLoader::makeInlineScript( $script, $nonce ) );
+
$toolbar = '<div id="toolbar"></div>';
if ( Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] ) ) {
// Only add the old toolbar cruft to the page payload if the toolbar has not
// been over-written by a hook caller
- $wgOut->addScript( ResourceLoader::makeInlineScript( $script ) );
+ $wgOut->addScript( ResourceLoader::makeInlineScript( $script, $nonce ) );
};
return $toolbar;