diff --git a/ApiVisualEditorEdit.php b/ApiVisualEditorEdit.php index eabc35b2aa..e21e134b4b 100644 --- a/ApiVisualEditorEdit.php +++ b/ApiVisualEditorEdit.php @@ -123,8 +123,27 @@ class ApiVisualEditorEdit extends ApiVisualEditor { if ( $result === false ) { $this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' ); } + $result['isRedirect'] = $page->isRedirect(); + if ( class_exists( 'FlaggablePageView' ) ) { + $view = FlaggablePageView::singleton(); + + // Defeat !$this->isPageView( $request ) || $request->getVal( 'oldid' ) check in setPageContent + $view->getContext()->setRequest( new DerivativeRequest( + $this->getRequest(), + array( + 'diff' => null, + 'oldid' => '', + 'action' => 'view' + ) + $this->getRequest()->getValues() + ) ); + + $view->setPageContent(); + $view->displayTag(); + } + $result['contentSub'] = $this->getOutput()->getSubtitle(); + $content = new WikitextContent( $wikitext ); $parserOutput = $content->getParserOutput( $page ); if ( $parserOutput ) { diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 0c6726b0f7..3e70f88280 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -439,7 +439,7 @@ ve.init.mw.ViewPageTarget.prototype.onSurfaceReady = function () { * @param {Object} lastModified Object containing user-formatted date and time strings */ ve.init.mw.ViewPageTarget.prototype.onSave = function ( - html, categoriesHtml, newid, isRedirect, displayTitle, lastModified + html, categoriesHtml, newid, isRedirect, displayTitle, lastModified, contentSub ) { var newUrlParams, watchChecked; this.saveDeferred.resolve(); @@ -482,7 +482,13 @@ ve.init.mw.ViewPageTarget.prototype.onSave = function ( this.revid = newid; } this.saveDialog.reset(); - this.replacePageContent( html, categoriesHtml, isRedirect, displayTitle, lastModified ); + this.replacePageContent( + html, + categoriesHtml, + displayTitle, + lastModified, + contentSub + ); this.setupSectionEditLinks(); this.tearDownBeforeUnloadHandler(); this.deactivate( true ); @@ -1519,12 +1525,12 @@ ve.init.mw.ViewPageTarget.prototype.onWindowPopState = function ( e ) { * @method * @param {string} html Rendered HTML from server * @param {string} categoriesHtml Rendered categories HTML from server - * @param {boolean} isRedirect Whether this page is a redirect or not * @param {string} displayTitle What HTML to show as the page title * @param {Object} lastModified Object containing user-formatted date and time strings + * @param {string} contentSub What HTML to show as the content subtitle */ ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( - html, categoriesHtml, isRedirect, displayTitle, lastModified + html, categoriesHtml, displayTitle, lastModified, contentSub ) { var $content = $( $.parseHTML( html ) ), $editableContent; @@ -1555,15 +1561,7 @@ ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( $( '#content > #firstHeading > span:first' ).html( displayTitle ); } $( '#catlinks' ).replaceWith( categoriesHtml ); - if ( isRedirect && !$( '#contentSub > #redirectsub' ).length ) { - $( '#contentSub' ).append( - $( '' ) - .attr( 'id', 'redirectsub' ) - .text( ve.msg( 'redirectpagesub' ) ) - ); - } else if ( !isRedirect ) { - $( '#contentSub > #redirectsub' ).remove(); - } + $( '#contentSub' ).html( contentSub ); }; /** diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 03ab0ce05a..322d1961db 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -564,7 +564,8 @@ ve.init.mw.Target.onSave = function ( doc, saveData, response ) { data.newrevid, data.isRedirect, data.displayTitleHtml, - data.lastModified + data.lastModified, + data.contentSub ); } };