]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/wp-diff.php
WordPress 3.7.2-scripts
[autoinstalls/wordpress.git] / wp-includes / wp-diff.php
index 052bf133458f5c662fe760e1494ec05f75db88cd..62f4162fa37df5c7c72933ab84537bb83d29b826 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";
+                               }
                        }
                }
 
@@ -422,7 +450,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
                $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 )