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-activity/bp-activity-templatetags.php

    r3214 r3245  
    2020
    2121        $this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : $page;
    22         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    23 
    24         /* Check if blog/forum replies are disabled */
     22        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     23
     24        // Check if blog/forum replies are disabled
    2525        $this->disable_blogforum_replies = $bp->site_options['bp-disable-blogforum-comments'];
    2626
    27         /* Get an array of the logged in user's favorite activities */
     27        // Get an array of the logged in user's favorite activities
    2828        $this->my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) );
    2929
    30         if ( !empty( $include ) ) {
    31             /* Fetch specific activity items based on ID's */
     30        // Fetch specific activity items based on ID's
     31        if ( !empty( $include ) )
    3232            $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments ) );
    33         } else {
     33        // Fetch all activity items
     34        else
    3435            $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 ) );
    35         }
    3636
    3737        if ( !$max || $max >= (int)$this->activities['total'] )
     
    4343
    4444        if ( $max ) {
    45             if ( $max >= count($this->activities) )
    46                 $this->activity_count = count($this->activities);
    47             else
     45            if ( $max >= count($this->activities) ) {
     46                $this->activity_count = count( $this->activities );
     47            } else {
    4848                $this->activity_count = (int)$max;
     49            }
    4950        } else {
    50             $this->activity_count = count($this->activities);
     51            $this->activity_count = count( $this->activities );
    5152        }
    5253
    5354        $this->full_name = $bp->displayed_user->fullname;
    5455
    55         /* Fetch parent content for activity comments so we do not have to query in the loop */
     56        // Fetch parent content for activity comments so we do not have to query in the loop
    5657        foreach ( (array)$this->activities as $activity ) {
    57             if ( 'activity_comment' != $activity->type ) continue;
     58            if ( 'activity_comment' != $activity->type )
     59                continue;
     60
    5861            $parent_ids[] = $activity->item_id;
    5962        }
     
    6366
    6467        if ( !empty( $activity_parents['activities'] ) ) {
    65             foreach( $activity_parents['activities'] as $parent ) $this->activity_parents[$parent->id] = $parent;
     68            foreach( $activity_parents['activities'] as $parent )
     69                $this->activity_parents[$parent->id] = $parent;
     70
    6671            unset( $activity_parents );
    6772        }
    6873
    69         if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
     74        if ( (int)$this->total_activity_count && (int)$this->pag_num ) {
    7075            $this->pag_links = paginate_links( array(
    71                 'base' => add_query_arg( 'acpage', '%#%' ),
    72                 'format' => '',
    73                 'total' => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
    74                 'current' => (int)$this->pag_page,
     76                'base'      => add_query_arg( 'acpage', '%#%' ),
     77                'format'    => '',
     78                'total'     => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
     79                'current'   => (int)$this->pag_page,
    7580                'prev_text' => '←',
    7681                'next_text' => '→',
    77                 'mid_size' => 1
    78             ));
     82                'mid_size'  => 1
     83            ) );
    7984        }
    8085    }
Note: See TracChangeset for help on using the changeset viewer.