Page MenuHomePhabricator

Provide easy, backend way for extensions to show PostEdit notifications with custom content
Closed, DeclinedPublic

Description

I've recently been working on an extension, and it would be nice for it to show a PostEdit success box when it successfully completes an operation. However, doing this at the moment would mean loading a Javascript file, the PHP setting a JS config var for whether to display the PostEdit box or not, JS checking this variable, JS getting a message for the text to display, etc.

What would really be useful would be a way, just in PHP, for extensions to specify that a PostEdit box should be shown, with the text to display. The code would then ensure that JS to show the box is loaded on the page (which would possibly also save resources over the above method).

I am not entirely sure how this would be best implemented, but possibly something like wfShowPostEdit( $text ), that could be easily called in an extension's code. Something like this would make it many more times easier for extensions to show PostEdit boxes.


Version: unspecified
Severity: enhancement

Details

Reference
bz63740

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:10 AM
bzimport set Reference to bz63740.
bzimport added a subscriber: Unknown Object (MLST).

MediaWiki 1.21 provides a wgPostEdit variable (bug 43270) depending on mediawiki.action.view.postEdit.
Per bug 48276, the VisualEditor extension depends on it, but looks like you'd like to define your own strings to display here?

Yeah, it would be nice extensions to be able to show their own messages, depending on their function.

(Sorry about the categorisation stuff, still pretty unexperienced here :) )

Krinkle subscribed.

I think what you're looking for is mw.notify().

See also https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.plugin.notify. Be sure to load the mediawiki.notify module (or add it as dependency to your script).

There are various examples in MediaWiki core that use this. Including the ajax modules for patrol and watch actions. E.g. click the watch star on a page when logged-in.