Extension:Page Schemas

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Page Schemas

Release status: beta

Implementation Special page
Description Defines a tag, <PageSchema>, that can be used to define page schemas.
Author(s) Ankit Garg and Yaron Koren
Last version 0.3 (October 2011)
MediaWiki 1.16.* or greater
License GPL
Download See below
Hooks used
ParserFirstCallInit

Check usage (experimental)

Page Schemas is a MediaWiki extension that allows for defining all the schema information about a "class", or data type - for naming, display, data input, and browsing - within a single piece of XML contained within a category page. This XML then is used to generate all the necessary additional pages needed to put the schema into effect, such as template pages and, for instance, if Semantic Forms is installed, form pages. The XML can be created and edited via a helper form, preventing users from having to generate or modify it manually.

Page Schemas allows other extensions to define their own fields to add to the XML, using hooks. Currently, the following extensions hook into Page Schemas:

Contents

[edit] Special pages

The "edit schema" page, when Semantic MediaWiki, Semantic Forms, Semantic Drilldown and Semantic Internal Objects are installed

Page Schemas defines two pages that can show up as tabs on category pages: "Edit schema" (which appears as "Create schema" if no schema exists yet) and "Generate pages". "Edit schema" allows for creating or editing the XML via the helper form, while "Generate pages" provides a button that lets the administrator create the template(s), semantic properties, form etc. automatically from the XML definition. "Generate pages" also includes checkboxes for each of the pages to be generated, to let administrators choose not to override certain wiki pages that already exist.

Any user who is allowed to edit a certain category page will see the "Edit schema/Create schema" tab for that category, and will be allowed to use that page to modify the schema.

In order to generate pages, a user must have the 'generatepages' permission. By default, this permission is given only to members of the 'sysop' user group. You can add to or modify the set of allowed users, though, by modifying the $wgGroupPermissions array in LocalSettings.php. To enable all registered users to generate pages from the schema, for instance, you would add the following:

$wgGroupPermissions['user']['generatepages'] = true;

[edit] Code and download

You can download the Page Schemas code in either one of these two compressed files:

You can also download the code via SVN from the MediaWiki source code repository, at http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/PageSchemas/. From a command line, you can call the following:

svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/PageSchemas/

To view the code online, including version history for each file, you can go here.

[edit] Installation

After you've obtained a 'PageSchemas' directory, place this directory within the main MediaWiki 'extensions' directory. Then, in the file 'LocalSettings.php' in the main MediaWiki directory, add the following line:

include_once("$IP/extensions/PageSchemas/PageSchemas.php");

[edit] Sample XML structure

Here is some sample XML, to be contained within a page called "Category:Cities", used to define the schema for pages within that category. This section defines the name of the form, and information for a single field of that class, "Population".

<PageSchema>
        <semanticforms_Form name="City" />
        <Template name="City">
                <Field name="Population">
                        <Label>Pop.</Label>
                        <semanticmediawiki_Property name="Has population">
                                <Type>Number</Type>
                        </semanticmediawiki_Property>
                        <semanticforms_FormInput>
                                <InputType>text</InputType>
                                <Parameter name="size">20</Parameter>
                                <Parameter name="mandatory" />
                        </semanticforms_FormInput>
                        <semanticdrilldown_Filter />
                </Field>
                ...
        </Template>
        ...
</PageSchema>

[edit] Author

Page Schemas was created by Ankit Garg as part of the 2011 Google Summer of Code, and was mentored by Yaron Koren. It is currently maintained by Yaron Koren. Parts of it are based on the TemplateInfo extension, by Yaron Koren and Roan Kattouw.

[edit] Version

Page Schemas is currently at version 0.3.

The version history for Page Schemas is:

  • 0.1 - August 23, 2011 - initial version
  • 0.2 - October 13, 2011 - overhaul; many changes to display and code structure
  • 0.3 - October 25, 2011 - extensions hook into Page Schemas via a single hook and a subclass, instead of a variety of hooks; various other changes

[edit] Roadmap

Features and improvements that it would be great to add to Page Schemas in the future include:

  • Adding more options to the schema, such as support for the "standard inputs" in Semantic Forms like the free text input.
  • Allowing Semantic Forms to use the Page Schemas XML directly when generating a form, instead of requiring a separate form definition.
  • Support for subobjects instead of, or in addition to, Semantic Internal Objects.
  • Ability to export/import data structure files in formats such as UML and SQL to/from the Page Schemas XML format.
  • Making use of the proposed ContentHandler for storing XML natively, instead of in a wiki page, if/when it gets added to MediaWiki.

There are no immediate plans to add any of these, however.

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox