This repository has been archived by the owner on Apr 5, 2019. It is now read-only.
forked from basisentscheid/basisentscheid
/
diff.php
71 lines (52 loc) · 1.71 KB
/
diff.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?
/**
* proposal draft differences
*
* @author Magnus Rosenbaum <dev@cmr.cx>
* @package Basisentscheid
*/
require "inc/common_http.php";
require "inc/libs/PHP-FineDiff/finediff.php";
$draft = new Draft(@$_GET['draft1']);
if (!$draft->id) {
error(_("The requested draft does not exist."));
}
$draft2 = new Draft(@$_GET['draft2']);
if (!$draft2->id) {
error(_("The requested draft does not exist."));
}
$proposal = new Proposal($draft->proposal);
$issue = $proposal->issue();
$_SESSION['ngroup'] = $issue->area()->ngroup;
list($supporters, $proponents, $is_supporter, $is_proponent) = $proposal->supporters();
if (!$is_proponent and !Login::$admin) {
error(_("You are not a proponent of this proposal!"));
}
html_head( sprintf(_("<a%s>Proposal %d</a>, version differences"), ' href="proposal.php?id='.$proposal->id.'"', $proposal->id) );
?>
<section class="proposal_info">
<? $proposal->display_proposal_info($issue, $proponents, $is_proponent); ?>
</section>
<section class="proposal_content diff">
<h2><?=_("Title")?></h2>
<p class="proposal proposal_title"><? diff($draft->title, $draft2->title)?></p>
<h2><?=_("Content")?></h2>
<p class="proposal"><? diff($draft->content, $draft2->content)?></p>
<h2><?=_("Reason")?></h2>
<p class="proposal"><? diff($draft->reason, $draft2->reason)?></p>
</section>
<div class="clearfix"></div>
<?
html_foot();
/**
* wrapper for PHP-FineDiff library
*
* @param string $from_text
* @param string $to_text
*/
function diff($from_text, $to_text) {
/** @noinspection PhpUndefinedClassInspection */
$opcodes = FineDiff::getDiffOpcodes($from_text, $to_text);
/** @noinspection PhpUndefinedClassInspection */
echo FineDiff::renderDiffToHTMLFromOpcodes($from_text, $opcodes);
}