Extension:SemanticFormsToolbar
Semantic Forms Toolbar Release status: beta |
|
---|---|
Implementation | Page action, API |
Description | Provides an infrastructure for turning semantic forms into toolbar items |
Author(s) | Andrew Garrett (Werdnatalk) |
Latest version | 1.0 |
MediaWiki | 1.16+ |
License | TBC |
Download | ExtensionDistributor |
Translate the SemanticFormsToolbar extension if possible |
|
Check usage and version matrix; code metrics |
What can this extension do?[edit | edit source]
SemanticFormsToolbar provides a basic infrastructure for converting a semantic form into a toolbar icon. It was generated so that forms can be used to generate elements that are placed inline in wikitext, instead of editing an entire page.
Usage[edit | edit source]
In JavaScript, you can create a dialog definition suitable for WikiEditor's addDialog API using code similar to the following:
$j('#wpTextbox1').wikiEditor( 'addDialog', {'recommendation-form' : sfToolbar.getDialog( 'Form:Recommendation', 'recommendation' ) } );
Remember that you also need to associate a toolbar icon with the appropriate dialog like so:
// Recommendation dialog $j('#wpTextbox1').wikiEditor( 'addToToolbar', { 'section' : 'main', 'group' : 'insert', 'tools' : { 'recommendation-dialog' : { 'label' : 'Insert recommendation', 'type' : 'button', 'icon' : '/images/recommendation.png', 'action' : { 'type' : 'dialog', 'module' : 'recommendation-form' } } } } );
The public interface for SemanticFormsToolbar consists of one method: sfToolbar.getDialog. It takes two parameters: the first is the name of the form to be used, and the second is a unique identifier for this dialog (for HTML ids).
When the dialog is triggered, it will prefill the form with any templates that are selected in the editor, so you can edit a template with the forms as well as inserting one. The "save" button on the form is overridden by a JavaScript action, which replaces the current text with the output of the form.
Download instructions[edit | edit source]
Download the tarball from MediaWiki.org, and extract it in your extensions directory.
Installation[edit | edit source]
Note that, before you install SemanticFormsToolbar, you must have Semantic MediaWiki and SemanticForms installed as well.
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/SemanticFormsToolbar/SemanticFormsToolbar.php");