Custom Recent Changes

Situation
You have installed your own Mediawiki engine and you are hosting (have imported) more than one (former) Wikis on/into it, becoming a so called Wikihive or Wikifarm. So you have pages sorted like Somewiki/Fnord, Somewiki/Foobar and now the users of Somewiki are asking for their own Recent Changes page that only includes the pages of their (sub)-wiki, so a subset of your complete RC page that only shows pages beggining with the string "Somewiki" in this case. (Another approach would have been sorting out by categories,but this would have meant having to look inside page content instead of doing it inside a SELECT statement).

So i read Write your own MediaWiki extension and came up with this code:

Tag
Users can just insert a tag like  Whatever  into any wiki page and will include a Recent changes table of all pages beginning with "Whatever". Normally they would insert this into index.php/Subwiki/RecentChanges then.

Example
Compare S23Wiki:Debian/RecentChanges with its source.

Custom Recent Changes Extension
<?php
 * 1) Custom RC-page WikiMedia extension
 * 2) display custom recent changes pages for a subset of pages inside any wiki page
 * 3) insert Fnord into a wikipage and it will be replaced
 * 4) by a table containing stripped RecentChanges for all pages begging with "Fnord".
 * 5) This is made for making RC pages for "subwikis" on a "wikihive" where all pages
 * 6) below a /Subwiki page should be taken into account. like yourwiki/subwiki/RecentChanges.
 * 7) by mutante of s23 - 01.03.2005

$wgExtensionFunctions[] = "wfCustomRCExtension";

function wfCustomRCExtension { global $wgParser;

# register the extension with the WikiText parser # the first parameter is the name of the new tag. In this case it defines the tag ...     # the second parameter is the callback function for processing the text between the tags $wgParser->setHook( "customrc", "renderCustomRC" ); } function renderCustomRC( $input ) {
 * 1) The callback function for converting the input text to HTML output

$input = mysql_escape_string($input);
 * 1) strip possible evil characters from user

$hd = mysql_connect("localhost", "wikiuser", "password") or die ("Unable to connect");
 * 1) db connect (replace "password" of course)

mysql_select_db ("wikidb", $hd) or die ("Unable to select database");
 * 1) select db

$res = mysql_query("SELECT rc_id,rc_timestamp,rc_title,rc_comment,rc_user_text FROM recentchanges WHERE rc_title LIKE \"$input%\" ORDER by rc_timestamp desc", $hd) or die ("Unable to run query");
 * 1) mysql query

$output=<<

mutante 22:07, 1 Mar 2005 (UTC)