When saving, return the full contentSub to the client

And introduce code to make FlaggedRevs add its notices to contentSub.

Bug: 60718
Change-Id: Ibb91dc563ccf73d3b4bd1994134ccf02634fccb5
This commit is contained in:
Alex Monk 2014-11-07 00:31:34 +00:00
parent e144e55972
commit 581d1350e6
3 changed files with 32 additions and 14 deletions

View file

@ -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 ) {

View file

@ -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(
$( '<span>' )
.attr( 'id', 'redirectsub' )
.text( ve.msg( 'redirectpagesub' ) )
);
} else if ( !isRedirect ) {
$( '#contentSub > #redirectsub' ).remove();
}
$( '#contentSub' ).html( contentSub );
};
/**

View file

@ -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
);
}
};