aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/wiki/WikiDiffLine.php
blob: ca0b9f793c9dea3b4c582b69b77f5d7e95a09690 (plain)
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
<?php

/////////////////////////////////////////////////
// DIFF functions adapted from:
// PukiWiki - Yet another WikiWikiWeb clone.
// http://www.pukiwiki.org (GPL'd)
/*
WikiDiffer

S. Wu, <a href="http://www.cs.arizona.edu/people/gene/vita.html">
E. Myers,</a> U. Manber, and W. Miller,
<a href="http://www.cs.arizona.edu/people/gene/PAPERS/np_diff.ps">
"An O(NP) Sequence Comparison Algorithm,"</a>
Information Processing Letters 35, 6 (1990), 317-323.
*/
class WikiDiffLine
{
    var $text;
    var $status;
    var $who; // who originally wrote this line?

    function __construct($text, $who = null)
    {
        $this->text = "$text\n";
        $this->who = $who;
        $this->status = [];
    }
    function compare($obj)
    {
        return $this->text == $obj->text;
    }
    function set($key,$status)
    {
        $this->status[$key] = $status;
    }
    function get($key)
    {
        return array_key_exists($key,$this->status) ? $this->status[$key] : '';
    }
    function merge($obj)
    {
        $this->status += $obj->status;
    }
    function text()
    {
        return $this->text;
    }
}