Merge "mediawiki.ui: Ensure that buttons and inputs are vertically aligned"
[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 /** @var int */
33 protected $leadingContextLines = 2;
34
35 /** @var int */
36 protected $trailingContextLines = 2;
37
38 /**
39 * @param $lines
40 */
41 protected function added( $lines ) {
42 $this->lines( $lines, '+' );
43 }
44
45 /**
46 * @param $lines
47 */
48 protected function deleted( $lines ) {
49 $this->lines( $lines, '-' );
50 }
51
52 /**
53 * @param $orig
54 * @param $closing
55 */
56 protected function changed( $orig, $closing ) {
57 $this->deleted( $orig );
58 $this->added( $closing );
59 }
60
61 /**
62 * @param $xbeg
63 * @param $xlen
64 * @param $ybeg
65 * @param $ylen
66 * @return string
67 */
68 protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
69 return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
70 }
71 }