當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wikidiff_do_diff函數代碼示例

本文整理匯總了PHP中wikidiff_do_diff函數的典型用法代碼示例。如果您正苦於以下問題:PHP wikidiff_do_diff函數的具體用法?PHP wikidiff_do_diff怎麽用?PHP wikidiff_do_diff使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wikidiff_do_diff函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generateDiffBody

 /**
  * Generate a diff, no caching
  *
  * @param $otext String: old text, must be already segmented
  * @param $ntext String: new text, must be already segmented
  */
 function generateDiffBody($otext, $ntext)
 {
     global $wgExternalDiffEngine, $wgContLang;
     wfProfileIn(__METHOD__);
     $otext = str_replace("\r\n", "\n", $otext);
     $ntext = str_replace("\r\n", "\n", $ntext);
     $this->initDiffEngines();
     if ($wgExternalDiffEngine == 'wikidiff' && function_exists('wikidiff_do_diff')) {
         # For historical reasons, external diff engine expects
         # input text to be HTML-escaped already
         $otext = htmlspecialchars($wgContLang->segmentForDiff($otext));
         $ntext = htmlspecialchars($wgContLang->segmentForDiff($ntext));
         wfProfileOut(__METHOD__);
         return $wgContLang->unsegmentForDiff(wikidiff_do_diff($otext, $ntext, 2)) . $this->debug('wikidiff1');
     }
     if ($wgExternalDiffEngine == 'wikidiff2' && function_exists('wikidiff2_do_diff')) {
         # Better external diff engine, the 2 may some day be dropped
         # This one does the escaping and segmenting itself
         wfProfileIn('wikidiff2_do_diff');
         $text = wikidiff2_do_diff($otext, $ntext, 2);
         $text .= $this->debug('wikidiff2');
         wfProfileOut('wikidiff2_do_diff');
         wfProfileOut(__METHOD__);
         return $text;
     }
     if ($wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false) {
         # Diff via the shell
         global $wgTmpDirectory;
         $tempName1 = tempnam($wgTmpDirectory, 'diff_');
         $tempName2 = tempnam($wgTmpDirectory, 'diff_');
         $tempFile1 = fopen($tempName1, "w");
         if (!$tempFile1) {
             wfProfileOut(__METHOD__);
             return false;
         }
         $tempFile2 = fopen($tempName2, "w");
         if (!$tempFile2) {
             wfProfileOut(__METHOD__);
             return false;
         }
         fwrite($tempFile1, $otext);
         fwrite($tempFile2, $ntext);
         fclose($tempFile1);
         fclose($tempFile2);
         $cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
         wfProfileIn(__METHOD__ . "-shellexec");
         $difftext = wfShellExec($cmd);
         $difftext .= $this->debug("external {$wgExternalDiffEngine}");
         wfProfileOut(__METHOD__ . "-shellexec");
         unlink($tempName1);
         unlink($tempName2);
         wfProfileOut(__METHOD__);
         return $difftext;
     }
     # Native PHP diff
     $ota = explode("\n", $wgContLang->segmentForDiff($otext));
     $nta = explode("\n", $wgContLang->segmentForDiff($ntext));
     $diffs = new Diff($ota, $nta);
     $formatter = new TableDiffFormatter();
     $difftext = $wgContLang->unsegmentForDiff($formatter->format($diffs)) . wfProfileOut(__METHOD__);
     return $difftext;
 }
開發者ID:eFFemeer,項目名稱:seizamcore,代碼行數:68,代碼來源:DifferenceEngine.php

示例2: dl

";

dl( 'php_wikidiff.so' );

function randomString( $length, $nullOk = false, $ascii = false ) {
	$out = '';
	for( $i = 0; $i < $length; $i++ )
		$out .= chr( mt_rand( $nullOk ? 0 : 1, $ascii ? 127 : 255 ) );
	return $out;
}

$size = 100000;
$maxruns = 1000;
$membase = memory_get_usage();
for( $i = 0; $i <= $maxruns; $i++ ) {
	$x = memory_get_usage() - $membase;
	printf( "%5d: up %d bytes\n", $i, $x );
	
	$a = randomString( $size );
	$b = randomString( $size );
	$c = wikidiff_do_diff( $a, $b, 1 );
	
	$a = '';
	$b = '';
	$c = '';
}

echo "(" . (memory_get_usage() - $membase) . " used)\n";

開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:28,代碼來源:memleak.php

