Extension:Submit In Toolbar
|
Submit In Toolbar Release status: unknown |
|
|---|---|
| Implementation | Page action |
| Description | Adds 'Save', 'Preview' and 'Diff' buttons to Toolbar. |
| Author(s) | VitasTalk |
| Last version | 0.0.2 |
| MediaWiki | 1.8.2 |
| License | GPL |
| Download | .tgz |
|
Check usage (experimental) |
|
Adds Save, Preview, Diff buttons to Toolbar.
Contents |
[edit] Installation
[edit] MediaWiki 1.16
- Download extension and place it in /extensions/SubmitInToolbar/
- Insert these lines into LocalSettings.php:
require_once("extensions/SubmitInToolbar/SubmitInToolbar.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.)
[edit] MediaWiki 1.15 and earlier
|
|
This extension requires patches to core MediaWiki code. Extensions implemented using patches may be disabled by or interfere with upgrades and security patches. If a suitable alternative without a patch is available, we recommend you use that extension instead. |
- Download extension and place it in /extensions/SubmitInToolbar/
- Apply this Patch to includes/EditPage.php:
search for (around Line 2130 in V1.14)
$toolbar.="/*]]>*/\n</script>";
$toolbar.="\n</div>";
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)
$text.=$ret;
after, add
return true;
- add to LocalSettings.php:
require_once ("extensions/SubmitInToolbar/SubmitInToolbar.php");
[edit] Configuration
If not installed on expected path (which is extensions/SubmitInToolbar/), override $wgSubmitInToolbar by:
$wgSubmitInToolbar = "$wgScriptPath/path-to-SubmitInToolbar-dir";
[edit] Source code
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:
<? 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'), 'button'=>"wpSave", ), array( 'image' =>'button_preview.png', 'tip' => wfMsg('showpreview'), 'button'=>"wpPreview", ), array( 'image' =>'button_diff.png', 'tip' => wfMsg('showdiff'), 'button'=>"wpDiff", ), ); $ret = addSubmitButton_js_text(); foreach($arr_tool as $tool) { $image=$wgSubmitInToolbarPath ."/images/" . $tool['image']; $button=$tool['button']; $tip=$tool['tip']; $ret.="addSubmitButton('$image','$tip','$button');\n"; } $text.=$ret; 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); button.click(); return false; } // image.onclick = 'javascript:document.getElementById("' + // escapeQuotesHTML(buttonId) + // '").click();'; toolbar.appendChild(image); } function addSubmitButtons() { var toolbar = document.getElementById('toolbar'); if (!toolbar) return false; sp = document.createElement('span'); sp.innerHTML= " " toolbar.appendChild(sp); for(var i in mwSubmitButtons) { addSubmitButtons_insert(toolbar, mwSubmitButtons[i]); } } hookEvent("load", addSubmitButtons); EOL; } /* document.write( '<a href="javascript:' + '(document.getElementById(' + "'" + escapeQuotesHTML(buttonId) + "'" + ')).click()"' + '>' + '<img width="23" height="22" ' + 'src="' + escapeQuotesHTML(imageFile) + '" ' + 'border="0" ' + 'alt="' + escapeQuotesHTML(speedTip) + '" ' + 'title="'+ escapeQuotesHTML(speedTip) + '" ' + '/></a>'); } */ $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.
[edit] Bugs
- 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 :(
[edit] Alternatives
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.
[edit] Who's using it?
Please add your wiki here! Add it to the top, and feel free to add a link to your favourite article or two.
