");
SDV($HandleDiffFmt, array(
&$PageStartFmt,
&$PageDiffFmt,"
", 'function:PrintDiffInline', '
',
&$PageEndFmt ));
SDV($HTMLStylesFmt['diffinline'], "
.diffmarkup del { background:#fcc; }
.diffmarkup ins { background:#cfc; }");
function PrintDiffInline($pagename) {
global $DiffShow,$DiffStartFmt,$TimeFmt,$DiffDelFmt,$DiffAddFmt,
$DiffEndDelAddFmt,$DiffEndFmt,$DiffRestoreFmt,$FmtV, $LinkFunctions, $FarmD;
$page = ReadPage($pagename);
if (!$page) return;
krsort($page); reset($page);
$lf = $LinkFunctions;
$LinkFunctions['http:'] = 'LinkSuppress';
$LinkFunctions['https:'] = 'LinkSuppress';
foreach($page as $k=>$v) {
if (!preg_match("/^diff:(\d+):(\d+):?([^:]*)/",$k,$match)) continue;
$diffclass = $match[3];
if ($diffclass=='minor' && $DiffShow['minor']!='y') continue;
$diffgmt = $match[1]; $FmtV['$DiffTime'] = strftime($TimeFmt,$diffgmt);
$diffauthor = @$page["author:$diffgmt"];
if (!$diffauthor) @$diffauthor=$page["host:$diffgmt"];
if (!$diffauthor) $diffauthor="unknown";
$FmtV['$DiffChangeSum'] = htmlspecialchars(@$page["csum:$diffgmt"]);
$FmtV['$DiffHost'] = @$page["host:$diffgmt"];
$FmtV['$DiffAuthor'] = $diffauthor;
$FmtV['$DiffId'] = $k;
echo FmtPageName($DiffStartFmt,$pagename);
$difflines = explode("\n",$v."\n");
$in=array(); $out=array(); $dtype='';
foreach($difflines as $d) {
if ($d>'') {
if ($d[0]=='-' || $d[0]=='\\') continue;
if ($d[0]=='<') { $out[]=substr($d,2); continue; }
if ($d[0]=='>') { $in[]=substr($d,2); continue; }
}
if (preg_match("/^(\\d+)(,(\\d+))?([adc])(\\d+)(,(\\d+))?/",
$dtype,$match)) {
if (@$match[7]>'') {
$lines='lines';
$count=$match[1].'-'.($match[1]+$match[7]-$match[5]);
} elseif ($match[3]>'') {
$lines='lines'; $count=$match[1].'-'.$match[3];
} else { $lines='line'; $count=$match[1]; }
$FmtV['$DiffLines'] = $count;
switch($match[4]) {
case 'a':
$txt = str_replace('line',$lines,$DiffDelFmt['a']);
echo FmtPageName($txt,$pagename),
"
",
str_replace("\n","
",htmlspecialchars(join("\n",$in))),
"
";
break;
case 'd':
$txt = str_replace('line',$lines,$DiffAddFmt['d']);
echo FmtPageName($txt,$pagename),
"
",
str_replace("\n","
",htmlspecialchars(join("\n",$out))),
"
";
break;
case 'c':
$txt = str_replace('line',$lines,$DiffAddFmt['c']);
echo FmtPageName($txt,$pagename);
include_once("$FarmD/cookbook/pagerevinline/Text/Diff.php");
include_once("$FarmD/cookbook/pagerevinline/Text/Diff/Renderer/inline.php");
$diff = &new Text_Diff($in, $out);
$renderer = &new Text_Diff_Renderer_inline();
echo "
",
str_replace("\n","
",$renderer->render($diff)),
"
";
break;
}
echo FmtPageName($DiffEndDelAddFmt,$pagename);
}
$in=array(); $out=array(); $dtype=$d;
}
echo FmtPageName($DiffEndFmt,$pagename);
echo FmtPageName($DiffRestoreFmt,$pagename);
}
$LinkFunctions = $lf;
}