Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
448 ddelon 1
<div class="page">
2
<?php
3
 
4
/* NOTE: This is a really cheap way to do it. I think it may be more intelligent to write the two
5
	 pages to temporary files and run /usr/bin/diff over them. Then again, maybe not.           */
6
 
7
// load pages
8
$pageA = $this->LoadPageById($_REQUEST["a"]);
9
$pageB = $this->LoadPageById($_REQUEST["b"]);
10
 
11
// prepare bodies
12
$bodyA = explode("\n", $pageA["body"]);
13
$bodyB = explode("\n", $pageB["body"]);
14
 
15
$added = array_diff($bodyA, $bodyB);
16
$deleted = array_diff($bodyB, $bodyA);
17
 
18
$output .= "<b>Comparing <a href=\"".$this->href("", "", "time=".urlencode($pageA["time"]))."\">".$pageA["time"]."</a> to <a href=\"".$this->href("", "", "time=".urlencode($pageB["time"]))."\">".$pageB["time"]."</a></b><br />\n";
19
 
20
if ($added)
21
{
22
	// remove blank lines
23
	$output .= "<br />\n<b>Additions:</b><br />\n";
24
	$output .= "<div class=\"additions\">".$this->Format(implode("\n", $added))."</div>";
25
}
26
 
27
if ($deleted)
28
{
29
	$output .= "<br />\n<b>Deletions:</b><br />\n";
30
	$output .= "<div class=\"deletions\">".$this->Format(implode("\n", $deleted))."</div>";
31
}
32
 
33
if (!$added && !$deleted)
34
{
35
	$output .= "<br />\nNo differences.";
36
}
37
print($output);
38
?>
39
</div>