• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wikidiff_do_diff函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wikify_links函数代码示例发布时间:2022-05-23
下一篇:
PHP wikidiff2_do_diff函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap