|
|
| (38 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| − | <?
| + | {{legacy}} |
| − | # TransformChanges {{#Security:*|dev}}{{#Security:view|*}}{{php}}
| + | {{svn|extensions|TransformChanges/TransformChanges.php}} |
| − | # - See http://www.mediawiki.org/Extension:TransformChanges for installation and usage details
| + | [[Category:Extensions]] |
| − | # - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
| |
| − | | |
| − | $wgHooks['SpecialPageExecuteAfterPage'][] = 'wfTransformChanges';
| |
| − | function wfTransformChanges() {
| |
| − | $title = $GLOBALS['wgTitle']->getDBkey();
| |
| − | if ($title != 'Recentchanges' && $title != 'Watchlist') return true;
| |
| − | $text =& $GLOBALS['wgOut']->mBodytext;
| |
| − | $text = preg_replace('|(</ul>\\s*)?<h4>(.+?)</h4>\\s*(<ul class="special">)<li>|s','$3<li $2>',$text);
| |
| − | $text = preg_replace_callback('|<ul class="special">(.+?)</ul>|s','wfTransformChangesUL',$text);
| |
| − | return true;
| |
| − | }
| |
| − | | |
| − | function wfTransformChangesUL($match) {
| |
| − | global $wgTransformChangesRow;
| |
| − | $wgTransformChangesRow = 0;
| |
| − | $rows = preg_replace_callback('|<li\\s*(.*?)>(.+?)</li>|s','wfTransformChangesLI',$match[1]);
| |
| − | return "<table class=\"changes\">$rows</table>";
| |
| − | }
| |
| − | | |
| − | 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 = '<td colspan="$ncols"><font color="red"><b>Error: match failed!</b></font></td>';
| |
| − | if ($date) {
| |
| − | $row = "<tr><td class=\"heading\" colspan=\"$ncols\">$date</td></tr>\n";
| |
| − | $wgTransformChangesRow = 1;
| |
| − | }
| |
| − | $row .= "<tr class=\"bg$wgTransformChangesRow\">";
| |
| − | if (preg_match('|^(.+?); (\\d+:\\d+)(.+?)(<a.+?\\))\\s*(.*?)$|',$text,$m)) {
| |
| − | list(,$diff,$time,$bytes,$user,$comment) = $m;
| |
| − | if (preg_match('|^(.+\\)).*?\\. \\.\\s*(.*?)\\s*(<a.+)$|',$diff,$m)) list(,$diff,$info,$title) = $m; else $info = $title = '';
| |
| − | if (preg_match('|(\\(.+?\\))|',$bytes,$m)) $info .= "<small>$m[1]</small>";
| |
| − | if (preg_match('|(<a.+?</a>).+?(\\(.+?\\))|',$user,$m)) list(,$user,$talk) = $m;
| |
| − | if (preg_match('|\\((.+)\\)|',$comment,$m)) $comment = $m[1];
| |
| − | foreach ($cols as $col) $row .= "<td class=\"$col\">{$$col}</td>";
| |
| − | } else $row = $error;
| |
| − | $row .= "</tr>\n";
| |
| − | return $row;
| |
| − | }
| |
| − | ?>
| |