Integrated C++ wikidiff engine. Enable by setting wgUseExternalDiffEngine to true.
authorJens Frank <jeluf@users.mediawiki.org>
Sun, 8 Aug 2004 02:20:00 +0000 (02:20 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sun, 8 Aug 2004 02:20:00 +0000 (02:20 +0000)
Needs wikidiff module from the extensions package and SWIG to compile.

includes/DefaultSettings.php
includes/DifferenceEngine.php

index d9d64eb..1faa21c 100644 (file)
@@ -473,6 +473,10 @@ $wgUseGeoMode = false;
 # Validation for print or other production versions
 $wgUseValidation = false;
 
+# Use external C++ diff engine (module wikidiff from the
+# extensions package)
+$wgUseExternalDiffEngine = false;
+
 } else {
        die();
 }
index 61aec22..8b80c27 100644 (file)
@@ -90,24 +90,29 @@ class DifferenceEngine {
 
        function showDiff( $otext, $ntext, $otitle, $ntitle )
        {
-               global $wgOut;
+               global $wgOut, $wgUseExternalDiffEngine;
+
+               $otext = str_replace( "\r\n", "\n", htmlspecialchars( $otext ) );
+               $ntext = str_replace( "\r\n", "\n", htmlspecialchars( $ntext ) );
 
-               $ota = explode( "\n", str_replace( "\r\n", "\n",
-                 htmlspecialchars( $otext ) ) );
-               $nta = explode( "\n", str_replace( "\r\n", "\n",
-                 htmlspecialchars( $ntext ) ) );
 
-               $wgOut->addHTML( "<table border='0' width='98%'
+                       $wgOut->addHTML( "<table border='0' width='98%'
 cellpadding='0' cellspacing='4px' class='diff'><tr>
 <td colspan='2' width='50%' align='center' class='diff-otitle'>
 {$otitle}</td>
 <td colspan='2' width='50%' align='center' class='diff-ntitle'>
 {$ntitle}</td>
 </tr>\n" );
-
-               $diffs = new Diff( $ota, $nta );
-               $formatter = new TableDiffFormatter();
-               $formatter->format( $diffs );
+               if ( $wgUseExternalDiffEngine ) {
+                       dl("php_wikidiff.so");
+                       $wgOut->addHTML( wikidiff_do_diff( $otext, $ntext, 2) );
+               } else {
+                       $ota = explode( "\n", $otext);
+                       $nta = explode( "\n", $ntext);
+                       $diffs = new Diff( $ota, $nta );
+                       $formatter = new TableDiffFormatter();
+                       $formatter->format( $diffs );
+               }
                $wgOut->addHTML( "</table>\n" );
        }