示例3: generateDiffBody

 /**
  * Generate a diff, no caching
  * $otext and $ntext must be already segmented
  */
 function generateDiffBody($otext, $ntext)
 {
     global $wgExternalDiffEngine, $wgContLang;
     $fname = 'DifferenceEngine::generateDiffBody';
     $otext = str_replace("\r\n", "\n", $otext);
     $ntext = str_replace("\r\n", "\n", $ntext);
     if ($wgExternalDiffEngine == 'wikidiff') {
         # For historical reasons, external diff engine expects
         # input text to be HTML-escaped already
         $otext = htmlspecialchars($wgContLang->segmentForDiff($otext));
         $ntext = htmlspecialchars($wgContLang->segmentForDiff($ntext));
         if (!function_exists('wikidiff_do_diff')) {
             dl('php_wikidiff.so');
         }
         return $wgContLang->unsegementForDiff(wikidiff_do_diff($otext, $ntext, 2));
     }
     if ($wgExternalDiffEngine == 'wikidiff2') {
         # Better external diff engine, the 2 may some day be dropped
         # This one does the escaping and segmenting itself
         if (!function_exists('wikidiff2_do_diff')) {
             wfProfileIn("{$fname}-dl");
             @dl('php_wikidiff2.so');
             wfProfileOut("{$fname}-dl");
         }
         if (function_exists('wikidiff2_do_diff')) {
             wfProfileIn('wikidiff2_do_diff');
             $text = wikidiff2_do_diff($otext, $ntext, 2);
             wfProfileOut('wikidiff2_do_diff');
             return $text;
         }
     }
     if ($wgExternalDiffEngine !== false) {
         # Diff via the shell
         global $wgTmpDirectory;
         $tempName1 = tempnam($wgTmpDirectory, 'diff_');
         $tempName2 = tempnam($wgTmpDirectory, 'diff_');
         $tempFile1 = fopen($tempName1, "w");
         if (!$tempFile1) {
             wfProfileOut($fname);
             return false;
         }
         $tempFile2 = fopen($tempName2, "w");
         if (!$tempFile2) {
             wfProfileOut($fname);
             return false;
         }
         fwrite($tempFile1, $otext);
         fwrite($tempFile2, $ntext);
         fclose($tempFile1);
         fclose($tempFile2);
         $cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
         wfProfileIn("{$fname}-shellexec");
         $difftext = wfShellExec($cmd);
         wfProfileOut("{$fname}-shellexec");
         unlink($tempName1);
         unlink($tempName2);
         return $difftext;
     }
     # Native PHP diff
     $ota = explode("\n", $wgContLang->segmentForDiff($otext));
     $nta = explode("\n", $wgContLang->segmentForDiff($ntext));
     $diffs =& new Diff($ota, $nta);
     $formatter =& new TableDiffFormatter();
     return $wgContLang->unsegmentForDiff($formatter->format($diffs));
 }
開發者ID:k-hasan-19,項目名稱:wiki,代碼行數:69,代碼來源:DifferenceEngine.php

示例4: dl

<?php

dl("php_wikidiff.so");
$f1 = implode("\n", file("t1.txt"));
$f2 = implode("\n", file("t2.txt"));

# performance test
for ($i = 0; $i < 100; ++$i) {
	$v = wikidiff_do_diff($f1, $f2, 2);
}

開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:10,代碼來源:test.php

示例5: getDiff

 function getDiff($otext, $ntext, $otitle, $ntitle)
 {
     global $wgUseExternalDiffEngine, $wgContLang;
     $out = "\n\t\t\t<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' width='50%' align='center' class='diff-otitle'>{$otitle}</td>\n\t\t\t\t<td colspan='2' width='50%' align='center' class='diff-ntitle'>{$ntitle}</td>\n\t\t\t</tr>\n\t\t";
     $otext = $wgContLang->segmentForDiff($otext);
     $ntext = $wgContLang->segmentForDiff($ntext);
     $difftext = '';
     if ($wgUseExternalDiffEngine) {
         # For historical reasons, external diff engine expects
         # input text to be HTML-escaped already
         $otext = str_replace("\r\n", "\n", htmlspecialchars($otext));
         $ntext = str_replace("\r\n", "\n", htmlspecialchars($ntext));
         if (!function_exists('wikidiff_do_diff')) {
             dl('php_wikidiff.so');
         }
         $difftext = wikidiff_do_diff($otext, $ntext, 2);
     } else {
         $ota = explode("\n", str_replace("\r\n", "\n", $otext));
         $nta = explode("\n", str_replace("\r\n", "\n", $ntext));
         $diffs =& new Diff($ota, $nta);
         $formatter =& new TableDiffFormatter();
         $difftext = $formatter->format($diffs);
     }
     $difftext = $wgContLang->unsegmentForDiff($difftext);
     $out .= $difftext . "</table>\n";
     return $out;
 }
開發者ID:BackupTheBerlios,項目名稱:blahtex,代碼行數:27,代碼來源:DifferenceEngine.php


注:本文中的wikidiff_do_diff函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。