home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Text / Diff / Renderer / unified.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  1.4 KB  |  68 lines

  1. <?php
  2. /**
  3.  * "Unified" diff renderer.
  4.  *
  5.  * This class renders the diff in classic "unified diff" format.
  6.  *
  7.  * $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.10 2008/01/04 10:07:51 jan Exp $
  8.  *
  9.  * Copyright 2004-2008 The Horde Project (http://www.horde.org/)
  10.  *
  11.  * See the enclosed file COPYING for license information (LGPL). If you did
  12.  * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
  13.  *
  14.  * @author  Ciprian Popovici
  15.  * @package Text_Diff
  16.  */
  17.  
  18. /** Text_Diff_Renderer */
  19. require_once 'Text/Diff/Renderer.php';
  20.  
  21. /**
  22.  * @package Text_Diff
  23.  */
  24. class Text_Diff_Renderer_unified extends Text_Diff_Renderer {
  25.  
  26.     /**
  27.      * Number of leading context "lines" to preserve.
  28.      */
  29.     var $_leading_context_lines = 4;
  30.  
  31.     /**
  32.      * Number of trailing context "lines" to preserve.
  33.      */
  34.     var $_trailing_context_lines = 4;
  35.  
  36.     function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
  37.     {
  38.         if ($xlen != 1) {
  39.             $xbeg .= ',' . $xlen;
  40.         }
  41.         if ($ylen != 1) {
  42.             $ybeg .= ',' . $ylen;
  43.         }
  44.         return "@@ -$xbeg +$ybeg @@";
  45.     }
  46.  
  47.     function _context($lines)
  48.     {
  49.         return $this->_lines($lines, ' ');
  50.     }
  51.  
  52.     function _added($lines)
  53.     {
  54.         return $this->_lines($lines, '+');
  55.     }
  56.  
  57.     function _deleted($lines)
  58.     {
  59.         return $this->_lines($lines, '-');
  60.     }
  61.  
  62.     function _changed($orig, $final)
  63.     {
  64.         return $this->_deleted($orig) . $this->_added($final);
  65.     }
  66.  
  67. }
  68.