Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: Diff.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Diff
[2] Fix | Delete
*
[3] Fix | Delete
* A comprehensive library for generating differences between two strings
[4] Fix | Delete
* in multiple formats (unified, side by side HTML etc)
[5] Fix | Delete
*
[6] Fix | Delete
* PHP version 5
[7] Fix | Delete
*
[8] Fix | Delete
* Copyright (c) 2009 Chris Boulton <chris.boulton@interspire.com>
[9] Fix | Delete
*
[10] Fix | Delete
* All rights reserved.
[11] Fix | Delete
*
[12] Fix | Delete
* Redistribution and use in source and binary forms, with or without
[13] Fix | Delete
* modification, are permitted provided that the following conditions are met:
[14] Fix | Delete
*
[15] Fix | Delete
* - Redistributions of source code must retain the above copyright notice,
[16] Fix | Delete
* this list of conditions and the following disclaimer.
[17] Fix | Delete
* - Redistributions in binary form must reproduce the above copyright notice,
[18] Fix | Delete
* this list of conditions and the following disclaimer in the documentation
[19] Fix | Delete
* and/or other materials provided with the distribution.
[20] Fix | Delete
* - Neither the name of the Chris Boulton nor the names of its contributors
[21] Fix | Delete
* may be used to endorse or promote products derived from this software
[22] Fix | Delete
* without specific prior written permission.
[23] Fix | Delete
*
[24] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
[25] Fix | Delete
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
[26] Fix | Delete
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
[27] Fix | Delete
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
[28] Fix | Delete
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
[29] Fix | Delete
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
[30] Fix | Delete
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
[31] Fix | Delete
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
[32] Fix | Delete
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
[33] Fix | Delete
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
[34] Fix | Delete
* POSSIBILITY OF SUCH DAMAGE.
[35] Fix | Delete
*
[36] Fix | Delete
* @package Diff
[37] Fix | Delete
* @author Chris Boulton <chris.boulton@interspire.com>
[38] Fix | Delete
* @copyright (c) 2009 Chris Boulton
[39] Fix | Delete
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
[40] Fix | Delete
* @version 1.1
[41] Fix | Delete
* @link http://github.com/chrisboulton/php-diff
[42] Fix | Delete
*/
[43] Fix | Delete
[44] Fix | Delete
class Diff
[45] Fix | Delete
{
[46] Fix | Delete
/**
[47] Fix | Delete
* @var array The "old" sequence to use as the basis for the comparison.
[48] Fix | Delete
*/
[49] Fix | Delete
private $a = null;
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* @var array The "new" sequence to generate the changes for.
[53] Fix | Delete
*/
[54] Fix | Delete
private $b = null;
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* @var array Array containing the generated opcodes for the differences between the two items.
[58] Fix | Delete
*/
[59] Fix | Delete
private $groupedCodes = null;
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* @var array Associative array of the default options available for the diff class and their default value.
[63] Fix | Delete
*/
[64] Fix | Delete
private $defaultOptions = array(
[65] Fix | Delete
'context' => 3,
[66] Fix | Delete
'ignoreNewLines' => false,
[67] Fix | Delete
'ignoreWhitespace' => false,
[68] Fix | Delete
'ignoreCase' => false
[69] Fix | Delete
);
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* @var array Array of the options that have been applied for generating the diff.
[73] Fix | Delete
*/
[74] Fix | Delete
private $options = array();
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* The constructor.
[78] Fix | Delete
*
[79] Fix | Delete
* @param array $a Array containing the lines of the first string to compare.
[80] Fix | Delete
* @param array $b Array containing the lines for the second string to compare.
[81] Fix | Delete
*/
[82] Fix | Delete
public function __construct($a, $b, $options=array())
[83] Fix | Delete
{
[84] Fix | Delete
$this->a = $a;
[85] Fix | Delete
$this->b = $b;
[86] Fix | Delete
[87] Fix | Delete
$this->options = array_merge($this->defaultOptions, $options);
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Render a diff using the supplied rendering class and return it.
[92] Fix | Delete
*
[93] Fix | Delete
* @param object $renderer An instance of the rendering object to use for generating the diff.
[94] Fix | Delete
* @return mixed The generated diff. Exact return value depends on the rendered.
[95] Fix | Delete
*/
[96] Fix | Delete
public function render(Diff_Renderer_Abstract $renderer)
[97] Fix | Delete
{
[98] Fix | Delete
$renderer->diff = $this;
[99] Fix | Delete
return $renderer->render();
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Get a range of lines from $start to $end from the first comparison string
[104] Fix | Delete
* and return them as an array. If no values are supplied, the entire string
[105] Fix | Delete
* is returned. It's also possible to specify just one line to return only
[106] Fix | Delete
* that line.
[107] Fix | Delete
*
[108] Fix | Delete
* @param int $start The starting number.
[109] Fix | Delete
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
[110] Fix | Delete
* @return array Array of all of the lines between the specified range.
[111] Fix | Delete
*/
[112] Fix | Delete
public function getA($start=0, $end=null)
[113] Fix | Delete
{
[114] Fix | Delete
if($start == 0 && $end === null) {
[115] Fix | Delete
return $this->a;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
if($end === null) {
[119] Fix | Delete
$length = 1;
[120] Fix | Delete
}
[121] Fix | Delete
else {
[122] Fix | Delete
$length = $end - $start;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
return array_slice($this->a, $start, $length);
[126] Fix | Delete
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Get a range of lines from $start to $end from the second comparison string
[131] Fix | Delete
* and return them as an array. If no values are supplied, the entire string
[132] Fix | Delete
* is returned. It's also possible to specify just one line to return only
[133] Fix | Delete
* that line.
[134] Fix | Delete
*
[135] Fix | Delete
* @param int $start The starting number.
[136] Fix | Delete
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
[137] Fix | Delete
* @return array Array of all of the lines between the specified range.
[138] Fix | Delete
*/
[139] Fix | Delete
public function getB($start=0, $end=null)
[140] Fix | Delete
{
[141] Fix | Delete
if($start == 0 && $end === null) {
[142] Fix | Delete
return $this->b;
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
if($end === null) {
[146] Fix | Delete
$length = 1;
[147] Fix | Delete
}
[148] Fix | Delete
else {
[149] Fix | Delete
$length = $end - $start;
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
return array_slice($this->b, $start, $length);
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
/**
[156] Fix | Delete
* Generate a list of the compiled and grouped opcodes for the differences between the
[157] Fix | Delete
* two strings. Generally called by the renderer, this class instantiates the sequence
[158] Fix | Delete
* matcher and performs the actual diff generation and return an array of the opcodes
[159] Fix | Delete
* for it. Once generated, the results are cached in the diff class instance.
[160] Fix | Delete
*
[161] Fix | Delete
* @return array Array of the grouped opcodes for the generated diff.
[162] Fix | Delete
*/
[163] Fix | Delete
public function getGroupedOpcodes()
[164] Fix | Delete
{
[165] Fix | Delete
if(!is_null($this->groupedCodes)) {
[166] Fix | Delete
return $this->groupedCodes;
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
require_once(dirname(__FILE__) . '/Diff/SequenceMatcher.php');
[170] Fix | Delete
$sequenceMatcher = new Diff_SequenceMatcher($this->a, $this->b, null, $this->options);
[171] Fix | Delete
$this->groupedCodes = $sequenceMatcher->getGroupedOpcodes();
[172] Fix | Delete
return $this->groupedCodes;
[173] Fix | Delete
}
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function