Merge "Expand core post edit functionality to match VE"
This commit is contained in:
commit
82b8b57893
5 changed files with 35 additions and 10 deletions
|
|
@ -1213,13 +1213,22 @@ class EditPage {
|
|||
*
|
||||
* If the variable were set on the server, it would be cached, which is unwanted
|
||||
* since the post-edit state should only apply to the load right after the save.
|
||||
*
|
||||
* @param $statusValue int The status value (to check for new article status)
|
||||
*/
|
||||
protected function setPostEditCookie() {
|
||||
protected function setPostEditCookie( $statusValue ) {
|
||||
$revisionId = $this->mArticle->getLatest();
|
||||
$postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
|
||||
|
||||
$val = 'saved';
|
||||
if ( $statusValue == self::AS_SUCCESS_NEW_ARTICLE ) {
|
||||
$val = 'created';
|
||||
} elseif ( $this->oldid ) {
|
||||
$val = 'restored';
|
||||
}
|
||||
|
||||
$response = RequestContext::getMain()->getRequest()->response();
|
||||
$response->setcookie( $postEditKey, '1', time() + self::POST_EDIT_COOKIE_DURATION, array(
|
||||
$response->setcookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, array(
|
||||
'path' => '/',
|
||||
'httpOnly' => false,
|
||||
) );
|
||||
|
|
@ -1257,7 +1266,7 @@ class EditPage {
|
|||
if ( $status->value == self::AS_SUCCESS_UPDATE || $status->value == self::AS_SUCCESS_NEW_ARTICLE ) {
|
||||
$this->didSave = true;
|
||||
if ( !$resultDetails['nullEdit'] ) {
|
||||
$this->setPostEditCookie();
|
||||
$this->setPostEditCookie( $status->value );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -687,7 +687,9 @@
|
|||
"edit-gone-missing": "Could not update the page.\nIt appears to have been deleted.",
|
||||
"edit-conflict": "Edit conflict.",
|
||||
"edit-no-change": "Your edit was ignored because no change was made to the text.",
|
||||
"postedit-confirmation": "Your edit was saved.",
|
||||
"postedit-confirmation-created": "The page has been created.",
|
||||
"postedit-confirmation-restored": "The page has been restored.",
|
||||
"postedit-confirmation-saved": "Your edit was saved.",
|
||||
"edit-already-exists": "Could not create a new page.\nIt already exists.",
|
||||
"addsection-preload": "",
|
||||
"addsection-editintro": "",
|
||||
|
|
|
|||
|
|
@ -849,7 +849,9 @@
|
|||
"edit-gone-missing": "Used as error message.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-conflict}}\n* {{msg-mw|edit-no-change}}\n* {{msg-mw|edit-already-exists}}",
|
||||
"edit-conflict": "An 'Edit conflict' happens when more than one edit is being made to a page at the same time. This would usually be caused by separate individuals working on the same page. However, if the system is slow, several edits from one individual could back up and attempt to apply simultaneously - causing the conflict.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-gone-missing}}\n* {{msg-mw|edit-no-change}}\n* {{msg-mw|edit-already-exists}}",
|
||||
"edit-no-change": "Used as error message.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-gone-missing}}\n* {{msg-mw|edit-conflict}}\n* {{msg-mw|edit-already-exists}}",
|
||||
"postedit-confirmation": "{{gender}}\nConfirmation message that is displayed upon successful edit.\n\nParameters:\n* $1 - (Optional) the current user, for GENDER support",
|
||||
"postedit-confirmation-created": "{{gender}}\nShown after a user creates a new page. Parameters:\n* $1 - the current user, for GENDER support",
|
||||
"postedit-confirmation-restored": "{{gender}}\nShown after a user restores a page to a previous revision. Parameters:\n* $1 - the current user, for GENDER support",
|
||||
"postedit-confirmation-saved": "{{gender}}\nShown after a user saves a page. Parameters:\n* $1 - the current user, for GENDER support",
|
||||
"edit-already-exists": "Used as error message.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-gone-missing}}\n* {{msg-mw|edit-conflict}}\n* {{msg-mw|edit-no-change}}",
|
||||
"addsection-preload": "{{notranslate}}",
|
||||
"addsection-editintro": "{{notranslate}}",
|
||||
|
|
|
|||
|
|
@ -975,7 +975,9 @@ return array(
|
|||
'mediawiki.jqueryMsg'
|
||||
),
|
||||
'messages' => array(
|
||||
'postedit-confirmation',
|
||||
'postedit-confirmation-created',
|
||||
'postedit-confirmation-restored',
|
||||
'postedit-confirmation-saved',
|
||||
),
|
||||
),
|
||||
'mediawiki.action.view.redirectToFragment' => array(
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@
|
|||
var config = mw.config.get( [ 'wgAction', 'wgCookiePrefix', 'wgCurRevisionId' ] ),
|
||||
// This should match EditPage::POST_EDIT_COOKIE_KEY_PREFIX:
|
||||
cookieKey = config.wgCookiePrefix + 'PostEditRevision' + config.wgCurRevisionId,
|
||||
cookieVal = $.cookie( cookieKey ),
|
||||
$div, id;
|
||||
|
||||
function showConfirmation( data ) {
|
||||
data = data || {};
|
||||
if ( data.message === undefined ) {
|
||||
data.message = $.parseHTML( mw.message( 'postedit-confirmation', data.user || mw.user ).escaped() );
|
||||
data.message = $.parseHTML( mw.message( 'postedit-confirmation-saved', data.user || mw.user ).escaped() );
|
||||
}
|
||||
|
||||
$div = $(
|
||||
|
|
@ -66,11 +67,20 @@
|
|||
|
||||
mw.hook( 'postEdit' ).add( showConfirmation );
|
||||
|
||||
if ( config.wgAction === 'view' && $.cookie( cookieKey ) === '1' ) {
|
||||
$.cookie( cookieKey, null, { path: '/' } );
|
||||
if ( config.wgAction === 'view' && cookieVal ) {
|
||||
mw.config.set( 'wgPostEdit', true );
|
||||
|
||||
mw.hook( 'postEdit' ).fire();
|
||||
mw.hook( 'postEdit' ).fire( {
|
||||
// The following messages can be used here:
|
||||
// postedit-confirmation-saved
|
||||
// postedit-confirmation-created
|
||||
// postedit-confirmation-restored
|
||||
'message': mw.msg(
|
||||
'postedit-confirmation-' + cookieVal,
|
||||
mw.user
|
||||
)
|
||||
} );
|
||||
$.cookie( cookieKey, null, { path: '/' } );
|
||||
}
|
||||
|
||||
} ( mediaWiki, jQuery ) );
|
||||
|
|
|
|||
Loading…
Reference in a new issue