Open main menu

Extension:SemanticFormsToolbar

MediaWiki extensions manual
OOjs UI icon advanced.svg
Semantic Forms Toolbar
Release status: unmaintained
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 No license specified
Download Template:WikimediaDownload/svn
Translate the SemanticFormsToolbar extension if it is available at translatewiki.net
Check usage and version matrix.

The SemanticFormsToolbar extension 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.

UsageEdit

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.

InstallationEdit

  Note: This extension requires Semantic MediaWiki and Semantic Forms to be installed first.

  • Download and place the file(s) in a directory called SemanticFormsToolbar in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/SemanticFormsToolbar/SemanticFormsToolbar.php";
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.