]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/wp-diff.php
WordPress 3.8
[autoinstalls/wordpress.git] / wp-includes / wp-diff.php
index 65dd00743de144a0ee50010ec7de3d826019889b..dc335e30e4c034c6388792204be2c0d9ed5ab0e8 100644 (file)
@@ -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 "<td>+</td><td class='diff-addedline'>{$line}</td>";
+               return "<td class='diff-addedline'>{$line}</td>";
+
        }
 
        /**
@@ -108,7 +120,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
         * @return string
         */
        function deletedLine( $line ) {
-               return "<td>-</td><td class='diff-deletedline'>{$line}</td>";
+               return "<td class='diff-deletedline'>{$line}</td>";
        }
 
        /**
@@ -118,7 +130,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
         * @return string
         */
        function contextLine( $line ) {
-               return "<td> </td><td class='diff-context'>{$line}</td>";
+               return "<td class='diff-context'>{$line}</td>";
        }
 
        /**
@@ -127,7 +139,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
         * @return string
         */
        function emptyLine() {
-               return '<td colspan="2">&nbsp;</td>';
+               return '<td>&nbsp;</td>';
        }
 
        /**
@@ -143,7 +155,11 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
                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;
        }
@@ -161,7 +177,12 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
                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;
        }
@@ -179,8 +200,11 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
                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;
        }
@@ -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 .= '<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";
+                               }
                        }
                }
 
@@ -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);
-*/
        }
 
        /**