Merge "xml dump maintenance scripts should use the 'dump' db group"
[lhc/web/wiklou.git] / includes / diff / UnifiedDiffFormatter.php
1 <?php
2 /**
3 * Portions taken from phpwiki-1.3.3.
4 *
5 * Copyright © 2000, 2001 Geoffrey T. Dairiki <dairiki@dairiki.org>
6 * You may copy this code freely under the conditions of the GPL.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
22 *
23 * @file
24 * @ingroup DifferenceEngine
25 */
26
27 /**
28 * A formatter that outputs unified diffs
29 * @ingroup DifferenceEngine
30 */
31 class UnifiedDiffFormatter extends DiffFormatter {
32 protected $leadingContextLines = 2;
33 protected $trailingContextLines = 2;
34
35 /**
36 * @param $lines
37 */
38 protected function added( $lines ) {
39 $this->lines( $lines, '+' );
40 }
41
42 /**
43 * @param $lines
44 */
45 protected function deleted( $lines ) {
46 $this->lines( $lines, '-' );
47 }
48
49 /**
50 * @param $orig
51 * @param $closing
52 */
53 protected function changed( $orig, $closing ) {
54 $this->deleted( $orig );
55 $this->added( $closing );
56 }
57
58 /**
59 * @param $xbeg
60 * @param $xlen
61 * @param $ybeg
62 * @param $ylen
63 * @return string
64 */
65 protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
66 return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
67 }
68 }