<commit_before><?php
// $Header: /cvsroot/tikiwiki/tiki/lib/diff/renderer_sidebyside.php,v 1.2 2004-08-03 19:44:57 teedog Exp $

/**
 * "Side-by-Side" diff renderer.
 *
 * This class renders the diff in "side-by-side" format, like Wikipedia.
 *
 * @package Text_Diff
 */
class Text_Diff_Renderer_sidebyside extends Text_Diff_Renderer {

    function Text_Diff_Renderer_sidebyside($context_lines = 4)
    {
        $this->_leading_context_lines = $context_lines;
        $this->_trailing_context_lines = $context_lines;
    }
    
    function _startDiff()
    {
        ob_start();
        echo '<table class="normal diff">';
    }

    function _endDiff()
    {
        echo '</table>';
        $val = ob_get_contents();
        ob_end_clean();
        return $val;
    }

    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
    {
        return "Line: $xbeg";
    }

    function _startBlock($header)
    {
        echo '<tr class="diffheader"><td></td><td>'.$header.'</td><td></td><td>'.$header.'</tr>';
    }

    function _endBlock()
    {
    }

    function _lines($type, $lines, $prefix = '')
    {
    	if ($type == 'context') {
	        foreach ($lines as $line) {
	        	if (!empty($line))
	            echo "<tr class='diffbody'><td></td><td>$line</td><td></td><td>$line</td></tr>\n";
	        }
    	} elseif ($type == 'added') {
	        foreach ($lines as $line) {
	        	if (!empty($line))
	            echo "<tr class='diffadded'><td colspan='2'></td><td>$prefix</td><td>$line</td></tr>\n";
	        }
    	} elseif ($type == 'deleted') {
	        foreach ($lines as $line) {
	        	if (!empty($line))
	            echo "<tr class='diffdeleted'><td>$prefix</td><td>$line</td><td colspan='2'></td></tr>\n";
	        }
    	} elseif ($type == 'change-deleted') {
    		foreach ($lines as $line) {
    			if (!empty($line))
    			echo "<tr><td class='diffdeleted'>$prefix</td><td class='diffdeleted'>$line</td>\n";
    		}
    	} elseif ($type == 'change-added') {
    		foreach ($lines as $line) {
    			if (!empty($line))
    			echo "<td class='diffadded'>$prefix</td><td class='diffadded'>$line</td></tr>\n";
    		}
    	}
    }

    function _context($lines)
    {
        $this->_lines('context', $lines);
    }

    function _added($lines, $changemode = FALSE)
    {
        if ($changemode) {
        	$this->_lines('change-added', $lines, '+');
        } else {
        	$this->_lines('added', $lines, '+');<commit_msg>when a group of lines changed, the respectivelly old and new lines  must be grouped in a same cell<commit_after><?php
// $Header: /cvsroot/tikiwiki/tiki/lib/diff/renderer_sidebyside.php,v 1.3 2004-08-11 17:39:01 sylvieg Exp $

/**
 * "Side-by-Side" diff renderer.
 *
 * This class renders the diff in "side-by-side" format, like Wikipedia.
 *
 * @package Text_Diff
 */
class Text_Diff_Renderer_sidebyside extends Text_Diff_Renderer {

    function Text_Diff_Renderer_sidebyside($context_lines = 4)
    {
        $this->_leading_context_lines = $context_lines;
        $this->_trailing_context_lines = $context_lines;
    }
    
    function _startDiff()
    {
        ob_start();
        echo '<table class="normal diff">';
    }

    function _endDiff()
    {
        echo '</table>';
        $val = ob_get_contents();
        ob_end_clean();
        return $val;
    }

    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
    {
        return "Line: $xbeg";
    }

    function _startBlock($header)
    {
        echo '<tr class="diffheader"><td></td><td>'.$header.'</td><td></td><td>'.$header.'</tr>';
    }

    function _endBlock()
    {
    }

    function _lines($type, $lines, $prefix = '')
    {
    	if ($type == 'context') {
	        foreach ($lines as $line) {
	        	if (!empty($line))
	            echo "<tr class='diffbody'><td></td><td>$line</td><td></td><td>$line</td></tr>\n";
	        }
    	} elseif ($type == 'added') {
	        foreach ($lines as $line) {
	        	if (!empty($line))
	            echo "<tr class='diffadded'><td colspan='2'></td><td>$prefix</td><td>$line</td></tr>\n";
	        }
    	} elseif ($type == 'deleted') {
	        foreach ($lines as $line) {
	        	if (!empty($line))
	            echo "<tr class='diffdeleted'><td>$prefix</td><td>$line</td><td colspan='2'></td></tr>\n";
	        }
    	} elseif ($type == 'change-deleted') {
    		echo '<tr><td class="diffdeleted" valign="top">'.$prefix.'</td><td class="diffdeleted" valign="top">'.implode("<br />", $lines)."</td>\n";
    	} elseif ($type == 'change-added') {
    		echo '<td class="diffadded" valign="top">'.$prefix.'</td><td class="diffadded" valign="top">'.implode("<br />", $lines)."</td></tr>\n";
    	}
    }

    function _context($lines)
    {
        $this->_lines('context', $lines);
    }

    function _added($lines, $changemode = FALSE)
    {
        if ($changemode) {
        	$this->_lines('change-added', $lines, '+');
        } else {
        	$this->_lines('added', $lines, '+');
{'fraction_non_alphanumeric': 0.19947665056360708, 'fraction_numerical': 0.007648953301127214, 'mean_word_length': 2.484572230014025, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '950083', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1684, 'n_words': 308}