Ticket #24056: 24056-pagination.2.patch
File 24056-pagination.2.patch, 5.3 KB (added by , 12 years ago) |
---|
-
wp-admin/css/wp-admin.css
3642 3642 display: block; 3643 3643 } 3644 3644 3645 #diff-paginate { 3646 text-align: center; 3647 margin: 10px 0 0 0; 3648 } 3649 3650 #diff-paginate input { 3651 margin: 0 2px; 3652 } 3653 3645 3654 #diff-title-to strong { 3646 3655 display: none; 3647 3656 } -
wp-admin/includes/ajax-actions.php
2112 2112 $right_handle_at = ! empty( $_GET['right_handle_at'] ) ? (int) $_GET['right_handle_at'] : 0; 2113 2113 $left_handle_at = ! empty( $_GET['left_handle_at'] ) ? (int) $_GET['left_handle_at'] : 0; 2114 2114 $single_revision_id = ! empty( $_GET['single_revision_id'] ) ? absint( $_GET['single_revision_id'] ) : 0; 2115 $page_size = ! empty( $_GET['page_size'] ) ? absint( $_GET['page_size'] ) : -1; 2116 $page = ! empty( $_GET['page'] ) ? absint( $_GET['page'] ) : 1; 2115 2117 $compare_two_mode = (bool) $post_id; 2116 2118 2117 2119 $all_the_revisions = array(); … … 2121 2123 if ( ! current_user_can( 'read_post', $post_id ) ) 2122 2124 continue; 2123 2125 2124 if ( ! $revisions = wp_get_post_revisions( $post_id ) )2126 if ( ! $revisions = wp_get_post_revisions( $post_id, array( 'posts_per_page' => $page_size, 'paged' => $page ) ) ) 2125 2127 return; 2126 2128 2127 2129 $left_revision = get_post( $compare_to ); … … 2183 2185 2184 2186 $count = -1; 2185 2187 2188 // append current live revision if not on first page 2189 if( $page > 1 ) { 2190 $current = array_pop(wp_get_post_revisions( $post_id, array( 'numberposts' => 1 ) )); 2191 $revisions[$current->ID] = $current; 2192 } 2193 2186 2194 // reverse the list to start with oldest revision 2187 2195 $revisions = array_reverse( $revisions ); 2188 2196 -
wp-admin/js/revisions.js
38 38 rightModelLoading: false, // disallow slider interaction, also repeat loads, while loading 39 39 tickmarkView: null, // the slider tickmarks 40 40 slider: null, // the slider instance 41 page: null, 41 42 42 43 constructor: function() { 43 44 var self = this; … … 568 569 // next and previous buttons, only available in compare one mode 569 570 events: { 570 571 'click #next': ! isRtl ? 'nextRevision' : 'previousRevision', 571 'click #previous': ! isRtl ? 'previousRevision' : 'nextRevision' 572 'click #previous': ! isRtl ? 'previousRevision' : 'nextRevision', 573 'click .paginate': 'changePage' 572 574 }, 573 575 574 576 render: function() { … … 630 632 Diff.slider.refresh({ 631 633 value: Diff.rightDiff - 1 632 634 }, true ); 633 } 635 }, 636 637 changePage: function(e) { 638 // suppress event on disabled current page button 639 if( Diff.page == $( e.currentTarget ).data( 'id' ) ) 640 return false; 641 642 // change page 643 Diff.page = $( e.currentTarget ).data( 'id' ); 644 645 $( '.paginate' ).removeClass( 'button-disabled' ); 646 $( e.currentTarget ).addClass( 'button-disabled' ); 647 648 // single handle mode 649 if ( Diff.slider.singleRevision ) 650 Diff.reloadModelSingle(); 651 652 // compare two mode 653 else { 654 Diff.revisions.fetch({ 655 success: function() { 656 Diff.reloadLeftRight(); // load diffs for left and right handles 657 Diff.revisionView.model = Diff.rightHandleRevisions; // results in a reload of the revisionView.model 658 } 659 }); 660 } 661 } 634 662 }); 635 663 636 664 /** … … 789 817 'showSplitView': true, 790 818 'rightHandleAt': 0, 791 819 'leftHandleAt': 0, 820 'page_size' : revisions.model.settings.page_size, 792 821 'nonce': revisions.model.settings.nonce 793 822 }); 794 823 }, … … 802 831 '&show_split_view=' + this.options.showSplitView + // show in split view or single column view 803 832 '&right_handle_at=' + this.options.rightHandleAt + // mark point for comparison list 804 833 '&left_handle_at=' + this.options.leftHandleAt + // mark point for comparison list 834 '&page_size=' + this.options.page_size + 835 '&page=' + Diff.page + 805 836 '&nonce=' + this.options.nonce; 806 837 }, 807 838 -
wp-admin/revision.php
78 78 79 79 wp_enqueue_script( 'revisions' ); 80 80 81 $page_size = 50; 82 $revisions_idx = array_flip( array_keys( wp_get_post_revisions( $post->ID ) ) ); 81 83 82 84 $settings = array( 83 85 'post_id' => $post->ID, 84 86 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ), 85 'revision_id' => $revision_id 87 'revision_id' => $revision_id, 88 'page' => floor((( $revisions_idx[$revision_id] ) / $page_size))+1, 89 'page_size' => $page_size 86 90 ); 87 91 88 92 wp_localize_script( 'revisions', 'wpRevisionsSettings', $settings ); … … 172 176 </div> 173 177 174 178 <div id="diff-slider" class="wp-slider"></div> 179 180 <div id="diff-paginate"> 181 <?php 182 $pages = floor(count( $revisions_idx ) / $page_size)+1; 183 for( $i = 1; $i <= $pages; $i++ ) 184 echo '<input class="button'.( $i == $settings['page'] ? ' button-disabled' : '' ).' paginate" type="button" value="'.( ( $i - 1 ) * $page_size + 1 ) .'-'.( ( $i == $pages ) ? count( $revisions_idx ) : $i * $page_size ).'" data-id="'.$i.'" />'; 185 ?> 186 </div> 175 187 </script> 176 188 177 189 <script id="tmpl-revision-ticks" type="text/html">