private function compareResult($pathinput, $pathoutput) { $finediff = new cogpowered\FineDiff\Diff(); $input = fopen($pathinput, "r"); $output = fopen($pathoutput, "r"); while (!feof($input)) { $lineinp = fgets($input, 4096); $lineout = fgets($output, 4096); $opcodes = $finediff->getOpcodes($lineinp, $lineout); for ($i = 0; $i < strlen($opcodes); $i++) { if ($opcodes[$i] == 'i') { $i++; while ($opcodes[$i] != ':') { $i++; } $i++; if ($opcodes[$i] != ' ' || $opcodes[$i] != '\\t' || $opcodes[$i] != '\\n') { throw new IncorrectOutputError(); #return -8; } else { throw new OutputFormatError(); #return -9; } } else { if ($opcodes[$i] == 'd') { throw new OutputFormatError(); # return -9; } } } } return 0; }
<span style="text-decoration: line-through; background-color: #F78181;"><?php echo $this->fieldChanges[$index][1]; ?> </span> <span style="background-color: #BCF5A9;"><?php echo $this->fieldChanges[$index][2]; ?> </span> <?php } else { ?> <?php $granularity = new cogpowered\FineDiff\Granularity\Word(); $diff = new cogpowered\FineDiff\Diff($granularity); $fromText = $this->fieldChanges[$index][1]; $toText = $this->fieldChanges[$index][2]; $opCodes = $diff->getOpcodes($fromText, $toText); $render = new cogpowered\FineDiff\Render\Html(); $diffHTML = $render->process($fromText, $opCodes); $diffHTML = str_replace('<ins>', '<ins style="color: green; background: #dfd; text-decoration: none;">', $diffHTML); $diffHTML = str_replace('<del>', '<del style="color: red;background: #fdd; text-decoration: none;">', $diffHTML); ?> <span><?php echo ucfirst($fieldChanged) . ': ' . str_replace("\n", '<br />', htmlspecialchars_decode($diffHTML)); ?> </span> <?php } ?> </div> <?php }