1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8/**
9 * "Inline" diff renderer.
10 *
11 * This class renders the diff in "inline" format,
12 * with removed and inserted words for both versions
13 *
14 * @package Text_Diff
15 */
16
17require_once "renderer_sidebyside.php";
18
19class Text_Diff_Renderer_inline extends Text_Diff_Renderer_sidebyside
20{
21
22	public function __construct($context_lines = 4, $words = 1)
23	{
24		$this->_leading_context_lines = $context_lines;
25		$this->_trailing_context_lines = $context_lines;
26		$this->_words = $words;
27	}
28
29	protected function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
30	{
31		$this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
32		$orig = [];
33		$final = [];
34		foreach ($edits as $edit) {
35			if (is_array($edit->orig)) {
36				$orig = array_merge($orig, $edit->orig);
37			}
38			if (is_array($edit->final)) {
39				$final = array_merge($final, $edit->final);
40			}
41		}
42		$lines = diffChar($orig, $final, $this->_words, "character_inline");
43		echo "<tr class='diffbody'><td colspan='3'>$lines[0]</td></tr>\n";
44		$this->_endBlock();
45	}
46}
47