You are here

class Text_Diff_Renderer_parallel in Coder 7.2

Same name and namespace in other branches
  1. 6.2 scripts/coder_format/tests/CoderTestFile.php \Text_Diff_Renderer_parallel
  2. 6 scripts/coder_format/tests/CoderTestFile.php \Text_Diff_Renderer_parallel
  3. 7 scripts/coder_format/tests/CoderTestFile.php \Text_Diff_Renderer_parallel

Parallel diff renderer for HTML tables with original text on left, new text on right, and changed text highlighted with appropriate classes.

Hierarchy

Expanded class hierarchy of Text_Diff_Renderer_parallel

File

scripts/coder_format/tests/CoderTestFile.php, line 172
Set of tests for the coder_format script.

View source
class Text_Diff_Renderer_parallel extends Text_Diff_Renderer {

  /* String header for left column */
  var $original = 'Expected';

  /* String header for right column */
  var $final = 'Actual';

  // These are big to ensure entire string is output.
  var $_leading_context_lines = 10000;
  var $_trailing_context_lines = 10000;
  var $title;
  function Text_Diff_Renderer_parallel($title) {
    $this->title = $title;
  }
  function _blockHeader() {
  }
  function _startDiff() {
    return '<table class="diff"><thead><tr><th colspan="2">' . $this->title . '</th></tr><tr><th>' . $this->original . '</th><th>' . $this->final . '</th></tr></thead><tbody>';
  }
  function _endDiff() {
    return '</tbody></table>';
  }
  function _context($lines) {
    return '<tr><td><pre>' . $this
      ->_renderLines($lines) . '</pre></td>
          <td><pre>' . $this
      ->_renderLines($lines) . '</pre></td></tr>';
  }
  function _added($lines) {
    return '<tr><td>&nbsp;</td><td class="added"><pre>' . $this
      ->_renderLines($lines) . '</pre></td></tr>';
  }
  function _deleted($lines) {
    return '<tr><td class="deleted"><pre>' . $this
      ->_renderLines($lines) . '</pre></td><td>&nbsp;</td></tr>';
  }
  function _changed($orig, $final) {
    return '<tr class="changed"><td><pre>' . $this
      ->_renderLines($orig) . '</pre></td>
        <td><pre>' . $this
      ->_renderLines($final) . '</pre></td></tr>';
  }
  function _renderLines($lines) {
    return str_replace("\n", "<strong>&para;</strong>\n", htmlspecialchars(implode("\n", $lines) . "\n"));
  }

}

Members