Extension:TransformChanges

I've found the format of the recent changes and watchlists to be difficult to read and generally unpleasent looking, so I've made a quick extension to reformat them from a bullet list into a table. It also adds CSS classes to the table, rows and columns for easy customisation of styles.

Installation
Save the code below into a file and include in your LocalSettings.php file, or just insert the code directly if you prefer. <? $wgHooks['SpecialPageExecuteAfterPage'][] = 'wfTransformChanges'; function wfTransformChanges { $title = $GLOBALS['wgTitle']->getDBkey; if ($title != 'Recentchanges' && $title != 'Watchlist') return true; $text =& $GLOBALS['wgOut']->mBodytext; $text = preg_replace('|(\\s*)? (.+?) \\s*|s','$3',$text); $text = preg_replace_callback('| (.+?)|s','wfTransformChangesUL',$text); return true; }

function wfTransformChangesUL($match) { global $wgTransformChangesRow; $wgTransformChangesRow = 0; $rows = preg_replace_callback('|(.+?)|s','wfTransformChangesLI',$match[1]); return " "; }

function wfTransformChangesLI($match) { global $wgTransformChangesRow; $wgTransformChangesRow = ++$wgTransformChangesRow%2; list(,$date,$text) = $match; $cols = array('time','title','comment','user','talk','diff','info'); $ncols = count($cols); $row = ''; $error = ' Error: match failed! '; if ($date) { $row = " $date \n"; $wgTransformChangesRow = 1; }	$row .= ""; if (preg_match('|^(.+?); (\\d+:\\d+)(.+?)().+?(\\(.+?\\))|',$user,$m)) list(,$user,$talk) = $m; if (preg_match('|\\((.+)\\)|',$comment,$m)) $comment = $m[1]; foreach ($cols as $col) $row .= "{$$col} "; } else $row = $error; $row .= " \n"; return $row; } ?>

CSS Styles
To make it render properly some CSS styles should be added to your stylesheet, for example here's the styles that we've added on the Organic Design recent changes. table.changes           { border:none; width:100%; } table.changes tr        { margin:0; padding:0; } table.changes tr.bg0    { background:white; } table.changes tr.bg1    { background:#eee; } table.changes td        { margin:0; padding: 1px 4px 0 4px; vertical-align: top; } table.changes td.heading { font-size: 110%; font-weight:bold; padding-top:10px; } table.changes td.comment { width:100%; }

table.changes td.talk, table.changes td.diff   { font-size: 90%; }

table.changes td.user, table.changes td.talk, table.changes td.diff, table.changes td.info   { white-space: nowrap; }