X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6c8f14c09105d0afa4c1574215c59b5021040e76..a349837896628462bf8c9bdc27d1477a10fe03eb:/wp-includes/wp-diff.php?ds=sidebyside diff --git a/wp-includes/wp-diff.php b/wp-includes/wp-diff.php index 65dd0074..dc335e30 100644 --- a/wp-includes/wp-diff.php +++ b/wp-includes/wp-diff.php @@ -59,6 +59,15 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { */ 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. * @@ -70,6 +79,8 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { */ function __construct( $params = array() ) { parent::__construct( $params ); + if ( isset( $params[ 'show_split_view' ] ) ) + $this->_show_split_view = $params[ 'show_split_view' ]; } /** @@ -98,7 +109,8 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { * @return string */ function addedLine( $line ) { - return "+{$line}"; + return "{$line}"; + } /** @@ -108,7 +120,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { * @return string */ function deletedLine( $line ) { - return "-{$line}"; + return "{$line}"; } /** @@ -118,7 +130,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { * @return string */ function contextLine( $line ) { - return " {$line}"; + return "{$line}"; } /** @@ -127,7 +139,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { * @return string */ function emptyLine() { - return ' '; + return ' '; } /** @@ -143,7 +155,11 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { foreach ($lines as $line) { if ( $encode ) $line = htmlspecialchars( $line ); - $r .= '' . $this->emptyLine() . $this->addedLine( $line ) . "\n"; + if ( $this->_show_split_view ) { + $r .= '' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "\n"; + } else { + $r .= '' . $this->addedLine( $line ) . "\n"; + } } return $r; } @@ -161,7 +177,12 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { foreach ($lines as $line) { if ( $encode ) $line = htmlspecialchars( $line ); - $r .= '' . $this->deletedLine( $line ) . $this->emptyLine() . "\n"; + if ( $this->_show_split_view ) { + $r .= '' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "\n"; + } else { + $r .= '' . $this->deletedLine( $line ) . "\n"; + } + } return $r; } @@ -179,8 +200,11 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { foreach ($lines as $line) { if ( $encode ) $line = htmlspecialchars( $line ); - $r .= '' . - $this->contextLine( $line ) . $this->contextLine( $line ) . "\n"; + if ( $this->_show_split_view ) { + $r .= '' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line ) . "\n"; + } else { + $r .= '' . $this->contextLine( $line ) . "\n"; + } } return $r; } @@ -264,7 +288,11 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { } 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 .= '' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "\n"; + if ( $this->_show_split_view ) { + $r .= '' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "\n"; + } else { + $r .= '' . $this->deletedLine( $orig_line ) . "" . $this->addedLine( $final_line ) . "\n"; + } } } @@ -363,48 +391,6 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { } 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); -*/ } /**