[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/diff/ -> UnifiedDiffFormatter.php (source)

   1  <?php
   2  /**
   3   * Portions taken from phpwiki-1.3.3.
   4   *
   5   * Copyright © 2000, 2001 Geoffrey T. Dairiki <[email protected]>
   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  
  33      /** @var int */
  34      protected $leadingContextLines = 2;
  35  
  36      /** @var int */
  37      protected $trailingContextLines = 2;
  38  
  39      /**
  40       * @param string[] $lines
  41       */
  42  	protected function added( $lines ) {
  43          $this->lines( $lines, '+' );
  44      }
  45  
  46      /**
  47       * @param string[] $lines
  48       */
  49  	protected function deleted( $lines ) {
  50          $this->lines( $lines, '-' );
  51      }
  52  
  53      /**
  54       * @param string[] $orig
  55       * @param string[] $closing
  56       */
  57  	protected function changed( $orig, $closing ) {
  58          $this->deleted( $orig );
  59          $this->added( $closing );
  60      }
  61  
  62      /**
  63       * @param int $xbeg
  64       * @param int $xlen
  65       * @param int $ybeg
  66       * @param int $ylen
  67       *
  68       * @return string
  69       */
  70  	protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
  71          return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
  72      }
  73  
  74  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1