Changeset 23506
- Timestamp:
- 02/28/2013 03:14:34 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r23481 r23506 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 … … 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 -
trunk/wp-admin/css/colors-fresh.css
r23501 r23506 1352 1352 /* Diff */ 1353 1353 table.diff .diff-deletedline { 1354 background-color: #fdd; 1354 background-color: #ffe5e6; 1355 color: #f2001f; 1356 text-decoration: line-through; 1355 1357 } 1356 1358 … … 1359 1361 } 1360 1362 1363 table.diff .diff-deletedline-symbol { 1364 color: #f2001f; 1365 } 1366 1361 1367 table.diff .diff-addedline { 1362 background-color: #dfd; 1368 background-color: #e9f6ea; 1369 color: #00a500; 1370 } 1371 1372 table.diff .diff-addedline-symbol { 1373 color: #00a500; 1363 1374 } 1364 1375 -
trunk/wp-admin/css/wp-admin.css
r23504 r23506 3505 3505 3506 3506 table.diff col.content { 3507 width: 50%; 3507 width: auto; 3508 } 3509 3510 table.diff col.content.diffsplit { 3511 width: 48%; 3512 } 3513 3514 table.diff col.diffsplit.middle { 3515 width: 4%; 3516 } 3517 3518 table.diff col.ltype { 3519 width: 30px; 3508 3520 } 3509 3521 … … 8809 8821 margin-left: 8em; 8810 8822 } 8823 8824 #revisions-meta-mostrecent, 8825 #revisions-meta-stored, 8826 #revisions-meta-oldest, 8827 #revisions-meta-link { 8828 line-height: 30px; 8829 height: 30px; 8830 vertical-align: middle; 8831 padding-right: 10px; 8832 } 8833 #revisions-meta-mostrecent img, 8834 #revisions-meta-oldest img { 8835 vertical-align: middle; 8836 } -
trunk/wp-admin/edit-form-advanced.php
r23456 r23506 169 169 } 170 170 171 if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) 171 // TODO review this count() - why do we need to add it? 172 if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && count ( wp_get_post_revisions( $post_ID ) ) > 1 ) 172 173 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); 173 174 -
trunk/wp-admin/includes/ajax-actions.php
r23484 r23506 1380 1380 1381 1381 check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); 1382 1382 1383 1383 $post_data = wp_unslash( $_POST ); 1384 1384 … … 2135 2135 } 2136 2136 2137 function wp_ajax_revisions_data() { 2138 check_ajax_referer( 'revisions-ajax-nonce', 'nonce' ); 2139 2140 $compareto = isset( $_GET['compareto'] ) ? absint( $_GET['compareto'] ) : 0; 2141 $showautosaves = isset( $_GET['showautosaves'] ) ? $_GET['showautosaves'] : ''; 2142 $show_split_view = isset( $_GET['show_split_view'] ) ? $_GET['show_split_view'] : ''; 2143 $postid = isset( $_GET['postid'] ) ? absint( $_GET['postid'] ) : ''; 2144 2145 $comparetwomode = ( '' == $postid ) ? false : true; 2146 // 2147 //TODO: currently code returns all possible comparisons for the indicated 'compareto' revision 2148 //however, the front end prevents users from pulling the right handle past the left or the left pass the right, 2149 //so only the possible diffs need be generated 2150 // 2151 $alltherevisions = array(); 2152 2153 if ( '' == $postid ) 2154 $postid = $compareto; 2155 2156 if ( ! current_user_can( 'read_post', $postid ) ) 2157 continue; 2158 2159 if ( ! $revisions = wp_get_post_revisions( $postid ) ) 2160 return; 2161 2162 //if we are comparing two revisions, the first 'revision' represented by the leftmost 2163 //slider position is the current revision, prepend a comparison to this revision 2164 if ( $comparetwomode ) 2165 array_unshift( $revisions, get_post( $postid ) ); 2166 2167 $count = 1; 2168 foreach ( $revisions as $revision ) : 2169 if ( 'true' != $showautosaves && wp_is_post_autosave( $revision ) ) 2170 continue; 2171 2172 $revision_from_date_author = ''; 2173 2174 2175 $left_revision = get_post( $compareto ); 2176 $right_revision = get_post( $revision ); 2177 2178 $author = get_the_author_meta( 'display_name', $revision->post_author ); 2179 /* translators: revision date format, see http://php.net/date */ 2180 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 2181 2182 $gravatar = get_avatar( $revision->post_author, 18 ); 2183 2184 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 2185 $revision_date_author = sprintf( 2186 '%s %s, %s %s (%s)', 2187 $gravatar, 2188 $author, 2189 human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ), 2190 __( ' ago ' ), 2191 $date 2192 ); 2193 2194 if ( $comparetwomode ) { 2195 $compareto_gravatar = get_avatar( $left_revision->post_author, 18 ); 2196 $compareto_author = get_the_author_meta( 'display_name', $left_revision->post_author ); 2197 $compareto_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) ); 2198 2199 $revision_from_date_author = sprintf( 2200 '%s %s, %s %s (%s)', 2201 $compareto_gravatar, 2202 $compareto_author, 2203 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ), 2204 __( ' ago ' ), 2205 $compareto_date 2206 ); 2207 } 2208 2209 $restoreaction = wp_nonce_url( 2210 add_query_arg( 2211 array( 'revision' => $revision->ID, 2212 'action' => 'restore' ), 2213 '/wp-admin/revision.php' 2214 ), 2215 "restore-post_{$compareto}|{$revision->ID}" 2216 ); 2217 2218 // 2219 //make sure the left revision is the most recent 2220 // 2221 if ( strtotime( $right_revision->post_modified_gmt ) < strtotime( $left_revision->post_modified_gmt ) ) { 2222 $temp = $left_revision; 2223 $left_revision = $right_revision; 2224 $right_revision = $temp; 2225 } 2226 2227 // 2228 //compare from left to right, passed from application 2229 // 2230 $content=''; 2231 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 2232 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' ); 2233 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' ); 2234 2235 add_filter( "_wp_post_revision_field_$field", 'wp_kses_post' ); 2236 2237 $args = array(); 2238 2239 if ( 'true' == $show_split_view ) 2240 $args = array( 'show_split_view' => 'true' ); 2241 2242 $content .= wp_text_diff( $left_content, $right_content, $args ); 2243 } 2244 2245 //if we are comparing two revisions 2246 //and we are on the matching revision 2247 //add an error revision indicating unable to compare to self 2248 if ( $comparetwomode && $compareto == $revision->ID ) 2249 $alltherevisions[] = array ( 2250 'ID' => $revision->ID, 2251 'revision_date_author' => $revision_date_author, 2252 'revisiondiff' => sprintf('<div id="selfcomparisonerror">%s</div>', __( 'Cannot compare revision to itself' ) ), 2253 'restoreaction' => urldecode( $restoreaction ), 2254 'revision_from_date_author' => '' 2255 ); 2256 2257 //add to the return data only if there is a difference 2258 if ( '' != $content ) 2259 $alltherevisions[] = array ( 2260 'ID' => $revision->ID, 2261 'revision_date_author' => $revision_date_author, 2262 'revisiondiff' => $content, 2263 'restoreaction' => urldecode( $restoreaction ), 2264 'revision_from_date_author' => $revision_from_date_author 2265 ); 2266 2267 endforeach; 2268 2269 echo json_encode( $alltherevisions ); 2270 exit(); 2271 } -
trunk/wp-admin/revision.php
r23404 r23506 9 9 /** WordPress Administration Bootstrap */ 10 10 require_once('./admin.php'); 11 12 wp_enqueue_script('list-revisions'); 13 14 wp_reset_vars(array('revision', 'left', 'right', 'action')); 11 wp_reset_vars( array( 'revision', 'action' ) ); 15 12 16 13 $revision_id = absint($revision); 17 $left = absint($left);18 $right = absint($right);19 20 14 $redirect = 'edit.php'; 21 15 … … 34 28 break; 35 29 } 36 37 check_admin_referer( "restore-post_$post->ID|$revision->ID" ); 30 check_admin_referer( "restore-post_{$post->ID}|{$revision->ID}" ); 38 31 39 32 wp_restore_post_revision( $revision->ID ); 40 33 $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); 41 34 break; 42 case 'diff' :43 if ( !$left_revision = get_post( $left ) )44 break;45 if ( !$right_revision = get_post( $right ) )46 break;47 48 if ( !current_user_can( 'read_post', $left_revision->ID ) || !current_user_can( 'read_post', $right_revision->ID ) )49 break;50 51 // If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post52 if ( $left_revision->ID == $right_revision->ID ) {53 $redirect = get_edit_post_link( $left_revision->ID );54 include( './js/revisions-js.php' );55 break;56 }57 58 // Don't allow reverse diffs?59 if ( strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt) ) {60 $redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );61 break;62 }63 64 if ( $left_revision->ID == $right_revision->post_parent ) // right is a revision of left65 $post =& $left_revision;66 elseif ( $left_revision->post_parent == $right_revision->ID ) // left is a revision of right67 $post =& $right_revision;68 elseif ( $left_revision->post_parent == $right_revision->post_parent ) // both are revisions of common parent69 $post = get_post( $left_revision->post_parent );70 else71 break; // Don't diff two unrelated revisions72 73 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled74 if (75 // we're not looking at an autosave76 ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )77 ||78 // we're not comparing an autosave to the current post79 ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID )80 ) {81 $redirect = 'edit.php?post_type=' . $post->post_type;82 break;83 }84 }85 86 if (87 // They're the same88 $left_revision->ID == $right_revision->ID89 ||90 // Neither is a revision91 ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )92 )93 break;94 95 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';96 $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title );97 $title = __( 'Revisions' );98 99 $left = $left_revision->ID;100 $right = $right_revision->ID;101 102 $redirect = false;103 break;104 35 case 'view' : 36 case 'edit' : 105 37 default : 106 38 if ( !$revision = wp_get_post_revision( $revision_id ) ) … … 120 52 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; 121 53 $revision_title = wp_post_revision_title( $revision, false ); 122 $h2 = sprintf( __( ' Revision for “%1$s” created on %2$s' ), $post_title, $revision_title );54 $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); 123 55 $title = __( 'Revisions' ); 124 125 // Sets up the diff radio buttons126 $left = $revision->ID;127 $right = $post->ID;128 56 129 57 $redirect = false; … … 146 74 $parent_file = $submenu_file = 'edit.php'; 147 75 76 wp_enqueue_style( 'revisions' ); 77 wp_enqueue_script( 'revisions' ); 78 148 79 require_once( './admin-header.php' ); 149 80 81 //TODO - Some of the translations below split things into multiple strings that are contextually related and this makes it pretty impossible for RTL translation. 82 //TODO can we pass the context in a better way 150 83 ?> 84 <script type="text/javascript"> 85 var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>; 86 </script> 151 87 88 <div id="backbonerevisionsoptions"></div> 89 90 <br class="clear"/> 152 91 <div class="wrap"> 153 154 <h2 class="long-header"><?php echo $h2; ?></h2> 155 156 <table class="form-table ie-fixed"> 157 <col class="th" /> 158 <?php if ( 'diff' == $action ) : ?> 159 <tr id="revision"> 160 <th scope="row"></th> 161 <th scope="col" class="th-full"> 162 <span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?></span> 163 <span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?></span> 164 </th> 165 </tr> 166 <?php endif; 167 168 // use get_post_to_edit filters? 169 $identical = true; 170 foreach ( _wp_post_revision_fields() as $field => $field_title ) : 171 if ( 'diff' == $action ) { 172 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' ); 173 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' ); 174 if ( !$content = wp_text_diff( $left_content, $right_content ) ) 175 continue; // There is no difference between left and right 176 $identical = false; 177 } else { 178 add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' ); 179 $content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field, $revision, '' ); 180 } 181 ?> 182 183 <tr id="revision-field-<?php echo $field; ?>"> 184 <th scope="row"><?php echo esc_html( $field_title ); ?></th> 185 <td><div class="pre"><?php echo $content; ?></div></td> 186 </tr> 187 188 <?php 189 190 endforeach; 191 192 if ( 'diff' == $action && $identical ) : 193 194 ?> 195 196 <tr><td colspan="2"><div class="updated"><p><?php _e( 'These revisions are identical.' ); ?></p></div></td></tr> 197 198 <?php 199 200 endif; 201 92 <div class="icon32 icon32-posts-post" id="icon-edit"><br></div> 93 <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading"> 94 <div id="modelsloading" class="updated message"><span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?></div> 95 <h2 class="long-header"><?php echo $h2; ?></h2> 96 <div id="backbonerevisionsinteract"></div> 97 <div id="backbonerevisionsdiff"></div> 98 <hr /> 99 <?php 100 $comparetworevisionslink = get_edit_post_link( $revision->ID ); 202 101 ?> 203 204 </table> 205 206 <br class="clear" /> 207 208 <h3><?php echo $title; ?></h3> 209 210 <?php 211 212 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); 213 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) 214 $args['type'] = 'autosave'; 215 216 wp_list_post_revisions( $post, $args ); 217 218 ?> 219 102 </div> 220 103 </div> 221 104 105 <script id="tmpl-revision" type="text/html"> 106 <div id="diffsubheader"> 107 <span id="diff_from_current_revision"><?php _e( 'Current version' ); ?><?php _e( '- compared to -' ); ?></span> 108 <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div> 109 <div id="difftitle">{{{ data.revision_date_author }}}</div> 110 <div id="diffcancel"><input class="button" onClick="document.location='<?php echo get_edit_post_link( $post->ID ); ?>'" type="submit" id="cancel" value="<?php esc_attr_e( 'Cancel' )?>" /></div> 111 <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore' )?>" /></div> 112 <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <?php esc_attr_e( 'Compare two revisions' )?></div> 113 </div> 114 <div id="removedandadded"> 115 <div id="removed"><?php _e( 'Removed -' ); ?></div> 116 <div id="added"><?php _e( 'Added +' ); ?></div> 117 </div 118 <div>{{{ data.revisiondiff }}}</div> 119 </script> 120 121 <script id="tmpl-revisionvinteract" type="text/html"> 122 <div id="diffheader"> 123 <div id="diffprevious"><input class="button" type="submit" id="previous" value="Previous" /></div> 124 <div id="diffnext"><input class="button" type="submit" id="next" value="Next" /></div> 125 <div id="diffslider"> 126 <div id="revisioncount"> 127 <?php _e( 'Comparing' ); ?> 128 <span id="diff_left_count"> <?php _e( 'revision' ); ?></span> <span id="diff_left_count_inner"></span> 129 <span id="diff_left_current_revision"><?php _e( 'current version' ); ?></span> 130 <span id="diff_revision_from">{{{ data.diff_revision_from }}}</span> 131 <?php _e( ' to revision' ); ?> 132 <span id="diff_count">{{{ data.current_diff }}}</span> 133 <?php _e( ' of ' ); ?> 134 <span id="diff_max" ></span> 135 </div> 136 137 <div id="slider"></div> 138 </div> 139 </div> 140 </script> 222 141 <?php 142 /* 143 TODO Convert these into screen options 144 <script id="tmpl-revisionoptions" type="text/html"> 145 <div id="revisionoptions"> 146 <div id="showsplitviewoption"> 147 <input type='checkbox' id="show_split_view" checked="checked" value="1" /> <?php _e( 'Show split diff view' ); ?> 148 </div> 149 <div id="toggleshowautosavesoption"> 150 <input type='checkbox' id="toggleshowautosaves" value="1" /> <?php _e( 'Show autosaves' ); ?> 151 </div> 152 </div> 153 </script> 154 */ 223 155 require_once( './admin-footer.php' ); -
trunk/wp-includes/pluggable.php
r23416 r23506 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 … … 1723 1722 1724 1723 $r = "<table class='diff'>\n"; 1725 $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />"; 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 } 1726 1730 1727 1731 if ( $args['title'] || $args['title_left'] || $args['title_right'] ) -
trunk/wp-includes/post-template.php
r23416 r23506 1301 1301 return false; 1302 1302 1303 $author = get_the_author_meta( 'display_name', $revision->post_author ); 1303 1304 /* translators: revision date format, see http://php.net/date */ 1304 $datef = _x( 'j F, Y @ G:i', 'revision date format'); 1305 /* translators: 1: date */ 1306 $autosavef = __( '%1$s [Autosave]' ); 1307 /* translators: 1: date */ 1308 $currentf = __( '%1$s [Current Revision]' ); 1305 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 1306 1307 $gravatar = get_avatar( $revision->post_author, 18 ); 1309 1308 1310 1309 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 1311 1310 if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) 1312 1311 $date = "<a href='$link'>$date</a>"; 1312 1313 $revision_date_author = sprintf( 1314 '%s %s, %s %s (%s)', 1315 $gravatar, 1316 $author, 1317 human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ), 1318 __( 'ago' ), 1319 $date 1320 ); 1321 1322 $autosavef = __( '%1$s [Autosave]' ); 1323 $currentf = __( '%1$s [Current Revision]' ); 1313 1324 1314 1325 if ( !wp_is_post_revision( $revision ) ) 1315 $ date = sprintf( $currentf, $date);1326 $revision_date_author = sprintf( $currentf, $revision_date_author ); 1316 1327 elseif ( wp_is_post_autosave( $revision ) ) 1317 $ date = sprintf( $autosavef, $date);1318 1319 return $ date;1328 $revision_date_author = sprintf( $autosavef, $revision_date_author ); 1329 1330 return $revision_date_author; 1320 1331 } 1321 1332 -
trunk/wp-includes/script-loader.php
r23487 r23506 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 ); 275 276 $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'backbone', 'jquery-ui-slider' ), false, 1 ); 274 277 275 278 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 ); … … 540 543 $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons' ) ); 541 544 $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); 545 $styles->add( 'wp-jquery-ui-slider', "/wp-includes/css/jquery-ui-slider$suffix.css" ); 546 $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css", array( 'wp-jquery-ui-slider' ) ); 542 547 543 548 foreach ( $rtl_styles as $rtl_style ) { -
trunk/wp-includes/wp-diff.php
r22118 r23506 61 61 62 62 /** 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 /** 63 72 * Constructor - Call parent constructor with params array. 64 73 * … … 71 80 function __construct( $params = array() ) { 72 81 parent::__construct( $params ); 82 if ( isset( $params[ 'show_split_view' ] ) ) 83 $this->_show_split_view = $params[ 'show_split_view' ]; 73 84 } 74 85 … … 99 110 */ 100 111 function addedLine( $line ) { 101 return "<td>+</td><td class='diff-addedline'>{$line}</td>"; 112 return "<td class='diff-addedline'>{$line}</td>"; 113 102 114 } 103 115 … … 109 121 */ 110 122 function deletedLine( $line ) { 111 return "<td >-</td><tdclass='diff-deletedline'>{$line}</td>";123 return "<td class='diff-deletedline'>{$line}</td>"; 112 124 } 113 125 … … 119 131 */ 120 132 function contextLine( $line ) { 121 return "<td > </td><tdclass='diff-context'>{$line}</td>";133 return "<td class='diff-context'>{$line}</td>"; 122 134 } 123 135 … … 128 140 */ 129 141 function emptyLine() { 130 return '<td colspan="2"> </td>';142 return '<td> </td>'; 131 143 } 132 144 … … 143 155 foreach ($lines as $line) { 144 156 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 } 147 163 } 148 164 return $r; … … 161 177 foreach ($lines as $line) { 162 178 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 165 186 } 166 187 return $r; … … 179 200 foreach ($lines as $line) { 180 201 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 } 184 208 } 185 209 return $r; … … 265 289 $r .= $this->_deleted( array($orig_line), false ); 266 290 } 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 } 268 296 } 269 297 }
Note: See TracChangeset
for help on using the changeset viewer.