Merge "EditPage: Show a different label for the button on create vs. modify"
[lhc/web/wiklou.git] / includes / EditPage.php
index 674cf28..da35fb5 100644 (file)
@@ -1474,7 +1474,7 @@ class EditPage {
 
                        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:
@@ -1551,7 +1551,7 @@ class EditPage {
                                // 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;
                }
@@ -2714,8 +2714,9 @@ class EditPage {
                $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' );
 
@@ -2913,6 +2914,9 @@ class EditPage {
                                        );
                                }
                                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(
@@ -3442,41 +3446,12 @@ HTML
                        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 ) {
@@ -4075,13 +4050,14 @@ HTML
        public function getEditButtons( &$tabindex ) {
                $buttons = [];
 
+               $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 = [