[ Index ]

PHP Cross Reference of MyBB 1.8.30

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Copyright 2007-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file COPYING for license information (LGPL). If you did
   6   * not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @author   Geoffrey T. Dairiki <dairiki@dairiki.org>
   9   * @category Horde
  10   * @license  http://www.horde.org/licenses/lgpl21 LGPL-2.1
  11   * @package  Text_Diff
  12   */
  13  
  14  /**
  15   * This can be used to compute things like case-insensitve diffs, or diffs
  16   * which ignore changes in white-space.
  17   *
  18   * @author    Geoffrey T. Dairiki <dairiki@dairiki.org>
  19   * @category  Horde
  20   * @copyright 2007-2017 Horde LLC
  21   * @license   http://www.horde.org/licenses/lgpl21 LGPL-2.1
  22   * @package   Text_Diff
  23   */
  24  
  25  // Disallow direct access to this file for security reasons
  26  if(!defined("IN_MYBB"))
  27  {
  28      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  29  }
  30  
  31  class Horde_Text_Diff_Mapped extends Horde_Text_Diff
  32  {
  33      /**
  34       * Computes a diff between sequences of strings.
  35       *
  36       * @param string $engine  Name of the diffing engine to use.  'auto' will
  37       *                        automatically select the best.
  38       * @param array $params   Parameters to pass to the diffing engine:
  39       *                        - Two arrays, each containing the lines from a
  40       *                          file.
  41       *                        - Two arrays with the same size as the first
  42       *                          parameters. The elements are what is actually
  43       *                          compared when computing the diff.
  44       */
  45      public function __construct($engine, $params)
  46      {
  47          list($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) = $params;
  48          assert(count($from_lines) == count($mapped_from_lines));
  49          assert(count($to_lines) == count($mapped_to_lines));
  50  
  51          parent::__construct($engine, array($mapped_from_lines, $mapped_to_lines));
  52  
  53          $xi = $yi = 0;
  54          for ($i = 0; $i < count($this->_edits); $i++) {
  55              $orig = &$this->_edits[$i]->orig;
  56              if (is_array($orig)) {
  57                  $orig = array_slice($from_lines, $xi, count($orig));
  58                  $xi += count($orig);
  59              }
  60  
  61              $final = &$this->_edits[$i]->final;
  62              if (is_array($final)) {
  63                  $final = array_slice($to_lines, $yi, count($final));
  64                  $yi += count($final);
  65              }
  66          }
  67      }
  68  }


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