/** @var bool */
public $tooBig = false;
- /** @var bool */
- public $kblength = false;
-
/** @var bool */
public $missingComment = false;
/** @var bool */
protected $edit;
+ /** @var bool|int */
+ protected $contentLength = false;
+
/**
* @var bool Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing
*/
case self::AS_CANNOT_USE_CUSTOM_MODEL:
case self::AS_PARSE_ERROR:
- $wgOut->addWikiText( '<div class="error">' . $status->getWikiText() . '</div>' );
+ $wgOut->addWikiText( '<div class="error">' . "\n" . $status->getWikiText() . '</div>' );
return true;
case self::AS_SUCCESS_NEW_ARTICLE:
// is if an extension hook aborted from inside ArticleSave.
// Render the status object into $this->hookError
// FIXME this sucks, we should just use the Status object throughout
- $this->hookError = '<div class="error">' . $status->getWikiText() .
+ $this->hookError = '<div class="error">' ."\n" . $status->getWikiText() .
'</div>';
return true;
}
return $status;
}
- $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
- if ( $this->kblength > $wgMaxArticleSize ) {
+ $this->contentLength = strlen( $this->textbox1 );
+ if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
// Error will be displayed by showEditForm()
$this->tooBig = true;
$status->setResult( false, self::AS_CONTENT_TOO_BIG );
}
// Check for length errors again now that the section is merged in
- $this->kblength = (int)( strlen( $this->toEditText( $content ) ) / 1024 );
- if ( $this->kblength > $wgMaxArticleSize ) {
+ $this->contentLength = strlen( $this->toEditText( $content ) );
+ if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
$this->tooBig = true;
$status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
return $status;
$wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'hiddencats' ],
Linker::formatHiddenCategories( $this->page->getHiddenCategories() ) ) );
- $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'limitreport' ],
- self::getPreviewLimitReport( $this->mParserOutput ) ) );
+ if ( $this->mParserOutput ) {
+ $wgOut->setLimitReportData( $this->mParserOutput->getLimitReportData() );
+ }
$wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' );
);
}
if ( $this->getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) {
+ $wgOut->wrapWikiMsg( '<div class="mw-usercssjspublic">$1</div>',
+ $this->isCssSubpage ? 'usercssispublic' : 'userjsispublic'
+ );
if ( $this->formtype !== 'preview' ) {
if ( $this->isCssSubpage && $wgAllowUserCss ) {
$wgOut->wrapWikiMsg(
'wrap' => "<div class=\"mw-titleprotectedwarning\">\n$1</div>" ] );
}
- if ( $this->kblength === false ) {
- $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
+ if ( $this->contentLength === false ) {
+ $this->contentLength = strlen( $this->textbox1 );
}
- if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
+ if ( $this->tooBig || $this->contentLength > $wgMaxArticleSize * 1024 ) {
$wgOut->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
[
'longpageerror',
- $wgLang->formatNum( $this->kblength ),
+ $wgLang->formatNum( round( $this->contentLength / 1024, 3 ) ),
$wgLang->formatNum( $wgMaxArticleSize )
]
);
return '';
}
- $limitReport = Html::rawElement( 'div', [ 'class' => 'mw-limitReportExplanation' ],
- wfMessage( 'limitreport-title' )->parseAsBlock()
+ return ResourceLoader::makeInlineScript(
+ ResourceLoader::makeConfigSetScript(
+ [ 'wgPageParseReport' => $output->getLimitReportData() ],
+ true
+ )
);
-
- // Show/hide animation doesn't work correctly on a table, so wrap it in a div.
- $limitReport .= Html::openElement( 'div', [ 'class' => 'preview-limit-report-wrapper' ] );
-
- $limitReport .= Html::openElement( 'table', [
- 'class' => 'preview-limit-report wikitable'
- ] ) .
- Html::openElement( 'tbody' );
-
- foreach ( $output->getLimitReportData() as $key => $value ) {
- if ( Hooks::run( 'ParserLimitReportFormat',
- [ $key, &$value, &$limitReport, true, true ]
- ) ) {
- $keyMsg = wfMessage( $key );
- $valueMsg = wfMessage( [ "$key-value-html", "$key-value" ] );
- if ( !$valueMsg->exists() ) {
- $valueMsg = new RawMessage( '$1' );
- }
- if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) {
- $limitReport .= Html::openElement( 'tr' ) .
- Html::rawElement( 'th', null, $keyMsg->parse() ) .
- Html::rawElement( 'td', null, $valueMsg->params( $value )->parse() ) .
- Html::closeElement( 'tr' );
- }
- }
- }
-
- $limitReport .= Html::closeElement( 'tbody' ) .
- Html::closeElement( 'table' ) .
- Html::closeElement( 'div' );
-
- return $limitReport;
}
protected function showStandardInputs( &$tabindex = 2 ) {
public function getEditButtons( &$tabindex ) {
$buttons = [];
+ $labelAsPublish = $this->mArticle->getContext()->getConfig()->get( 'EditButtonPublishNotSave' );
+ if ( $labelAsPublish ) {
+ $buttonLabelKey = $this->isNew ? 'publishpage' : 'publishchanges';
+ } else {
+ $buttonLabelKey = $this->isNew ? 'savearticle' : 'savechanges';
+ }
+ $buttonLabel = wfMessage( $buttonLabelKey )->text();
$attribs = [
'id' => 'wpSave',
'name' => 'wpSave',
'tabindex' => ++$tabindex,
] + Linker::tooltipAndAccesskeyAttribs( 'save' );
- $buttons['save'] = Html::submitButton( wfMessage( 'savearticle' )->text(),
- $attribs, [ 'mw-ui-constructive' ] );
+ $buttons['save'] = Html::submitButton( $buttonLabel, $attribs, [ 'mw-ui-constructive' ] );
++$tabindex; // use the same for preview and live preview
$attribs = [