Extension:RecordAdmin

Install using subversion on a unix system
To install from subversion under a unix system, change to the directory of your wiki extensions folder and check out the extension code. cd /var/www/mywiki/extensions svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/RecordAdmin/ You will need the svn client installed to use this method. Under debian/ubuntu or other apt based system use: apt-get install subversion Under Redhat/Centos or other RPM based unix use: yum install subversion

Configuring LocalSettings.php
Add this line to LocalSettings.php require_once("extensions/RecordAdmin/RecordAdmin.php");

Global configuration options

 * $wgRecordAdminCategory - Categorise a template with this category to tell RecordAdmin that the template represents a data type. Default value is Records so add   to your template. It is essential that you do this otherwise you will have no record types to work with.
 * $wgRecordAdminUseNamespaces

Handling records in a wiki
In a wiki the natural way of representing a record is by using template syntax in an article as in the following example:

The template (in this case Template:Member) defines how such a record should look to the public, and the corresponding article in the Form namespace (e.g. Form:Member) is used internally by administrators to manage and adjust the records. the template may not contain all the possible parameters because some of them are for internal use only, but the form needs to contain them all.

Forms
This extension was developed primarily for wikis used in business which don't allow public editing and can therefore have Raw HTML enabled, so the forms can be created using standard HTML as in the following example form. This means that normal Javascript validation techniques can be added.

Title:  Mr                Mrs Miss Ms

First names: 

Surname: 
 * The class attribute is only included so that CSS rules can be applied to the form if necessary.
 * Note that there is no need for any action parameter or submit inputs, all these aspects are handled by the RecordAdmin extension.
 * This may be adjusted in future to allow other extension's like SimpleForms to make the forms so that Raw HTML isn't necessary.

Setting up a template for use with RecordAdmin
Make a new template and this content into the page. Replace Visitor with whatever you call your record type. Next make a normal template definition to display the information you want.
 * Name:
 * Address:

Using the special page
If no type of record is specified in the special page URL parameter, then a selection of the available records is presented. The records available are obtained from finding all the template articles which are in Category:Records (the category used is set in the '$wgRecordAdminCategory global variable). After a record type as been selected, the form for that kind of record is shown and can then be used to create new records, or define parameters used to find matching records.



Searching for records
The search form works like a filter, so leaving it completely empty and then clicking search will list all members. Filling in some characters such as 123 into the phone field, then clicking search will list all members having 123 in their phone number somewhere. The results will be listed below the form in a sortable table such as in the following example image.



The fields in the search form are regular expressions, so more advanced searches can be done, for example putting ^445 into the phone field will search for all members who's phone number starts with "445".

Editing and viewing records
In the search results list, click edit to change any properties of the member, or click on a results title to go to that member's article to delete it or see its history etc.

Creating new records
If the Create button is clicked instead of Search, then the values in the form will be used to create a new record. If no value is supplied in the Record ID field when a record is created, then a unique ID will be used of the format yyyymmdd-xxxxx where y, m and d represent numbers for the year, month and day, and x are random unique digits and letters. This is useful for the kinds of records such as invoices or log entries which need no specific name.

Using the parser function
A parser function allows sets of records of a specified type exhibiting specified parameters to be rendered in a page using the template corresponding to the record type. This is useful for example for having an article contain certain kinds of products that are currently in stock, or to list members who conform to criteria such as interests or expertise.

Here's an example of the parser function syntax:

The "cols" parameter is used to specify which columns you'd like to be displayed and in what order. The column names are case sensitive. The first three columns shown in the example above are special ones which represent the link to the record article, the "edit" and "view" links, and the creation date respectively.

The sortable parameter specifies that the results be rendered in a sortable table so that it can be re-ordered by clicking on column headers, and the orderby parameter specifies which column the table should be sorted by initially.

The next two parameters are conditions in the form of regular expressions which are applied to the corresponding field name. In this case the table will contain records of type Inquiry and will be filtered to only those with phone numbers starting with "555" and having an "Open" status.

Record creation links
The RecordAdmin special page allows values for fields to be passed in the query-string so that links can be made for creating new records which can have some of the values pre-filled according to the context. For example a persons user page may contain the following wikitext which creates a sortable table of "Issue" records assigned to them and includes a link for creating a new issue with the "AssignedTo" field already filled out.


 * In this example we've set the "AssignedTo" parameter to since it's in a user page
 * The #tag built-in parser function is used so that we can add class="new" to the link to make it red
 * Notice that the "AssignedTo" parameter name is preceded by ra_

Public forms
Often it's useful to have public forms that create records but make only a sub-set of the fields available and fill others in internally. For example, you may run a number of sites which all post their enquiry forms to your wiki where they are made into "Inquiry" records. These enquiry forms would be cut-down versions of Form:Inquiry which use hidden values for some fields like "Website" and "User" so the user doesn't have to set them. Also some records may have "staff only" section which shouldn't be present when filled in by end-users. Such forms may also exhibit friendly widgets, validation and styles which are inappropriate for the private administration side. Here's an example of such a "public form". 

First Name: 

Last Name: 

Comments: 




 * The form's action can be set to a different article which can contain a "thank you" message or some other post-submission information
 * The resulting page (in this case the "Thanks" article) the tag &lt;recordid /&gt; can be inserted to refer to the unique ID of the created record
 * The wpType hidden input is used to specify the type of record that should be created

Form validation
Validation can be done with client side javascript, currently the extension does not support server side authentication. Here's an example of some simple validation that extends the form in the previous example to ensure the two name fields are filled in. 

First Name:  *

Last Name:  *

Comments: 



<input type="submit" name="wpCreate" value="Register!" />

<script type="text/javascript">

manditory = [ 'FirstName', 'LastName' ];

function validateRegistration(form) { var done = true; for (i in manditory) if (document.getElementById(manditory[i]).value == '') done = false; if (!done) alert('Please ensure that all the fields marked with red asterisks are filled in!'); return done; }
 * A simple JavaScript validation function has been added to the form and is called from the form's onsubmit attribute
 * The fields which are manditory are added in the script to the manditory array
 * We've added asterisks after the manditory fields which are made red with MediaWiki's "error" CSS class

Useful RecordAdmin templates
still in development