*/
var $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline';
+ /**
+ * Should we show the split view or not
+ *
+ * @var string
+ * @access protected
+ * @since 3.6.0
+ */
+ var $_show_split_view = true;
+
/**
* Constructor - Call parent constructor with params array.
*
*/
function __construct( $params = array() ) {
parent::__construct( $params );
+ if ( isset( $params[ 'show_split_view' ] ) )
+ $this->_show_split_view = $params[ 'show_split_view' ];
}
/**
* @return string
*/
function addedLine( $line ) {
- return "<td>+</td><td class='diff-addedline'>{$line}</td>";
+ return "<td class='diff-addedline'>{$line}</td>";
+
}
/**
* @return string
*/
function deletedLine( $line ) {
- return "<td>-</td><td class='diff-deletedline'>{$line}</td>";
+ return "<td class='diff-deletedline'>{$line}</td>";
}
/**
* @return string
*/
function contextLine( $line ) {
- return "<td> </td><td class='diff-context'>{$line}</td>";
+ return "<td class='diff-context'>{$line}</td>";
}
/**
* @return string
*/
function emptyLine() {
- return '<td colspan="2"> </td>';
+ return '<td> </td>';
}
/**
foreach ($lines as $line) {
if ( $encode )
$line = htmlspecialchars( $line );
- $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
+ if ( $this->_show_split_view ) {
+ $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
+ } else {
+ $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n";
+ }
}
return $r;
}
foreach ($lines as $line) {
if ( $encode )
$line = htmlspecialchars( $line );
- $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n";
+ if ( $this->_show_split_view ) {
+ $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
+ } else {
+ $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n";
+ }
+
}
return $r;
}
foreach ($lines as $line) {
if ( $encode )
$line = htmlspecialchars( $line );
- $r .= '<tr>' .
- $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n";
+ if ( $this->_show_split_view ) {
+ $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line ) . "</tr>\n";
+ } else {
+ $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n";
+ }
}
return $r;
}
} elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row.
$r .= $this->_deleted( array($orig_line), false );
} else { // A true changed row.
- $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "</tr>\n";
+ if ( $this->_show_split_view ) {
+ $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n";
+ } else {
+ $r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n";
+ }
}
}
}
return array($orig_matches, $final_matches, $orig_rows, $final_rows);
-
-/*
- // Debug
- echo "\n\n\n\n\n";
-
- echo "-- DEBUG Matches: Orig -> Final --";
-
- foreach ( $orig_matches as $o => $f ) {
- echo "\n\n\n\n\n";
- echo "ORIG: $o, FINAL: $f\n";
- var_dump($orig[$o],$final[$f]);
- }
- echo "\n\n\n\n\n";
-
- echo "-- DEBUG Matches: Final -> Orig --";
-
- foreach ( $final_matches as $f => $o ) {
- echo "\n\n\n\n\n";
- echo "FINAL: $f, ORIG: $o\n";
- var_dump($final[$f],$orig[$o]);
- }
- echo "\n\n\n\n\n";
-
- echo "-- DEBUG Rows: Orig -- Final --";
-
- echo "\n\n\n\n\n";
- foreach ( $orig_rows as $row => $o ) {
- if ( $o < 0 )
- $o = 'X';
- $f = $final_rows[$row];
- if ( $f < 0 )
- $f = 'X';
- echo "$o -- $f\n";
- }
- echo "\n\n\n\n\n";
-
- echo "-- END DEBUG --";
-
- echo "\n\n\n\n\n";
-
- return array($orig_matches, $final_matches, $orig_rows, $final_rows);
-*/
}
/**
$chars2 = count_chars($string2);
// L1-norm of difference vector.
- $difference = array_sum( array_map( array(&$this, 'difference'), $chars1, $chars2 ) );
+ $difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
// $string1 has zero length? Odd. Give huge penalty by not dividing.
if ( !$string1 )