public function getDiff($old, $new, $granularity = null) { $granularity = $granularity ? $this->getGranularity($granularity) : $this->defaultGranularity; $opcodes = FineDiff::getDiffOpcodes($old, $new, $granularity); $html = FineDiff::renderDiffToHTMLFromOpcodes($old, $opcodes); return $html; }
$num_files -= 1; if ($num_files < $cache_lo_water_mark) { break; } } } } // save diff in cache $data_to_serialize = array('granularity' => $granularity, 'from_text' => $from_text, 'diff_opcodes' => $diff_opcodes, 'data_key' => $data_key); $serialized_data = serialize($data_to_serialize); @file_put_contents("./cache/{$filename}", gzcompress($serialized_data)); @chmod("./cache/{$filename}", 0666); } } } $rendered_diff = FineDiff::renderDiffToHTMLFromOpcodes($from_text, $diff_opcodes); $from_len = strlen($from_text); $to_len = strlen($to_text); if (!empty($data_key)) { echo '<p style="margin-right:8em;font-size:smaller">Tempolink: <a href="viewdiff.php?data=', $data_key, '">http://', $_SERVER['HTTP_HOST'], '/viewdiff.php?data=', $data_key, '</a> <span style="color:#aaa">(This link is not viewable by others, unless it has been explicitly shared by the creator. This link will exist for a limited period of time, which depends on how often it is visited.)</span></p>', "\n"; } ?> <div class="panecontainer" style="width:99%"><p>Diff <span style="color:gray">(diff: <?php printf('%.3f', $exec_time); ?> seconds, diff len: <?php echo $diff_opcodes_len; ?> chars)</span> / Show <input type="radio" name="htmldiffshow" onclick="setHTMLDiffVisibility('deletions');">Deletions only <input type="radio" name="htmldiffshow" checked="checked" onclick="setHTMLDiffVisibility();">All <input type="radio" name="htmldiffshow" onclick="setHTMLDiffVisibility('insertions');">Insertions only</p><div><div id="htmldiff" class="pane" style="white-space:pre-wrap"><?php echo $rendered_diff; ?>