Extension:MGet

From Mario Fan Games Galaxy Wiki
Revision as of 13:43, 24 April 2010 by Kyori (talk | contribs)

Template:Notice

MFGG Badge Get is a Mediawiki extension written by Kyori and Char. It adds a magic word (badges) that is used to automatically update the badges on the MFGG Wiki using data from the MFGG Forums.

This magic word is used in the new MFGGer template, so it is no longer necessary to specify, or update, the badges that a user has.

Usage

The extension usage is as follows:

{{#badges:forumid|[optional:badgeid_order]}}

There is no need to provide a mainsite ID; if the forum account has been linked with the mainsite, things like submitter badges will be automatically added to the forum badge table.

It should be noted that due to the probable long life of the cache (2-4 hours), badges may not display when you first use the magic word if there is no information in the cache related to the user ID that you are using. However, you can be confident in the fact that as soon as the cache expires and badges are viewed, all requested badges will be updated.

Badge Ordering

The magic word, badges, allows for ordering of the badge information before it is returned to the wiki. The syntax for this is as follows:

id1 > id7 > id3 > id38 > id4 > etc.

In this case, if a user had badges id4, id1 and id38, they would be displayed in the order id1, id38, id4. The '>' means 'comes before'.

Method

When the extension is called, it checks whether the cache has expired (the cache lifetime is specified with $wgMFGGBadgesCacheTime).

If the cache hasn't expired, the extension adds the requested user ID to a cached list of user IDs.

If the cache has expired, the extension makes a POST request containing an array of the previously cached user IDs to a script in the forum directory, which then queries the database for the badge information for those users. The script returns the information and the extension caches it in a local file.

The script then sorts through the information (either from the cache or from a request) and finds the requested user badges, then returns them in the Badge template format:

{{Badge|id|count|auto=true}}

Note: auto is set to true so that the Badge template knows to use the badge ID image naming scheme ("Badge42.png" instead of "Badge_sysop.png").

Configuration Variables

These are the various settings that can be modified in LocalSettings.php.

# Address of the forum badge get script
$wgMFGGBadgesReadFileAddress;
# Number of seconds that the cache should live for (set to 4 hours by default)
$wgMFGGBadgesCacheTime;
# Security code to be provided to the forum script
$wgMFGGBadgesSecurityCode;

Version Log

  • v0.0.1 - Not in general usage due to being just a little bit buggy!