User:Kaldari/Task 1

Set-up
For this task, you'll want a local copy of the MediaWiki database. You can download this SQL dump of the Northern Sotho Wikipedia (10 MB) and import it into a local MySQL instance, or you can install MediaWiki and populate it with your own data (or do both).

Task
Write a PHP program that takes the following input as query string parameters: Using these 4 parameters, your program should answer the question "In the category X, what were the X most-edited articles between the days X and X, and how many times were each of them edited during that period." Don't worry about subcategories.
 * The name of a MediaWiki category (for example 'Afrika_Borwa' if you're using the Northern Sotho Wikipedia data)
 * The number of articles to list
 * A start date in ISO 8601 format (for example '2011-07-31')
 * An end date in ISO 8601 format (for example '2013-10-17')
 * Desired output format: json, xml, or text

If the output format is 'text', the result should be output to the browser as a text table: Kgwele ya ntlatlana | 14 Lefasana           | 11 Roma ya kgale      | 10 Segwagwa           | 7 Lenano la mengwaga | 3

Hints: The revision table stores all the edits. The categorylinks table stores category membership. The page table stores the titles of articles. MediaWiki stores timestamps in the format yyyymmddhhmmss.

The code should be a stand-alone PHP program that accesses the MediaWiki database directly, not a MediaWiki extension or maintenance script. Do not use any frameworks or PEAR packages, only plain PHP.

Code checked into GitHub is ideal.