Extension:Submit In Toolbar

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Submit In Toolbar

Release status:Extension status unknown

ImplementationTemplate:Extension#type Page action
DescriptionTemplate:Extension#description Adds 'Save', 'Preview' and 'Diff' buttons to Toolbar.
Author(s)Template:Extension#username Vitastalk
Latest versionTemplate:Extension#version 0.0.2
MediaWikiTemplate:Extension#mediawiki 1.8.2
LicenseTemplate:Extension#license GPL
Download .tgz

Translate the Submit In Toolbar extension if it is available at translatewiki.net

Check usage and version matrix.

Adds Save, Preview, Diff buttons to Toolbar.


MediaWiki 1.16[edit]

  • Download extension and place it in /extensions/SubmitInToolbar/
  • Insert these lines into LocalSettings.php:
	$wgHooks['EditPageBeforeEditToolbar'][] = 'fnMyTools';
	function fnMyTools ( &$toolbar )
            $toolbar .= "\n<script>\n";
	    wfRunHooks('EditToolBar', array(&$toolbar));
            $toolbar .= "\n</script>\n";
	    return true;

The extension should now be ready to use. Unlike with earlier MediaWiki versions, there is no need to patch core MediaWiki 1.16 code to get "Submit in Toolbar" up and running.

As a close equivalent to the non-standard 'EditToolBar' hook (once required by this function) now exists in MediaWiki as 'EditPageBeforeEditToolbar', the small stub of code redirecting 'EditPageBeforeEditToolbar' to 'EditToolBar' is all that is needed to allow an unmodified copy of this extension to operate under an unmodified copy of MediaWiki 1.16.

(Note: As of mid-2009, MW 1.16 is still alpha code and, in theory, its specifications may be changed as the product nears final release.)

MediaWiki 1.15 and earlier[edit]

  • Download extension and place it in /extensions/SubmitInToolbar/
  • Apply this Patch to includes/EditPage.php:

search for (around Line 2130 in V1.14)

 		return $toolbar;

before, add

 		wfRunHooks('EditToolBar', array(&$toolbar));
  • Apply this patch to /extensions/SubmitInToolbar/SubmitInToolbar.php if you are using MediaWiki version 1.14 or 1.15 (an extension routine must return a value):

search for (around Line 34)


after, add

 	return true;
  • add to LocalSettings.php:
        require_once ("extensions/SubmitInToolbar/SubmitInToolbar.php");


If not installed on expected path (which is extensions/SubmitInToolbar/), override $wgSubmitInToolbar by:

  $wgSubmitInToolbar = "$wgScriptPath/path-to-SubmitInToolbar-dir";

Source code[edit]

The source listing below has been patched to return 'true' when called from MediaWiki 1.14 and 1.15.

Create extensions/SubmitInToolbar/SubmitInToolbar.php as:

       $wgHooks['EditPageBeforeEditToolbar'][] = 'fnMyTools';
       function fnMyTools ( &$toolbar )
           $toolbar .= "\n<script>\n";
           wfRunHooks('EditToolBar', array(&$toolbar));
           $toolbar .= "\n</script>\n";
           return true;

if( !isset($wgSubmitInToolbarPath) ) {
        $wgSubmitInToolbarPath = "$wgScriptPath/extensions/SubmitInToolbar";

function addSubmitButton($text) {
        global $wgStylePath;
        global $wgSubmitInToolbarPath;
        $arr_tool = array(
                array(  'image' =>'button_save.png',
                        'tip'   => wfMsg('savearticle'),
                array(  'image' =>'button_preview.png',
                        'tip'   => wfMsg('showpreview'),
                array(  'image' =>'button_diff.png',
                        'tip'   => wfMsg('showdiff'),

        $ret = addSubmitButton_js_text();

        foreach($arr_tool as $tool) {
                $image=$wgSubmitInToolbarPath ."/images/" . $tool['image'];

        return true;

function addSubmitButton_js_text() {
        return <<<EOL
// Submit buttons extension
var mwSubmitButtons = [];

function addSubmitButton(imageFile, speedTip, buttonId) {
        mwSubmitButtons[mwSubmitButtons.length] =
                {"imageFile": imageFile,
                 "speedTip": speedTip,
                 "buttonId": buttonId };

function addSubmitButtons_insert(toolbar, item){

        var image = document.createElement("img");
        image.width = 23;
        image.height = 22;
        image.src = item.imageFile;
        image.border = 0;
        image.alt = item.speedTip;
        image.title = item.speedTip;
        image.style.cursor = "pointer";
        var buttonId= item.buttonId;
        image.onclick = function() {
                var button =  document.getElementById(buttonId);
                return false;

function addSubmitButtons() {

        var toolbar = document.getElementById('toolbar');
        if (!toolbar) return false;
        sp = document.createElement('span');
        sp.innerHTML= "&nbsp;"

        for(var i in mwSubmitButtons) {
                addSubmitButtons_insert(toolbar, mwSubmitButtons[i]);


hookEvent("load", addSubmitButtons);


$wgHooks['EditToolBar'][] = 'addSubmitButton';

Create extensions/SubmitInToolbar/images and place the following icons there:

  • button_diff.png
  • button_preview.png
  • button_save.png

Each icon should be 23 x 22 in size; a suitable set of icons is already included in the download package from the extension author's site. The icons may (alternately) be obtained from any of the wikis already using this extension.


  • Probably some, tell me...
  • Icons does not look nice... :-(
  • Icons don't show at the end of the bar in wiki 1.9, they display as the first icons :(


As an alternative to using an extension to modify the toolbar, some MediaWiki sites have added code to their site-wide JavaScript (mediawiki:common.js or scripts for individual skins) to modify edit toolbar and user interface components after a page is loaded by the users' browser.

Those scripts are technically not MediaWiki extensions as they do not require the installation of PHP files on the server.

Who's using it?[edit]

Please add your wiki here! Add it to the top, and feel free to add a link to your favourite article or two.