b2evolution PHP Cross Reference Blogging Systems

Source: /inc/_ext/phpsvnclient/ext/Diff/Diff/Mapped.php - 58 lines - 2223 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * $Horde: framework/Text_Diff/Diff/Mapped.php,v 1.3.2.4 2009/01/06 15:23:41 jan Exp $
   4   *
   5   * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
   6   *
   7   * See the enclosed file COPYING for license information (LGPL). If you did
   8   * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
   9   *
  10   * @package Text_Diff
  11   * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
  12   */
  13  if( ! defined( 'EVO_MAIN_INIT' ) ) die( 'Please, do not access this page directly.' );
  14  
  15  class Text_Diff_Mapped extends Text_Diff {
  16  
  17      /**
  18       * Computes a diff between sequences of strings.
  19       *
  20       * This can be used to compute things like case-insensitve diffs, or diffs
  21       * which ignore changes in white-space.
  22       *
  23       * @param array $from_lines         An array of strings.
  24       * @param array $to_lines           An array of strings.
  25       * @param array $mapped_from_lines  This array should have the same size
  26       *                                  number of elements as $from_lines.  The
  27       *                                  elements in $mapped_from_lines and
  28       *                                  $mapped_to_lines are what is actually
  29       *                                  compared when computing the diff.
  30       * @param array $mapped_to_lines    This array should have the same number
  31       *                                  of elements as $to_lines.
  32       */
  33      function Text_Diff_Mapped($from_lines, $to_lines,
  34                                $mapped_from_lines, $mapped_to_lines)
  35      {
  36          assert(count($from_lines) == count($mapped_from_lines));
  37          assert(count($to_lines) == count($mapped_to_lines));
  38  
  39          parent::Text_Diff($mapped_from_lines, $mapped_to_lines);
  40  
  41          $xi = $yi = 0;
  42          for ($i = 0; $i < count($this->_edits); $i++) {
  43              $orig = &$this->_edits[$i]->orig;
  44              if (is_array($orig)) {
  45                  $orig = array_slice($from_lines, $xi, count($orig));
  46                  $xi += count($orig);
  47              }
  48  
  49              $final = &$this->_edits[$i]->final;
  50              if (is_array($final)) {
  51                  $final = array_slice($to_lines, $yi, count($final));
  52                  $yi += count($final);
  53              }
  54          }
  55      }
  56  
  57  }
  58  ?>

title

Description

title

Description

title

Description

title

title

Body