Extension:Semantic Forms Inputs

Description
Semantic Forms Inputs is an extension to MediaWiki that provides additional input types for Semantic MediaWikis that use the Semantic Forms extension.

The Semantic Forms extension allows users to add, edit and query data of a Semantic MediaWiki using forms. For every form field the input type specifies the type of input a field will have in the form. Semantic Forms comes with basic input types for all data types. This extension -- Semantic Forms Inputs -- aims to collect further, optically and/or functionally enhanced input types.

Download instructions
Download released versions from Semantic Forms Inputs at Google Code or get the code using Subversion:

There is a version history available.

Installation
Having MediaWiki (version 1.16 or higher), Semantic MediaWiki (version 1.4 or higher) and Semantic Forms (version 1.8.4 or higher; 2.0 or higher to use the 'simpledatepicker' input) installed is a precondition for the Semantic Forms Inputs extension; the code will not work without it. Lower versions might work but are not tested.

For the 'datepicker' input to work the [http://developer.yahoo.com/yui/ Yahoo! User Interface] (YUI) Javascript library (version 2.7.0b or higher) must be available, either locally installed or via existing internet connection.

(The HeaderTabs extension 0.6.6 seems to work with 2.7.0b with some small change in the HeaderTabs.php: Remove the if-clause in lines 118 .. 126, then remove " . style" from line 127. The catch with that solution is, that the browser history feature of the Header Tabs will still not work, so you will have to deactivate it.)

Create a directory named SemanticFormsInputs in the /extensions directory of your MediaWiki installation and copy the extension's files into it. Then add the following line to your LocalSettings.php below the inclusion of the Semantic Forms extension:

require_once('extensions/SemanticFormsInputs/SemanticFormsInputs.php');

Configuration parameters
You can change the settings of the Semantic Forms Inputs extension by placing new settings in your LocalSettings.php file, below the inclusion of SemanticFormsInputs.php.

You can find all the current settings in the file SFI_Settings.php.

Simple date picker
Input type: simpledatepicker

The simple date picker lets a user pop up a graphical calendar and enables the user to choose a date from it. The calendar is generated entirely via script and can be navigated without any page refreshes. It currently offers no parameters.

This input requires version 2.0 or higher of Semantic Forms to work.

Examples
Example: A field that uses a simple date picker

Date picker
Input type: datepicker

The date picker lets a user pop up a graphical calendar and enables the user to choose a date from it. The calendar is generated entirely via script and can be navigated without any page refreshes. You can tweak the appearance of the calendar by changing or overriding the CSS rules of the YUI library.

Examples
Example: A field that uses a date picker with all parameters set to their default values

Example: A field that uses a date picker with specific parameters:

Regular expression filter
Input type: regexp

What it does: With the Regular Expression Filter you can fine-tune what values are allowed and what is blocked in your input fields. You can even string several filters together to have a cascade of checks, e.g. to give an error message specific to what violation occured.

How it works: Specify regexp as your input type and in the parameter regexp give a Javascript regular expression, that the user input has to match. If you want a base type different from text specify it with the parameter base type. You may want to specify an error message with the message parameter. Finally there is the problem, that you can not use the | character because it gets lost in the field definition. Use ! instead. Or specifiy any other replacement character in the parameter or char and use that. See Writing a Regular Expression Pattern for an introduction to writing a regular expression pattern in Javascript.

If you want to specify a chain of regexp filters there is the problem, that every parameter can be used only once in every field definition, e.g. just giving regexp twice will not work. To work around that and still be able to address the filters further down the chain, specify a prefix for each filter in the parameter base prefix of its predecessor. Sounds complicated? Have a look at the example below. You may, but do not need to specify a prefix for the final input type - each filter stage consumes only the parameters from the parameter set, that it understands, i.e. the specific parameters listed below.

Examples
Example: A simple text input field accepting only letters, numbers and spaces. (This may be useful for fields from which an article's name is generated in the Semantic Forms one-step process.)

Example: A text input field accepting only numbers and having no more than 5 digits. Certain numbers are forbidden. Each condition gets its own error message.

Example: A somewhat more complicated input field accepting valid dates in the (german) format dd.mm.yyyy with the basetype datepicker, so the user can either use the date picker or insert the date directly.

Credits
The 'datepicker' input uses the [http://developer.yahoo.com/yui/ Yahoo! User Interface (YUI)] Javascript library.

The 'simpledatepicker' input uses the jQuery and jQuery UI Javascript libraries.

Button icons for 'datepicker' and 'simpledatepicker' are derived from the Mini Icons 2 icon set from brandspankingnew.net. See the relevant article on brandspankingnew.net

Contact
Bugs should preferably be reported on the Wikimedia bug tracker.

Comments, questions and suggestions should be sent or posted to:
 * the Semantic Mediawiki User mailing list (preferred)
 * the Semantic Forms Inputs discussion page
 * the author