Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/10/2010 08:12:08 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Clean-up pagination in all components. Fixes #2625. Props BenFremer on your first trac ticket!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-messages/bp-messages-templatetags.php

    r3206 r3245  
    2222    function bp_messages_box_template( $user_id, $box, $per_page, $max, $type ) {
    2323        $this->pag_page = isset( $_GET['mpage'] ) ? intval( $_GET['mpage'] ) : 1;
    24         $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
    25 
    26         $this->user_id = $user_id;
    27         $this->box = $box;
    28         $this->type = $type;
    29 
    30         if ( 'notices' == $this->box )
     24        $this->pag_num  = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
     25
     26        $this->user_id  = $user_id;
     27        $this->box      = $box;
     28        $this->type     = $type;
     29
     30        if ( 'notices' == $this->box ) {
    3131            $this->threads = BP_Messages_Notice::get_notices();
    32         else {
     32        } else {
    3333            $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page );
    3434
    35             $this->threads = $threads['threads'];
     35            $this->threads            = $threads['threads'];
    3636            $this->total_thread_count = $threads['total'];
    3737        }
    3838
    3939        if ( !$this->threads ) {
    40             $this->thread_count = 0;
     40            $this->thread_count       = 0;
    4141            $this->total_thread_count = 0;
    4242        } else {
     
    4444
    4545            if ( !$max || $max >= (int)$total_notice_count ) {
    46                 if ( 'notices' == $this->box )
     46                if ( 'notices' == $this->box ) {
    4747                    $this->total_thread_count = (int)$total_notice_count;
     48                }
    4849            } else {
    4950                $this->total_thread_count = (int)$max;
     
    5152
    5253            if ( $max ) {
    53                 if ( $max >= count($this->threads) )
     54                if ( $max >= count($this->threads) ) {
    5455                    $this->thread_count = count($this->threads);
    55                 else
     56                } else {
    5657                    $this->thread_count = (int)$max;
     58                }
    5759            } else {
    5860                $this->thread_count = count($this->threads);
     
    6062        }
    6163
    62         $this->pag_links = paginate_links( array(
    63             'base' => add_query_arg( 'mpage', '%#%' ),
    64             'format' => '',
    65             'total' => ceil($this->total_thread_count / $this->pag_num),
    66             'current' => $this->pag_page,
    67             'prev_text' => '←',
    68             'next_text' => '→',
    69             'mid_size' => 1
    70         ));
     64        if ( (int)$this->total_topic_count && (int)$this->pag_num ) {
     65            $this->pag_links = paginate_links( array(
     66                'base'      => add_query_arg( 'mpage', '%#%' ),
     67                'format'    => '',
     68                'total'     => ceil( (int)$this->total_thread_count / (int)$this->pag_num ),
     69                'current'   => $this->pag_page,
     70                'prev_text' => '←',
     71                'next_text' => '→',
     72                'mid_size'  => 1
     73            ) );
     74        }
    7175    }
    7276
Note: See TracChangeset for help on using the changeset viewer.