_leading_context_lines = $context_lines; $this->_trailing_context_lines = $context_lines; $this->orig = ""; $this->final = ""; } protected function _startDiff() { } protected function _endDiff() { return [$this->orig, $this->final]; } protected function _blockHeader($xbeg, $xlen, $ybeg, $ylen) { } protected function _startBlock($header) { echo $header; } protected function _endBlock() { } protected function _lines($lines, $prefix = '', $suffix = '', $type = '') { if ($type == 'context') { foreach ($lines as $line) { $this->orig .= htmlspecialchars($line); $this->final .= htmlspecialchars($line); } } elseif ($type == 'added' || $type == 'change-added') { $l = ""; foreach ($lines as $line) { $l .= htmlspecialchars($line); } if (! empty($l)) { $this->final .= '' . $l . ""; } } elseif ($type == 'deleted' || $type == 'change-deleted') { $l = ""; foreach ($lines as $line) { $l .= htmlspecialchars($line); } if (! empty($l)) { $this->orig .= '' . $l . ""; } } } protected function _context($lines) { $this->_lines($lines, '', '', 'context'); } protected function _added($lines, $changemode = false) { if ($changemode) { $this->_lines($lines, '+', '', 'change-added'); } else { $this->_lines($lines, '+', '', 'added'); } } protected function _deleted($lines, $changemode = false) { if ($changemode) { $this->_lines($lines, '-', '', 'change-deleted'); } else { $this->_lines($lines, '-', '', 'deleted'); } } protected function _changed($orig, $final) { $this->_deleted($orig, true); $this->_added($final, true); } }