예제 #1
0
파일: diff_inc.php 프로젝트: laiello/suitex
function do_diff($all, $ignoreWhitespace, $ent, $newtname, $oldtname)
{
    if (class_exists('Text_Diff')) {
        return inline_diff($all, $ignoreWhitespace, $ent, $newtname, $oldtname);
    } else {
        return command_diff($all, $ignoreWhitespace, $ent, $newtname, $oldtname);
    }
}
예제 #2
0
<?php

/*
	file: inline_example.php

	This file shows an example of the inline diff usage.

	The inline_diff code was written by Ciprian Popovici in 2004,
	as a hack building upon the Text_Diff PEAR package.
	It is released under the GPL.

	There are 3 files in this package: inline_example.php, inline_function.php, inline_renderer.php
*/
include_once 'inline_function.php';
$text1 = 'This product comes with NO WARRANTY. There are no refnds.';
$text2 = 'This product comes with a 3yr warranty. There are no refunds.';
//$text1 = file_get_contents('a.html');
//$text2 = file_get_contents('b.html');
$nl = '#**!)@#';
$diff = inline_diff($text1, $text2, $nl);
//	echo str_replace($nl,"\n",$diff)."\n";
echo '<style>del{background:#fcc}ins{background:#cfc}</style>' . $diff . "\n";
예제 #3
0
파일: diff.class.php 프로젝트: wwwzys/fis
 /**
  * 展示文件内容不同
  */
 public function DisplayDetails()
 {
     $smartyConfig = self::getConfig('smarty');
     $outputConfig = self::getConfig('output');
     $diffdatas = array();
     $this->proInfo['files'] = array();
     $this->getFiles($this->proInfo['oldoutputdir']);
     foreach ($this->proInfo['files'] as $path) {
         $old = $path;
         $new = str_replace($outputConfig['oldoutputdir'], $outputConfig['newoutputdir'], $old);
         if (filesize($old) != filesize($new) && !preg_match("/fis_version.txt\$/", $old)) {
             $this->smarty->assign('new', $new);
             $this->smarty->assign('old', $old);
             $newtext = file_get_contents($new);
             $oldtext = file_get_contents($old);
             $nl = '#**!)@#';
             $diffdata = inline_diff($oldtext, $newtext, $nl);
             array_push($diffdatas, $diffdata);
             //文件内容diff的结果展示
             $this->smarty->assign('diffdata', mb_convert_encoding($diffdata, 'utf-8', 'gbk'));
             $html = $this->smarty->fetch($smartyConfig['templatedir'] . "diffdetails.tpl");
             $htmlpath = $smartyConfig['templatedir'] . $this->proInfo['name'] . "_" . str_replace("/", "_", substr($old, strrpos($old, $outputConfig['oldoutputdir']) + 13)) . ".html";
             $fileurl = self::getConfig('url') . str_replace("/home/work/repos/", "", $htmlpath);
             $diff = array('url' => $fileurl, 'name' => str_replace("/", "_", substr($old, strrpos($old, $outputConfig['oldoutputdir']) + 13)), 'old' => substr($old, strrpos($old, $outputConfig['oldoutputdir']) + 13), 'new' => substr($old, strrpos($new, $outputConfig['newoutputdir']) + 13));
             array_push($this->Diff, $diff);
             File::write($htmlpath, $html);
         }
     }
     //		$this->generateReport($diffdatas);
 }
function wiki_hist_newdiff(&$WS)
{
    global $CFG;
    require_once $CFG->dirroot . '/mod/wiki/inline-diff/inline_function.php';
    //this point only effects on html editor mode.
    if ($WS->dfwiki->editor == 'htmleditor') {
        $current_text = wiki_hist_convert_paragrafs($WS->pageverdata->content);
        $old_text = wiki_hist_convert_paragrafs($WS->pageolddata->content);
    } else {
        $current_text = $WS->pageverdata->content;
        $old_text = $WS->pageolddata->content;
    }
    //print version list
    wiki_hist_diff_print_versions("newdiff");
    //$diff= inline_diff($current_text,$old_text,$nl);
    $diff = inline_diff($current_text, $old_text);
    wiki_hist_restore($WS);
}