本文整理汇总了PHP中wikidiff2_do_diff函数的典型用法代码示例。如果您正苦于以下问题:PHP wikidiff2_do_diff函数的具体用法?PHP wikidiff2_do_diff怎么用?PHP wikidiff2_do_diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wikidiff2_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: 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
示例3: textDiff
/**
* Generates diff, to be wrapped internally in a logging/instrumentation
*
* @param string $otext Old text, must be already segmented
* @param string $ntext New text, must be already segmented
* @return bool|string
*/
protected function textDiff($otext, $ntext)
{
global $wgExternalDiffEngine, $wgContLang;
$otext = str_replace("\r\n", "\n", $otext);
$ntext = str_replace("\r\n", "\n", $ntext);
if ($wgExternalDiffEngine == 'wikidiff' || $wgExternalDiffEngine == 'wikidiff3') {
wfDeprecated("\$wgExternalDiffEngine = '{$wgExternalDiffEngine}'", '1.27');
$wgExternalDiffEngine = false;
}
if ($wgExternalDiffEngine == 'wikidiff2') {
if (function_exists('wikidiff2_do_diff')) {
# Better external diff engine, the 2 may some day be dropped
# This one does the escaping and segmenting itself
$text = wikidiff2_do_diff($otext, $ntext, 2);
$text .= $this->debug('wikidiff2');
return $text;
}
} elseif ($wgExternalDiffEngine !== false) {
# Diff via the shell
$tmpDir = wfTempDir();
$tempName1 = tempnam($tmpDir, 'diff_');
$tempName2 = tempnam($tmpDir, 'diff_');
$tempFile1 = fopen($tempName1, "w");
if (!$tempFile1) {
return false;
}
$tempFile2 = fopen($tempName2, "w");
if (!$tempFile2) {
return false;
}
fwrite($tempFile1, $otext);
fwrite($tempFile2, $ntext);
fclose($tempFile1);
fclose($tempFile2);
$cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
$difftext = wfShellExec($cmd);
$difftext .= $this->debug("external {$wgExternalDiffEngine}");
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();
$difftext = $wgContLang->unsegmentForDiff($formatter->format($diffs));
return $difftext;
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:56,代码来源:DifferenceEngine.php
示例4: textDiff
/**
* Generates diff, to be wrapped internally in a logging/instrumentation
*
* @param string $otext Old text, must be already segmented
* @param string $ntext New text, must be already segmented
* @return bool|string
*/
protected function textDiff($otext, $ntext)
{
global $wgExternalDiffEngine, $wgContLang;
$otext = str_replace("\r\n", "\n", $otext);
$ntext = str_replace("\r\n", "\n", $ntext);
if ($wgExternalDiffEngine == 'wikidiff' || $wgExternalDiffEngine == 'wikidiff3') {
wfDeprecated("\$wgExternalDiffEngine = '{$wgExternalDiffEngine}'", '1.27');
$wgExternalDiffEngine = false;
} elseif ($wgExternalDiffEngine == 'wikidiff2') {
// Same as above, but with no deprecation warnings
$wgExternalDiffEngine = false;
} elseif (!is_string($wgExternalDiffEngine) && $wgExternalDiffEngine !== false) {
// And prevent people from shooting themselves in the foot...
wfWarn('$wgExternalDiffEngine is set to a non-string value, forcing it to false');
$wgExternalDiffEngine = false;
}
if (function_exists('wikidiff2_do_diff') && $wgExternalDiffEngine === false) {
# Better external diff engine, the 2 may some day be dropped
# This one does the escaping and segmenting itself
$text = wikidiff2_do_diff($otext, $ntext, 2);
$text .= $this->debug('wikidiff2');
return $text;
} elseif ($wgExternalDiffEngine !== false && is_executable($wgExternalDiffEngine)) {
# Diff via the shell
$tmpDir = wfTempDir();
$tempName1 = tempnam($tmpDir, 'diff_');
$tempName2 = tempnam($tmpDir, 'diff_');
$tempFile1 = fopen($tempName1, "w");
if (!$tempFile1) {
return false;
}
$tempFile2 = fopen($tempName2, "w");
if (!$tempFile2) {
return false;
}
fwrite($tempFile1, $otext);
fwrite($tempFile2, $ntext);
fclose($tempFile1);
fclose($tempFile2);
$cmd = wfEscapeShellArg($wgExternalDiffEngine, $tempName1, $tempName2);
$difftext = wfShellExec($cmd);
$difftext .= $this->debug("external {$wgExternalDiffEngine}");
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();
$difftext = $wgContLang->unsegmentForDiff($formatter->format($diffs));
return $difftext;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:61,代码来源:DifferenceEngine.php
示例5: wikidiff2_do_diff
<?php
print wikidiff2_do_diff($x, $y, 2);
print wikidiff3_do_diff($x, $y, 3);
开发者ID:exakat,项目名称:exakat,代码行数:4,代码来源:Extwikidiff2.01.php
注:本文中的wikidiff2_do_diff函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论