Extension:Semantic Forms Inputs

Description
Semantic Forms Inputs is an extension to MediaWiki providing 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 the latest version from Semantic Forms Inputs at Google Code or get it using Subversion:

To get the latest trunk version use:

Installation
Remember that having Semantic MediaWiki and Semantic Forms installed is a precondition for the Semantic Forms Inputs extension; the code will not work without it.

For the date picker to work the [http://developer.yahoo.com/yui/ Yahoo! User Interface] (YUI) Javascript library must be available, either locally installed or via existing internet connection. As the library is used by the Semantic Forms extension as well, this should not be a problem.

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 tweak the settings of the Semantic Forms Inputs extension in the SemanticFormsInputs.Settings.inc file. You can find it in your extensions/SemanticFormsInputs directory.

If you do not want to alter that file just put the settings in your LocalSettings.php below the inclusion of SemanticFormsInputs.php

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.

Preconditions: The [http://developer.yahoo.com/yui/ Yahoo! User Interface] (YUI) Javascript library must be available, either locally installed or via existing internet connection. As the library is used by the Semantic Forms extension as well, this should not be a problem.

Examples
Example: A field that uses a simple 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.