[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/inc/3rdparty/diff/Diff/Renderer/ -> Unified.php (source)

   1  <?php
   2  /**
   3   * "Unified" diff renderer.
   4   *
   5   * This class renders the diff in classic "unified diff" format.
   6   *
   7   * Copyright 2004-2017 Horde LLC (http://www.horde.org/)
   8   *
   9   * See the enclosed file COPYING for license information (LGPL). If you did
  10   * not receive this file, see http://www.horde.org/licenses/lgpl21.
  11   *
  12   * @author  Ciprian Popovici
  13   * @package Text_Diff
  14   */
  15  
  16  // Disallow direct access to this file for security reasons
  17  if(!defined("IN_MYBB"))
  18  {
  19      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  20  }
  21  
  22  class Horde_Text_Diff_Renderer_Unified extends Horde_Text_Diff_Renderer
  23  {
  24      /**
  25       * Number of leading context "lines" to preserve.
  26       */
  27      protected $_leading_context_lines = 4;
  28  
  29      /**
  30       * Number of trailing context "lines" to preserve.
  31       */
  32      protected $_trailing_context_lines = 4;
  33  
  34      protected function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
  35      {
  36          if ($xlen != 1) {
  37              $xbeg .= ',' . $xlen;
  38          }
  39          if ($ylen != 1) {
  40              $ybeg .= ',' . $ylen;
  41          }
  42          return "@@ -$xbeg +$ybeg @@";
  43      }
  44  
  45      protected function _context($lines)
  46      {
  47          return $this->_lines($lines, ' ');
  48      }
  49  
  50      protected function _added($lines)
  51      {
  52          return $this->_lines($lines, '+');
  53      }
  54  
  55      protected function _deleted($lines)
  56      {
  57          return $this->_lines($lines, '-');
  58      }
  59  
  60      protected function _changed($orig, $final)
  61      {
  62          return $this->_deleted($orig) . $this->_added($final);
  63      }
  64  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref