Make WordPress Core


Ignore:
Timestamp:
02/28/2013 03:14:34 PM (14 years ago)
Author:
westi
Message:

Revisions: First pass an implementing a new UI/UX for reviewing the revisions of posts. See #23497 props adamsilverstein for the initial patch.

This implements a new revisions ui using Backbone and preserves all the old methods of "integration" so the change should be transparent to plugins using revisi
ons with CPTs.

This is the first pass and so there are a number of things still to be resolved, more details in the ticket. Feedback welcomed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wp-diff.php

    r22118 r23506  
    6161
    6262        /**
     63         * Should we show the split view or not
     64         *
     65         * @var string
     66         * @access protected
     67         * @since 3.6.0
     68         */
     69        var $_show_split_view = true;
     70
     71        /**
    6372         * Constructor - Call parent constructor with params array.
    6473         *
    … …  
    7180        function __construct( $params = array() ) {
    7281                parent::__construct( $params );
     82                if ( isset( $params[ 'show_split_view' ] ) )
     83                        $this->_show_split_view = $params[ 'show_split_view' ];
    7384        }
    7485
    … …  
    99110         */
    100111        function addedLine( $line ) {
    101                 return "<td>+</td><td class='diff-addedline'>{$line}</td>";
     112                return "<td class='diff-addedline'>{$line}</td>";
     113
    102114        }
    103115
    … …  
    109121         */
    110122        function deletedLine( $line ) {
    111                 return "<td>-</td><td class='diff-deletedline'>{$line}</td>";
     123                return "<td class='diff-deletedline'>{$line}</td>";
    112124        }
    113125
    … …  
    119131         */
    120132        function contextLine( $line ) {
    121                 return "<td> </td><td class='diff-context'>{$line}</td>";
     133                return "<td class='diff-context'>{$line}</td>";
    122134        }
    123135
    … …  
    128140         */
    129141        function emptyLine() {
    130                 return '<td colspan="2">&nbsp;</td>';
     142                return '<td>&nbsp;</td>';
    131143        }
    132144
    … …  
    143155                foreach ($lines as $line) {
    144156                        if ( $encode )
    145                                 $line = htmlspecialchars( $line );
    146                         $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
     157                                $line = wp_kses_post( $line );
     158                        if ( $this->_show_split_view ) {
     159                                $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
     160                        } else {
     161                                $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n";
     162                        }
    147163                }
    148164                return $r;
    … …  
    161177                foreach ($lines as $line) {
    162178                        if ( $encode )
    163                                 $line = htmlspecialchars( $line );
    164                         $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n";
     179                                $line = wp_kses_post( $line );
     180                        if ( $this->_show_split_view ) {
     181                                $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
     182                        } else {
     183                                $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n";
     184                        }
     185
    165186                }
    166187                return $r;
    … …  
    179200                foreach ($lines as $line) {
    180201                        if ( $encode )
    181                                 $line = htmlspecialchars( $line );
    182                         $r .= '<tr>' .
    183                                 $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n";
     202                                $line = wp_kses_post( $line );
     203                        if (  $this->_show_split_view ) {
     204                                $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line )  . "</tr>\n";
     205                        } else {
     206                                $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n";
     207                        }
    184208                }
    185209                return $r;
    … …  
    265289                                $r .= $this->_deleted( array($orig_line), false );
    266290                        } else { // A true changed row.
    267                                 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "</tr>\n";
     291                                if ( $this->_show_split_view ) {
     292                                        $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n";
     293                                } else {
     294                                        $r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n";
     295                                }
    268296                        }
    269297                }
Note: See TracChangeset for help on using the changeset viewer.