*/
const POST_EDIT_COOKIE_DURATION = 1200;
- /** @var Article */
+ /**
+ * @deprecated for public usage since 1.30 use EditPage::getArticle()
+ * @var Article
+ */
public $mArticle;
/** @var WikiPage */
private $page;
- /** @var Title */
+ /**
+ * @deprecated for public usage since 1.30 use EditPage::getTitle()
+ * @var Title
+ */
public $mTitle;
/** @var null|Title */
/** @var bool */
public $isConflict = false;
- /** @var bool */
+ /**
+ * @deprecated since 1.30 use Title::isCssJsSubpage()
+ * @var bool
+ */
public $isCssJsSubpage = false;
- /** @var bool */
+ /**
+ * @deprecated since 1.30 use Title::isCssSubpage()
+ * @var bool
+ */
public $isCssSubpage = false;
- /** @var bool */
+ /**
+ * @deprecated since 1.30 use Title::isJsSubpage()
+ * @var bool
+ */
public $isJsSubpage = false;
- /** @var bool */
+ /**
+ * @deprecated since 1.30
+ * @var bool
+ */
public $isWrongCaseCssJsPage = false;
/** @var bool New page or new section */
* @deprecated since 1.30
*/
public function isOouiEnabled() {
+ wfDeprecated( __METHOD__, '1.30' );
return true;
}
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
+ // The following member variables are deprecated since 1.30,
+ // the functions should be used instead.
$this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
$this->isCssSubpage = $this->mTitle->isCssSubpage();
$this->isJsSubpage = $this->mTitle->isJsSubpage();
- // @todo FIXME: Silly assignment.
$this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
# Show applicable editing introductions
* @return bool
*/
protected function previewOnOpen() {
- global $wgPreviewOnOpenNamespaces;
+ $config = $this->context->getConfig();
+ $previewOnOpenNamespaces = $config->get( 'PreviewOnOpenNamespaces' );
$request = $this->context->getRequest();
+ if ( $config->get( 'RawHtml' ) ) {
+ // If raw HTML is enabled, disable preview on open
+ // since it has to be posted with a token for
+ // security reasons
+ return false;
+ }
if ( $request->getVal( 'preview' ) == 'yes' ) {
// Explicit override from request
return true;
// Standard preference behavior
return true;
} elseif ( !$this->mTitle->exists()
- && isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
- && $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()]
+ && isset( $previewOnOpenNamespaces[$this->mTitle->getNamespace()] )
+ && $previewOnOpenNamespaces[$this->mTitle->getNamespace()]
) {
// Categories are special
return true;
// Run new style post-section-merge edit filter
if ( !Hooks::run( 'EditFilterMergedContent',
- [ $this->mArticle->getContext(), $content, $status, $this->summary,
+ [ $this->context, $content, $status, $this->summary,
$user, $this->minoredit ] )
) {
# Error messages etc. could be handled within the hook...
* time.
*/
public function internalAttemptSave( &$result, $bot = false ) {
- global $wgMaxArticleSize;
- global $wgContentHandlerUseDB;
-
$status = Status::newGood();
$user = $this->context->getUser();
}
$this->contentLength = strlen( $this->textbox1 );
- if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
+ $config = $this->context->getConfig();
+ $maxArticleSize = $config->get( 'MaxArticleSize' );
+ if ( $this->contentLength > $maxArticleSize * 1024 ) {
// Error will be displayed by showEditForm()
$this->tooBig = true;
$status->setResult( false, self::AS_CONTENT_TOO_BIG );
$changingContentModel = false;
if ( $this->contentModel !== $this->mTitle->getContentModel() ) {
- if ( !$wgContentHandlerUseDB ) {
+ if ( !$config->get( 'ContentHandlerUseDB' ) ) {
$status->fatal( 'editpage-cannot-use-custom-model' );
$status->value = self::AS_CANNOT_USE_CUSTOM_MODEL;
return $status;
// Check for length errors again now that the section is merged in
$this->contentLength = strlen( $this->toEditText( $content ) );
- if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
+ if ( $this->contentLength > $maxArticleSize * 1024 ) {
$this->tooBig = true;
$status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
return $status;
}
public function setHeaders() {
- global $wgAjaxEditStash;
-
$out = $this->context->getOutput();
$out->addModules( 'mediawiki.action.edit' );
# Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys
$out->addJsConfigVars( [
'wgEditMessage' => $msg,
- 'wgAjaxEditStash' => $wgAjaxEditStash,
+ 'wgAjaxEditStash' => $this->context->getConfig()->get( 'AjaxEditStash' ),
] );
}
$out->addHTML( $this->editFormTextBeforeContent );
- if ( !$this->isCssJsSubpage && $showToolbar && $user->getOption( 'showtoolbar' ) ) {
+ if ( !$this->mTitle->isCssJsSubpage() && $showToolbar && $user->getOption( 'showtoolbar' ) ) {
$out->addHTML( self::getEditToolbar( $this->mTitle ) );
}
}
protected function showHeader() {
- global $wgAllowUserCss, $wgAllowUserJs;
-
$out = $this->context->getOutput();
$user = $this->context->getUser();
if ( $this->isConflict ) {
);
}
} else {
- if ( $this->isCssJsSubpage ) {
+ if ( $this->mTitle->isCssJsSubpage() ) {
# Check the skin exists
- if ( $this->isWrongCaseCssJsPage ) {
+ if ( $this->isWrongCaseCssJsPage() ) {
$out->wrapWikiMsg(
"<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>",
[ 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ]
);
}
if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) {
+ $isCssSubpage = $this->mTitle->isCssSubpage();
$out->wrapWikiMsg( '<div class="mw-usercssjspublic">$1</div>',
- $this->isCssSubpage ? 'usercssispublic' : 'userjsispublic'
+ $isCssSubpage ? 'usercssispublic' : 'userjsispublic'
);
if ( $this->formtype !== 'preview' ) {
- if ( $this->isCssSubpage && $wgAllowUserCss ) {
+ $config = $this->context->getConfig();
+ if ( $isCssSubpage && $config->get( 'AllowUserCss' ) ) {
$out->wrapWikiMsg(
"<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
[ 'usercssyoucanpreview' ]
);
}
- if ( $this->isJsSubpage && $wgAllowUserJs ) {
+ if ( $this->mTitle->isJsSubpage() && $config->get( 'AllowUserJs' ) ) {
$out->wrapWikiMsg(
"<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
[ 'userjsyoucanpreview' ]
*/
function getSummaryInputOOUI( $summary = "", $labelText = null, $inputAttrs = null ) {
wfDeprecated( __METHOD__, '1.30' );
- $this->getSummaryInputWidget( $summary, $labelText, $inputAttrs );
+ return $this->getSummaryInputWidget( $summary, $labelText, $inputAttrs );
}
/**
$newContent = $oldContent->getContentHandler()->makeEmptyContent();
}
- $de = $oldContent->getContentHandler()->createDifferenceEngine( $this->mArticle->getContext() );
+ $de = $oldContent->getContentHandler()->createDifferenceEngine( $this->context );
$de->setContent( $oldContent, $newContent );
$difftext = $de->getDiff( $oldtitle, $newtitle );
$content2 = $this->toEditContent( $this->textbox2 );
$handler = ContentHandler::getForModelID( $this->contentModel );
- $de = $handler->createDifferenceEngine( $this->mArticle->getContext() );
+ $de = $handler->createDifferenceEngine( $this->context );
$de->setContent( $content2, $content1 );
$de->showDiff(
$this->context->msg( 'yourtext' )->parse(),
* @return string
*/
public function getPreviewText() {
- global $wgRawHtml;
- global $wgAllowUserCss, $wgAllowUserJs;
-
$out = $this->context->getOutput();
+ $config = $this->context->getConfig();
- if ( $wgRawHtml && !$this->mTokenOk ) {
+ if ( $config->get( 'RawHtml' ) && !$this->mTokenOk ) {
// Could be an offsite preview attempt. This is very unsafe if
// HTML is enabled, as it could be an attack.
$parsedNote = '';
if ( $content->getModel() == CONTENT_MODEL_CSS ) {
$format = 'css';
- if ( $level === 'user' && !$wgAllowUserCss ) {
+ if ( $level === 'user' && !$config->get( 'AllowUserCss' ) ) {
$format = false;
}
} elseif ( $content->getModel() == CONTENT_MODEL_JAVASCRIPT ) {
$format = 'js';
- if ( $level === 'user' && !$wgAllowUserJs ) {
+ if ( $level === 'user' && !$config->get( 'AllowUserJs' ) ) {
$format = false;
}
} else {
* @return ParserOptions
*/
protected function getPreviewParserOptions() {
- $parserOptions = $this->page->makeParserOptions( $this->mArticle->getContext() );
+ $parserOptions = $this->page->makeParserOptions( $this->context );
$parserOptions->setIsPreview( true );
$parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !== '' );
$parserOptions->enableLimitReport();
* @return array
*/
public function getCheckboxes( &$tabindex, $checked ) {
+ wfDeprecated( __METHOD__, '1.30' );
$checkboxes = [];
$checkboxesDef = $this->getCheckboxesDefinition( $checked );
* @return array Associative array of string keys to OOUI\FieldLayout instances
*/
public function getCheckboxesOOUI( &$tabindex, $checked ) {
+ wfDeprecated( __METHOD__, '1.30' );
return $this->getCheckboxesWidget( $tabindex, $checked );
}
/**
* Get the message key of the label for the button to save the page
*
+ * @since 1.30
* @return string
*/
protected function getSubmitButtonLabel() {
* @since 1.29
*/
protected function addLongPageWarningHeader() {
- global $wgMaxArticleSize;
-
if ( $this->contentLength === false ) {
$this->contentLength = strlen( $this->textbox1 );
}
$out = $this->context->getOutput();
$lang = $this->context->getLanguage();
- if ( $this->tooBig || $this->contentLength > $wgMaxArticleSize * 1024 ) {
+ $maxArticleSize = $this->context->getConfig()->get( 'MaxArticleSize' );
+ if ( $this->tooBig || $this->contentLength > $maxArticleSize * 1024 ) {
$out->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
[
'longpageerror',
$lang->formatNum( round( $this->contentLength / 1024, 3 ) ),
- $lang->formatNum( $wgMaxArticleSize )
+ $lang->formatNum( $maxArticleSize )
]
);
} else {
];
// The following classes can be used here:
- // * mw-editfont-default
// * mw-editfont-monospace
// * mw-editfont-sans-serif
// * mw-editfont-serif