Extension:Widgets

Widgets extension allows adding widgets to wiki by just creating pages in Widget namespace.

This extension was developed by Sergey Chernyshev for Ardorado.com and sponsored by Semantic Communities, LLC.

Usage
To add a widget to MediaWiki installation, just create a page in Widget namespace and then use  parser function to include it to the pages of the wiki.

Widget page syntax
Widget extension uses Smarty PHP templating engine to provide simple templating functionality within widget pages. All parameters passed to widget are converted into Smarty parameters.

You should use escape modifiers to make sure that user parameters can not expose hosting website to XSS (or any other) attacks.

parser function
To add defined widget to pages, users can use  parser function. The syntax is as follows:

Where WidgetName is a page name in Widget namespace (e.g. Widget:WidgetName) and param=value pairs are defining parameters defined within widget code.

Arrays
If you use the same parameter multiple times, widget will get an array of values. You can use to go through the array.

Dotted notation
Parameter names can have dots and Smarty will interpret them as associative arrays so you can use with both   and   attributes to traverse through them, or you can just use the same name with dots if you want to reference parameter directly.

Refreshing widget page
If you're using a call to the widget within the widget page itself, then you will not see the updated widget (and no widget at all when you just created a page). This happens because page contents are not available to Widget extension until page is saved, but the call to  parser function is made before page is saved. After pages is saved, it's being cached by MediaWiki so you don't see the result even if you just reload the page. To make latest edits of the widget code to work, you need to refresh the page in the cache, to do this, you just need to use  action (see also Purgetab extension).

Download instructions
Download the code archive and extract it to  folder. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installing from tarball
You can download Widgets code here:
 * Widgets-0.8.1.tgz - compressed using tar and gzip
 * Widgets-0.8.1.zip - compressed using zip

Installing from SVN
To get code from Subversion, just type svn checkout http://mediawiki-widgets.googlecode.com/svn/trunk/ Widgets

Installation
To install this extension, add the following to LocalSettings.php:

Folder permissions
Also,  folder should be made writable by web server (this is where Smarty stores pre-compiled templates).

Configuration parameters
You can set namespace ID to something different then default (274), make sure that it's an even number. Talk namespace ID will be

User rights
This extension adds Widget namespace, but due to potential security implications that can result from using insecure widget code, this namespace is only editable by users who have  permission (  group is also created to add users to, see Help:User rights management for more details).

To allow widgets to be editable by sysops, add the following to your 'LocalSettings.php' file:

$wgGroupPermissions['sysop']['editwidgets'] = true;

CHANGES

 * 0.8.1 (June 25, 2008) - Worked around MediaWiki bug that inserts  in front of widget output.
 * 0.8 (June 10, 2008) - Fixed a bug where variables were carried over from one widget to another on the same page
 * 0.7 (May 23, 2008) - Added support for arrays and Smarty's dotted notation
 * 0.6 (May 9, 2008) - Minor tweaks and bug fixes, release Makefile
 * 0.5 (Feb 11, 2008) - First public release

TODO

 * implement square bracket parameter parsing to support passing arrays (regular and associative)

Contributing code and widgets
If you would like to contribute patches or found some problems with the code, please send message to the discussion group: http://groups.google.com/group/mediawiki-widgets

If you created a widget and would like to share it, feel free to post it to MediaWikiWidgets.org or just add it to Widgets library.

Support
The best way to seek help with this widget is MediaWiki Widgets Google group - extension maintainer and active users and contributors are on this list and will be able to help you.

Widgets library
MediaWikiWidgets.org contains a full library of ready-made widgets, including support for most of the major video sites. Any widget can be used simply by copying over the contents of the page.

To get a most up to date list of widgets click here.