Difference between revisions of "Extension:TransformChanges.php"

From Organic Design wiki
(New page: <? # TransformChanges {{#Security:*|dev}}{{#Security:view|*}}{{php}} # - See http://www.mediawiki.org/Extension:TransformChanges for installation and usage details # - Licenced under LGPL ...)
 
(No difference)

Revision as of 02:20, 24 April 2007

<?

  1. TransformChanges {{#Security:*|dev}}{{#Security:view|*}}Template:Php
  2. - See http://www.mediawiki.org/Extension:TransformChanges for installation and usage details
  3. - 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('|(\\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('|<li\\s*(.*?)>(.+?)
  • |s','wfTransformChangesLI',$match[1]); return "$rows
    ";

    }

    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+)(.+?)(<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 .= "$m[1]"; if (preg_match('|(<a.+?</a>).+?(\\(.+?\\))|',$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; } ?>