Ticket #23497: 23497.8.diff
File 23497.8.diff, 14.4 KB (added by , 12 years ago) |
---|
-
wp-includes/wp-diff.php
59 59 */ 60 60 var $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline'; 61 61 62 var $_showsplitview = null; 63 62 64 /** 63 65 * Constructor - Call parent constructor with params array. 64 66 * … … 70 72 */ 71 73 function __construct( $params = array() ) { 72 74 parent::__construct( $params ); 75 if ( isset( $params[ 'showsplitview' ] ) ) 76 $this -> _showsplitview = $params[ 'showsplitview' ]; 73 77 } 74 78 75 79 /** … … 98 102 * @return string 99 103 */ 100 104 function addedLine( $line ) { 101 return "<td>+</td><td class='diff-addedline'>{$line}</td>"; 105 return "<td class='diff-addedline'>{$line}</td>"; 106 102 107 } 103 108 104 109 /** … … 108 113 * @return string 109 114 */ 110 115 function deletedLine( $line ) { 111 return "<td >-</td><tdclass='diff-deletedline'>{$line}</td>";116 return "<td class='diff-deletedline'>{$line}</td>"; 112 117 } 113 118 114 119 /** … … 118 123 * @return string 119 124 */ 120 125 function contextLine( $line ) { 121 return "<td > </td><tdclass='diff-context'>{$line}</td>";126 return "<td class='diff-context'>{$line}</td>"; 122 127 } 123 128 124 129 /** … … 127 132 * @return string 128 133 */ 129 134 function emptyLine() { 130 return '<td colspan="2"> </td>';135 return '<td> </td>'; 131 136 } 132 137 133 138 /** … … 142 147 $r = ''; 143 148 foreach ($lines as $line) { 144 149 if ( $encode ) 145 $line = htmlspecialchars( $line ); 146 $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; 150 $line = wp_kses_post( $line ); 151 if ( ! $this->_showsplitview ) { 152 $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n"; 153 } else { 154 $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; 155 } 147 156 } 148 157 return $r; 149 158 } … … 160 169 $r = ''; 161 170 foreach ($lines as $line) { 162 171 if ( $encode ) 163 $line = htmlspecialchars( $line ); 164 $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n"; 172 $line = wp_kses_post( $line ); 173 if ( ! $this->_showsplitview ) { 174 $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n"; 175 } else { 176 $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n"; 177 } 178 165 179 } 166 180 return $r; 167 181 } … … 178 192 $r = ''; 179 193 foreach ($lines as $line) { 180 194 if ( $encode ) 181 $line = htmlspecialchars( $line ); 182 $r .= '<tr>' . 183 $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n"; 195 $line = wp_kses_post( $line ); 196 if ( ! $this->_showsplitview ) { 197 $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n"; 198 } else { 199 $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line ) . "</tr>\n"; 200 } 184 201 } 185 202 return $r; 186 203 } … … 264 281 } elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row. 265 282 $r .= $this->_deleted( array($orig_line), false ); 266 283 } else { // A true changed row. 267 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "</tr>\n"; 284 if ( ! $this->_showsplitview ) { 285 $r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n"; 286 } else { 287 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n"; 288 } 268 289 } 269 290 } 270 291 -
wp-includes/pluggable.php
1713 1713 1714 1714 $left_lines = explode("\n", $left_string); 1715 1715 $right_lines = explode("\n", $right_string); 1716 1717 1716 $text_diff = new Text_Diff($left_lines, $right_lines); 1718 $renderer = new WP_Text_Diff_Renderer_Table( );1717 $renderer = new WP_Text_Diff_Renderer_Table( $args ); 1719 1718 $diff = $renderer->render($text_diff); 1720 1719 1721 1720 if ( !$diff ) 1722 1721 return ''; 1723 1722 1724 1723 $r = "<table class='diff'>\n"; 1725 $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";1726 1724 1725 if ( isset( $args[ 'showsplitview' ] ) && 'true' == $args[ 'showsplitview' ] ) { 1726 $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />"; 1727 } else { 1728 $r .= "<col class='content' />"; 1729 } 1730 1727 1731 if ( $args['title'] || $args['title_left'] || $args['title_right'] ) 1728 1732 $r .= "<thead>"; 1729 1733 if ( $args['title'] ) -
wp-includes/script-loader.php
270 270 $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2011-02-23'); 271 271 272 272 $scripts->add( 'underscore', '/wp-includes/js/underscore.min.js', array(), '1.4.4', 1 ); 273 $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery'), '0.9.2', 1 ); 273 $scripts->add( 'template', "/wp-includes/js/template$suffix.js", array('underscore'), '1.4.4', 1 ); 274 $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery', 'template'), '0.9.2', 1 ); 274 275 276 $scripts->add( 'revisions', "/wp-includes/js/revisions$suffix.js", array('backbone'), '', 1 ); 277 275 278 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 ); 276 279 277 280 $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), false, 1 ); … … 537 540 $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie' ) ); 538 541 $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons' ) ); 539 542 $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); 543 $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" ); 544 $styles->add( 'wp-jquery-ui-slider', "/wp-includes/css/jquery-ui-slider$suffix.css" ); 540 545 541 546 foreach ( $rtl_styles as $rtl_style ) { 542 547 $styles->add_data( $rtl_style, 'rtl', true ); -
wp-admin/admin-ajax.php
42 42 43 43 $core_actions_get = array( 44 44 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache', 45 'autocomplete-user', 'dashboard-widgets', 'logged-in', 45 'autocomplete-user', 'dashboard-widgets', 'logged-in', 'revisions-data' 46 46 ); 47 47 48 48 $core_actions_post = array( … … 56 56 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post', 57 57 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 58 58 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 59 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat' ,59 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat' 60 60 ); 61 61 62 62 // Register core Ajax calls. -
wp-admin/includes/ajax-actions.php
1379 1379 global $wp_list_table; 1380 1380 1381 1381 check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); 1382 1382 1383 1383 $post_data = wp_unslash( $_POST ); 1384 1384 1385 1385 $taxonomy = sanitize_key( $post_data['taxonomy'] ); … … 2134 2134 wp_send_json($response); 2135 2135 } 2136 2136 2137 function wp_ajax_revisions_data() { 2138 2139 $compareto = isset( $_GET['compareto'] ) ? $_GET['compareto'] : 0; 2140 $showautosaves = isset( $_GET['showautosaves'] ) ? $_GET['showautosaves'] : ''; 2141 $showsplitview = isset( $_GET['showsplitview'] ) ? $_GET['showsplitview'] : ''; 2142 $postid = isset( $_GET['postid'] ) ? $_GET['postid'] : ''; 2143 2144 $comparetwomode = ( '' == $postid ) ? false : true; 2145 // 2146 //TODO: currently code returns all possible comparisons for the indicated 'compareto' revision 2147 //however, the front end prevents users from pulling the right handle past the left or the left pass the right, 2148 //so only the possible diffs need be generated 2149 // 2150 $alltherevisions = array(); 2151 2152 if ( '' == $postid ) 2153 $postid = $compareto; 2154 2155 if ( ! $revisions = wp_get_post_revisions( $postid ) ) 2156 return; 2157 2158 //if we are comparing two revisions, the first 'revision' represented by the leftmost 2159 //slider position is the current revision, prepend a comparison to this revision 2160 if ( $comparetwomode ) 2161 array_unshift( $revisions, get_post( $postid ) ); 2162 2163 $count = 1; 2164 foreach ( $revisions as $revision ) : 2165 if ( 'true' != $showautosaves && wp_is_post_autosave( $revision ) ) 2166 continue; 2167 2168 $revision_from_date_author = ''; 2169 2170 2171 //if ( current_user_can( 'read_post', $revision->ID ) ) 2172 // continue; 2173 $left_revision = get_post( $compareto ); 2174 $right_revision = get_post( $revision ); 2175 2176 $author = get_the_author_meta( 'display_name', $revision->post_author ); 2177 $compareto_author = get_the_author_meta( 'display_name', $left_revision->post_author ); 2178 /* translators: revision date format, see http://php.net/date */ 2179 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 2180 2181 $gravatar = get_avatar( $revision->post_author, 18 ); 2182 $compareto_gravatar = get_avatar( $left_revision->post_author, 18 ); 2183 2184 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 2185 $compareto_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) ); 2186 $revision_date_author = sprintf( 2187 '%s %s, %s %s (%s)', 2188 $gravatar, 2189 $author, 2190 human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ), 2191 __( ' ago ' ), 2192 $date 2193 ); 2194 2195 if ( $comparetwomode ) { 2196 2197 $revision_from_date_author = sprintf( 2198 '%s %s, %s %s (%s)', 2199 $compareto_gravatar, 2200 $compareto_author, 2201 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ), 2202 __( ' ago ' ), 2203 $compareto_date 2204 ); 2205 } 2206 2207 $restoreaction = wp_nonce_url( 2208 add_query_arg( 2209 array( 'revision' => $revision->ID, 'action' => 'restore' ), 2210 '/wp-admin/revision.php' 2211 ), 2212 "restore-post_$compareto|$revision->ID" 2213 ); 2214 2215 // 2216 //make sure the left revision is the most recent 2217 // 2218 if ( strtotime( $right_revision->post_modified_gmt ) < strtotime( $left_revision->post_modified_gmt ) ) { 2219 $temp = $left_revision; 2220 $left_revision = $right_revision; 2221 $right_revision = $temp; 2222 } 2223 2224 // 2225 //compare from left to right, passed from application 2226 // 2227 $content=''; 2228 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 2229 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' ); 2230 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' ); 2231 2232 add_filter( "_wp_post_revision_field_$field", 'wp_kses_post' ); 2233 2234 $args = array(); 2235 2236 if ( 'true' == $showsplitview ) 2237 $args = array( 'showsplitview' => 'true' ); 2238 2239 $content .= wp_text_diff( $left_content, $right_content, $args ); 2240 } 2241 2242 //if we are comparing two revisions 2243 //and we are on the matching revision 2244 //add an error revision indicating unable to compare to self 2245 if ( $comparetwomode && $compareto == $revision->ID ) 2246 $alltherevisions[] = array ( 2247 'ID' => $revision->ID, 2248 'revision_date_author' => $revision_date_author, 2249 'revisiondiff' => sprintf('<div id="selfcomparisonerror">%s</div>', __( 'Cannot compare revision to itself' ) ), 2250 'restoreaction' => urldecode( $restoreaction ), 2251 'revision_from_date_author' => '' 2252 ); 2253 2254 //add to the return data only if there is a difference 2255 if ( '' != $content ) 2256 $alltherevisions[] = array ( 2257 'ID' => $revision->ID, 2258 'revision_date_author' => $revision_date_author, 2259 'revisiondiff' => $content, 2260 'restoreaction' => urldecode( $restoreaction ), 2261 'revision_from_date_author' => $revision_from_date_author 2262 ); 2263 2264 endforeach; 2265 2266 //remove initial revision that only contains 2267 //post title 2268 //TODO remove if this is fixed and initial revision not created 2269 array_pop( $alltherevisions ); 2270 echo json_encode( $alltherevisions ); 2271 exit(); 2272 } -
wp-admin/includes/meta-boxes.php
178 178 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Edit') ?></a> 179 179 <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'), 1); ?></div> 180 180 </div><?php // /misc-pub-section ?> 181 <?php endif; 182 183 $the_revisions = wp_get_post_revisions( $post->ID ); 184 185 if ( post_type_supports( $post_type, 'revisions' ) && count( $the_revisions ) ) : 186 ?> 187 <div id="post-revisions-link" class="misc-pub-section" > 188 <span id="revisions-link"><?php _e( 'Revisions:' ) ?></span> 189 <a href="<?php printf( 'revisions.php?revision=%s&postid=%s&action=edit', key( $the_revisions ), $post->ID )?>" class="edit-revisions hide-if-no-js"> 190 <?php _e( 'View' ); ?> 191 </a> 192 </div> 181 193 <?php endif; ?> 182 194 183 195 <?php do_action('post_submitbox_misc_actions'); ?> … … 979 991 function post_thumbnail_meta_box( $post ) { 980 992 $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 981 993 echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); 982 } 983 No newline at end of file 994 } -
wp-admin/css/colors-fresh.css
1299 1299 1300 1300 /* Diff */ 1301 1301 table.diff .diff-deletedline { 1302 background-color: #fdd; 1302 background-color: #ffe5e6; 1303 color: #f2001f; 1304 text-decoration: line-through; 1303 1305 } 1304 1306 1305 1307 table.diff .diff-deletedline del { 1306 1308 background-color: #f99; 1307 1309 } 1308 1310 1311 table.diff .diff-deletedline-symbol { 1312 color: #f2001f; 1313 } 1314 1309 1315 table.diff .diff-addedline { 1310 background-color: #dfd; 1316 background-color: #e9f6ea; 1317 color: #00a500; 1311 1318 } 1312 1319 1320 table.diff .diff-addedline-symbol { 1321 color: #00a500; 1322 } 1323 1313 1324 table.diff .diff-addedline ins { 1314 1325 background-color: #9f9; 1315 1326 } -
wp-admin/css/wp-admin.css
3495 3495 } 3496 3496 3497 3497 table.diff col.content { 3498 width: 50%;3498 width: auto; 3499 3499 } 3500 3500 3501 table.diff col.content.diffsplit { 3502 width: 48%; 3503 } 3504 3505 table.diff col.diffsplit.middle { 3506 width: 4%; 3507 } 3508 3509 table.diff col.ltype { 3510 width: 30px; 3511 } 3512 3501 3513 table.diff tr { 3502 3514 background-color: transparent; 3503 3515 }