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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib/Diff
File: SequenceMatcher.php
$ai,
[500] Fix | Delete
$i,
[501] Fix | Delete
$bj,
[502] Fix | Delete
$j
[503] Fix | Delete
);
[504] Fix | Delete
}
[505] Fix | Delete
}
[506] Fix | Delete
return $this->opCodes;
[507] Fix | Delete
}
[508] Fix | Delete
[509] Fix | Delete
/**
[510] Fix | Delete
* Return a series of nested arrays containing different groups of generated
[511] Fix | Delete
* opcodes for the differences between the strings with up to $context lines
[512] Fix | Delete
* of surrounding content.
[513] Fix | Delete
*
[514] Fix | Delete
* Essentially what happens here is any big equal blocks of strings are stripped
[515] Fix | Delete
* out, the smaller subsets of changes are then arranged in to their groups.
[516] Fix | Delete
* This means that the sequence matcher and diffs do not need to include the full
[517] Fix | Delete
* content of the different files but can still provide context as to where the
[518] Fix | Delete
* changes are.
[519] Fix | Delete
*
[520] Fix | Delete
* @param int $context The number of lines of context to provide around the groups.
[521] Fix | Delete
* @return array Nested array of all of the grouped opcodes.
[522] Fix | Delete
*/
[523] Fix | Delete
public function getGroupedOpcodes($context=3)
[524] Fix | Delete
{
[525] Fix | Delete
$opCodes = $this->getOpCodes();
[526] Fix | Delete
if(empty($opCodes)) {
[527] Fix | Delete
$opCodes = array(
[528] Fix | Delete
array(
[529] Fix | Delete
'equal',
[530] Fix | Delete
0,
[531] Fix | Delete
1,
[532] Fix | Delete
0,
[533] Fix | Delete
1
[534] Fix | Delete
)
[535] Fix | Delete
);
[536] Fix | Delete
}
[537] Fix | Delete
[538] Fix | Delete
if($opCodes[0][0] == 'equal') {
[539] Fix | Delete
$opCodes[0] = array(
[540] Fix | Delete
$opCodes[0][0],
[541] Fix | Delete
max($opCodes[0][1], $opCodes[0][2] - $context),
[542] Fix | Delete
$opCodes[0][2],
[543] Fix | Delete
max($opCodes[0][3], $opCodes[0][4] - $context),
[544] Fix | Delete
$opCodes[0][4]
[545] Fix | Delete
);
[546] Fix | Delete
}
[547] Fix | Delete
[548] Fix | Delete
$lastItem = count($opCodes) - 1;
[549] Fix | Delete
if($opCodes[$lastItem][0] == 'equal') {
[550] Fix | Delete
list($tag, $i1, $i2, $j1, $j2) = $opCodes[$lastItem];
[551] Fix | Delete
$opCodes[$lastItem] = array(
[552] Fix | Delete
$tag,
[553] Fix | Delete
$i1,
[554] Fix | Delete
min($i2, $i1 + $context),
[555] Fix | Delete
$j1,
[556] Fix | Delete
min($j2, $j1 + $context)
[557] Fix | Delete
);
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
$maxRange = $context * 2;
[561] Fix | Delete
$groups = array();
[562] Fix | Delete
$group = array();
[563] Fix | Delete
foreach($opCodes as $code) {
[564] Fix | Delete
list($tag, $i1, $i2, $j1, $j2) = $code;
[565] Fix | Delete
if($tag == 'equal' && $i2 - $i1 > $maxRange) {
[566] Fix | Delete
$group[] = array(
[567] Fix | Delete
$tag,
[568] Fix | Delete
$i1,
[569] Fix | Delete
min($i2, $i1 + $context),
[570] Fix | Delete
$j1,
[571] Fix | Delete
min($j2, $j1 + $context)
[572] Fix | Delete
);
[573] Fix | Delete
$groups[] = $group;
[574] Fix | Delete
$group = array();
[575] Fix | Delete
$i1 = max($i1, $i2 - $context);
[576] Fix | Delete
$j1 = max($j1, $j2 - $context);
[577] Fix | Delete
}
[578] Fix | Delete
$group[] = array(
[579] Fix | Delete
$tag,
[580] Fix | Delete
$i1,
[581] Fix | Delete
$i2,
[582] Fix | Delete
$j1,
[583] Fix | Delete
$j2
[584] Fix | Delete
);
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
if(!empty($group) && !(count($group) == 1 && $group[0][0] == 'equal')) {
[588] Fix | Delete
$groups[] = $group;
[589] Fix | Delete
}
[590] Fix | Delete
[591] Fix | Delete
return $groups;
[592] Fix | Delete
}
[593] Fix | Delete
[594] Fix | Delete
/**
[595] Fix | Delete
* Return a measure of the similarity between the two sequences.
[596] Fix | Delete
* This will be a float value between 0 and 1.
[597] Fix | Delete
*
[598] Fix | Delete
* Out of all of the ratio calculation functions, this is the most
[599] Fix | Delete
* expensive to call if getMatchingBlocks or getOpCodes is yet to be
[600] Fix | Delete
* called. The other calculation methods (quickRatio and realquickRatio)
[601] Fix | Delete
* can be used to perform quicker calculations but may be less accurate.
[602] Fix | Delete
*
[603] Fix | Delete
* The ratio is calculated as (2 * number of matches) / total number of
[604] Fix | Delete
* elements in both sequences.
[605] Fix | Delete
*
[606] Fix | Delete
* @return float The calculated ratio.
[607] Fix | Delete
*/
[608] Fix | Delete
public function Ratio()
[609] Fix | Delete
{
[610] Fix | Delete
$matches = array_reduce($this->getMatchingBlocks(), array($this, 'ratioReduce'), 0);
[611] Fix | Delete
return $this->calculateRatio($matches, count ($this->a) + count ($this->b));
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
/**
[615] Fix | Delete
* Helper function to calculate the number of matches for Ratio().
[616] Fix | Delete
*
[617] Fix | Delete
* @param int $sum The running total for the number of matches.
[618] Fix | Delete
* @param array $triple Array containing the matching block triple to add to the running total.
[619] Fix | Delete
* @return int The new running total for the number of matches.
[620] Fix | Delete
*/
[621] Fix | Delete
private function ratioReduce($sum, $triple)
[622] Fix | Delete
{
[623] Fix | Delete
return $sum + ($triple[count($triple) - 1]);
[624] Fix | Delete
}
[625] Fix | Delete
[626] Fix | Delete
[627] Fix | Delete
/**
[628] Fix | Delete
* Helper function for calculating the ratio to measure similarity for the strings.
[629] Fix | Delete
* The ratio is defined as being 2 * (number of matches / total length)
[630] Fix | Delete
*
[631] Fix | Delete
* @param int $matches The number of matches in the two strings.
[632] Fix | Delete
* @param int $length The length of the two strings.
[633] Fix | Delete
* @return float The calculated ratio.
[634] Fix | Delete
*/
[635] Fix | Delete
private function calculateRatio($matches, $length=0)
[636] Fix | Delete
{
[637] Fix | Delete
if($length) {
[638] Fix | Delete
return 2 * ($matches / $length);
[639] Fix | Delete
}
[640] Fix | Delete
else {
[641] Fix | Delete
return 1;
[642] Fix | Delete
}
[643] Fix | Delete
}
[644] Fix | Delete
[645] Fix | Delete
/**
[646] Fix | Delete
* Helper function that provides the ability to return the value for a key
[647] Fix | Delete
* in an array of it exists, or if it doesn't then return a default value.
[648] Fix | Delete
* Essentially cleaner than doing a series of if(isset()) {} else {} calls.
[649] Fix | Delete
*
[650] Fix | Delete
* @param array $array The array to search.
[651] Fix | Delete
* @param string $key The key to check that exists.
[652] Fix | Delete
* @param mixed $default The value to return as the default value if the key doesn't exist.
[653] Fix | Delete
* @return mixed The value from the array if the key exists or otherwise the default.
[654] Fix | Delete
*/
[655] Fix | Delete
private function arrayGetDefault($array, $key, $default)
[656] Fix | Delete
{
[657] Fix | Delete
if(isset($array[$key])) {
[658] Fix | Delete
return $array[$key];
[659] Fix | Delete
}
[660] Fix | Delete
else {
[661] Fix | Delete
return $default;
[662] Fix | Delete
}
[663] Fix | Delete
}
[664] Fix | Delete
[665] Fix | Delete
/**
[666] Fix | Delete
* Sort an array by the nested arrays it contains. Helper function for getMatchingBlocks
[667] Fix | Delete
*
[668] Fix | Delete
* @param array $a First array to compare.
[669] Fix | Delete
* @param array $b Second array to compare.
[670] Fix | Delete
* @return int -1, 0 or 1, as expected by the usort function.
[671] Fix | Delete
*/
[672] Fix | Delete
private function tupleSort($a, $b)
[673] Fix | Delete
{
[674] Fix | Delete
$max = max(count($a), count($b));
[675] Fix | Delete
for($i = 0; $i < $max; ++$i) {
[676] Fix | Delete
if($a[$i] < $b[$i]) {
[677] Fix | Delete
return -1;
[678] Fix | Delete
}
[679] Fix | Delete
else if($a[$i] > $b[$i]) {
[680] Fix | Delete
return 1;
[681] Fix | Delete
}
[682] Fix | Delete
}
[683] Fix | Delete
[684] Fix | Delete
if(count($a) == count($b)) {
[685] Fix | Delete
return 0;
[686] Fix | Delete
}
[687] Fix | Delete
else if(count($a) < count($b)) {
[688] Fix | Delete
return -1;
[689] Fix | Delete
}
[690] Fix | Delete
else {
[691] Fix | Delete
return 1;
[692] Fix | Delete
}
[693] Fix | Delete
}
[694] Fix | Delete
}
[695] Fix | Delete
[696] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function