Ticket #4045: 4045.03.diff
File 4045.03.diff, 9.5 KB (added by , 13 years ago) |
---|
-
bp-activity/bp-activity-classes.php
diff --git bp-activity/bp-activity-classes.php bp-activity/bp-activity-classes.php index 0dbea41..2fac336 100644
class BP_Activity_Activity { 136 136 'per_page' => 25, // Activity items per page 137 137 'max' => false, // Max number of items to return 138 138 'sort' => 'DESC', // ASC or DESC 139 'do_total_count' => true, 139 140 'exclude' => false, // Array of ids to exclude 140 141 'in' => false, // Array of ids to limit query by (IN) 141 142 'filter' => false, // See self::get_filter_sql() … … class BP_Activity_Activity { 227 228 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $select_sql, $from_sql, $where_sql, $sort ) ); 228 229 } 229 230 230 $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $where_sql, $sort ); 231 if ( $do_total_count && apply_filters( 'bp_activity_allow_total_count', true, $r ) ) { 232 $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $where_sql, $sort ); 231 233 232 $total_activities = $wpdb->get_var( $total_activities_sql ); 234 $total_activities = $wpdb->get_var( $total_activities_sql ); 235 } else { 236 $total_activities = -1; 237 } 233 238 234 239 // Get the fullnames of users so we don't have to query in the loop 235 240 $activity_user_ids = array(); -
bp-activity/bp-activity-functions.php
diff --git bp-activity/bp-activity-functions.php bp-activity/bp-activity-functions.php index ac7fc74..6040bf9 100644
function bp_activity_get( $args = '' ) { 794 794 'page' => 1, // page 1 without a per_page will result in no pagination. 795 795 'per_page' => false, // results per page 796 796 'sort' => 'DESC', // sort ASC or DESC 797 'do_total_count' => true, 797 798 'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item 798 799 799 800 'search_terms' => false, // Pass search terms as a string … … function bp_activity_get( $args = '' ) { 820 821 // Attempt to return a cached copy of the first page of sitewide activity. 821 822 if ( 1 == (int) $page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && empty( $exclude ) && empty( $in ) && 'DESC' == $sort && empty( $exclude ) && 'ham_only' == $spam ) { 822 823 if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) { 823 $ args = array(824 $get_args = array( 824 825 'page' => $page, 825 826 'per_page' => $per_page, 826 827 'max' => $max, 827 828 'sort' => $sort, 829 'do_total_count' => $do_total_count, 828 830 'search_terms' => $search_terms, 829 831 'filter' => $filter, 830 832 'display_comments' => $display_comments, 831 833 'show_hidden' => $show_hidden, 832 834 'spam' => $spam 833 835 ); 834 $activity = BP_Activity_Activity::get( $ args );836 $activity = BP_Activity_Activity::get( $get_args ); 835 837 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); 836 838 } 837 839 838 840 } else { 839 $ args = array(841 $get_args = array( 840 842 'page' => $page, 841 843 'per_page' => $per_page, 842 844 'max' => $max, 843 845 'sort' => $sort, 846 'do_total_count' => $do_total_count, 844 847 'search_terms' => $search_terms, 845 848 'filter' => $filter, 846 849 'display_comments' => $display_comments, … … function bp_activity_get( $args = '' ) { 849 852 'in' => $in, 850 853 'spam' => $spam 851 854 ); 852 $activity = BP_Activity_Activity::get( $ args );855 $activity = BP_Activity_Activity::get( $get_args ); 853 856 } 854 857 855 858 return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) ); -
bp-activity/bp-activity-template.php
diff --git bp-activity/bp-activity-template.php bp-activity/bp-activity-template.php index 72d4987..35b098a 100644
class BP_Activity_Template { 134 134 11 => 'spam', 135 135 12 => 'page_arg' 136 136 ); 137 137 138 138 $args = bp_core_parse_args_array( $old_args_keys, func_get_args() ); 139 139 } 140 140 141 141 $defaults = array( 142 142 'page' => 1, 143 143 'per_page' => 20, 144 144 'page_arg' => 'acpage', 145 145 'max' => false, 146 'do_total_count' => true, 146 147 'sort' => false, 147 148 'include' => false, 148 149 'exclude' => false, … … class BP_Activity_Template { 171 172 172 173 // Fetch all activity items 173 174 else 174 $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, ' sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam ) );175 $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'do_total_count' => $do_total_count, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam ) ); 175 176 176 177 if ( !$max || $max >= (int) $this->activities['total'] ) 177 178 $this->total_activity_count = (int) $this->activities['total']; … … class BP_Activity_Template { 210 211 unset( $activity_parents ); 211 212 } 212 213 213 if ( (int) $this->total_activity_count && (int) $this->pag_num ) { 214 $this->pag_links = paginate_links( array( 215 'base' => add_query_arg( $page_arg, '%#%' ), 216 'format' => '', 217 'total' => ceil( (int) $this->total_activity_count / (int) $this->pag_num ), 218 'current' => (int) $this->pag_page, 219 'prev_text' => _x( '←', 'Activity pagination previous text', 'buddypress' ), 220 'next_text' => _x( '→', 'Activity pagination next text', 'buddypress' ), 221 'mid_size' => 1 222 ) ); 214 // Pagination links 215 if ( (int) $this->pag_num ) { 216 // If the total pagination count is -1, it means that do_total_count was 217 // false, and we should use simple 'Previous | Next' pagination links 218 if ( (int) $this->total_activity_count >= 0 ) { 219 $this->pag_links = paginate_links( array( 220 'base' => add_query_arg( $page_arg, '%#%' ), 221 'format' => '', 222 'total' => ceil( (int) $this->total_activity_count / (int) $this->pag_num ), 223 'current' => (int) $this->pag_page, 224 'prev_text' => _x( '←', 'Activity pagination previous text', 'buddypress' ), 225 'next_text' => _x( '→', 'Activity pagination next text', 'buddypress' ), 226 'mid_size' => 1 227 ) ); 228 } else { 229 $this->pag_links = ''; 230 if ( (int) $this->pag_page > 1 ) { 231 $this->pag_links .= '<a href="' . add_query_arg( $page_arg, (int) $this->pag_page - 1 ) . '" class="ac-previous">' . __( 'Previous', 'buddypress' ) . '</a> | '; 232 } 233 $this->pag_links .= '<a href="' . add_query_arg( $page_arg, (int) $this->pag_page + 1 ) . '" class="ac-next">' . __( 'Next', 'buddypress' ) . '</a>'; 234 } 223 235 } 224 236 } 225 237 … … function bp_has_activities( $args = '' ) { 347 359 'max' => false, // max number to return 348 360 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide? 349 361 'spam' => 'ham_only', // Hide spammed items 362 'do_total_count' => true, // Do you need a count of total activity items matching your query? 350 363 351 364 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679 352 365 … … function bp_has_activities( $args = '' ) { 443 456 'per_page' => $per_page, 444 457 'page_arg' => $page_arg, 445 458 'max' => $max, 459 'do_total_count' => $do_total_count, 446 460 'sort' => $sort, 447 461 'include' => $include, 448 462 'exclude' => $exclude, … … function bp_activity_pagination_count() { 516 530 517 531 $start_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1; 518 532 $from_num = bp_core_number_format( $start_num ); 519 $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );520 533 $total = bp_core_number_format( $activities_template->total_activity_count ); 521 534 522 return sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ); 535 if ( (float) $total >= 0 ) { 536 $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) ); 537 $text = sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ); 538 } else { 539 $to_num = bp_core_number_format( $start_num + ( $activities_template->pag_num - 1 ) ); 540 541 $text = sprintf( __( 'Viewing item %1$s to %2$s', 'buddypress' ), $from_num, $to_num ); 542 } 543 544 return apply_filters( 'bp_get_activity_pagination_count', $text ); 523 545 } 524 546 525 547 /**