Skip to:
Content

BuddyPress.org

Changeset 3247


Ignore:
Timestamp:
09/10/2010 09:49:11 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Fixes #2625 (trunk)

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-templatetags.php

    r3232 r3247  
    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_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
    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        else
    3434            $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         }
    3635
    3736        if ( !$max || $max >= (int)$this->activities['total'] )
     
    4342
    4443        if ( $max ) {
    45             if ( $max >= count($this->activities) )
    46                 $this->activity_count = count($this->activities);
    47             else
     44            if ( $max >= count($this->activities) ) {
     45                $this->activity_count = count( $this->activities );
     46            } else {
    4847                $this->activity_count = (int)$max;
     48            }
    4949        } else {
    50             $this->activity_count = count($this->activities);
     50            $this->activity_count = count( $this->activities );
    5151        }
    5252
    5353        $this->full_name = $bp->displayed_user->fullname;
    5454
    55         /* Fetch parent content for activity comments so we do not have to query in the loop */
     55        // Fetch parent content for activity comments so we do not have to query in the loop
    5656        foreach ( (array)$this->activities as $activity ) {
    57             if ( 'activity_comment' != $activity->type ) continue;
     57            if ( 'activity_comment' != $activity->type )
     58                continue;
     59
    5860            $parent_ids[] = $activity->item_id;
    5961        }
     
    6365
    6466        if ( !empty( $activity_parents['activities'] ) ) {
    65             foreach( $activity_parents['activities'] as $parent ) $this->activity_parents[$parent->id] = $parent;
     67            foreach( $activity_parents['activities'] as $parent )
     68                $this->activity_parents[$parent->id] = $parent;
     69
    6670            unset( $activity_parents );
    6771        }
    6872
    69         if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
     73        if ( (int)$this->total_activity_count && (int)$this->pag_num ) {
    7074            $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,
     75                'base'      => add_query_arg( 'acpage', '%#%' ),
     76                'format'    => '',
     77                'total'     => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
     78                'current'   => (int)$this->pag_page,
    7579                'prev_text' => '←',
    7680                'next_text' => '→',
    77                 'mid_size' => 1
    78             ));
     81                'mid_size'  => 1
     82            ) );
    7983        }
    8084    }
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r3232 r3247  
    2222
    2323        $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : $page;
    24         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     24        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    2525
    2626        if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
     
    3737
    3838        if ( $max ) {
    39             if ( $max >= count($this->blogs) )
    40                 $this->blog_count = count($this->blogs);
    41             else
     39            if ( $max >= count( $this->blogs ) ) {
     40                $this->blog_count = count( $this->blogs );
     41            } else {
    4242                $this->blog_count = (int)$max;
     43            }
    4344        } else {
    44             $this->blog_count = count($this->blogs);
    45         }
    46 
    47         $this->pag_links = paginate_links( array(
    48             'base' => add_query_arg( 'bpage', '%#%' ),
    49             'format' => '',
    50             'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
    51             'current' => (int) $this->pag_page,
    52             'prev_text' => '←',
    53             'next_text' => '→',
    54             'mid_size' => 1
    55         ));
     45            $this->blog_count = count( $this->blogs );
     46        }
     47
     48        if ( (int)$this->total_blog_count && (int)$this->pag_num ) {
     49            $this->pag_links = paginate_links( array(
     50                'base'      => add_query_arg( 'bpage', '%#%' ),
     51                'format'    => '',
     52                'total'     => ceil( (int)$this->total_blog_count / (int)$this->pag_num ),
     53                'current'   => (int)$this->pag_page,
     54                'prev_text' => '←',
     55                'next_text' => '→',
     56                'mid_size'  => 1
     57            ) );
     58        }
    5659    }
    5760
  • trunk/bp-core/bp-core-templatetags.php

    r3239 r3247  
    2222
    2323        $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : $page_number;
    24         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    25         $this->type = $type;
    26 
    27         if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
     24        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     25        $this->type     = $type;
     26
     27        if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
    2828            $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras );
    29         }
    30         else if ( false !== $include ) {
     29        else if ( false !== $include )
    3130            $this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras );
    32         }
    33         else {
     31        else
    3432            $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
    35         }
    3633
    3734        if ( !$max || $max >= (int)$this->members['total'] )
     
    4340
    4441        if ( $max ) {
    45             if ( $max >= count($this->members) )
    46                 $this->member_count = count($this->members);
    47             else
     42            if ( $max >= count( $this->members ) ) {
     43                $this->member_count = count( $this->members );
     44            } else {
    4845                $this->member_count = (int)$max;
     46            }
    4947        } else {
    50             $this->member_count = count($this->members);
     48            $this->member_count = count( $this->members );
    5149        }
    5250
    53         if ( (int) $this->total_member_count && (int) $this->pag_num ) {
     51        if ( (int)$this->total_member_count && (int)$this->pag_num ) {
    5452            $this->pag_links = paginate_links( array(
    55                 'base' => add_query_arg( 'upage', '%#%' ),
    56                 'format' => '',
    57                 'total' => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
    58                 'current' => (int) $this->pag_page,
     53                'base'      => add_query_arg( 'upage', '%#%' ),
     54                'format'    => '',
     55                'total'     => ceil( (int)$this->total_member_count / (int)$this->pag_num ),
     56                'current'   => (int) $this->pag_page,
    5957                'prev_text' => '←',
    6058                'next_text' => '→',
    61                 'mid_size' => 1
    62             ));
     59                'mid_size'   => 1
     60            ) );
    6361        }
    6462    }
  • trunk/bp-forums/bp-forums-templatetags.php

    r3232 r3247  
    2222        global $bp;
    2323
    24         $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page;
    25         $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
    26         $this->type = $type;
     24        $this->pag_page     = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page;
     25        $this->pag_num      = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
     26        $this->type         = $type;
    2727        $this->search_terms = $search_terms;
    2828
     
    6666
    6767            if ( $max ) {
    68                 if ( $max >= count($this->topics) )
     68                if ( $max >= count( $this->topics ) ) {
    6969                    $this->topic_count = count( $this->topics );
    70                 else
     70                } else {
    7171                    $this->topic_count = (int)$max;
     72                }
    7273            } else {
    7374                $this->topic_count = count( $this->topics );
     
    7576        }
    7677
    77         $this->topic_count = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
     78        $this->topic_count       = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
    7879        $this->total_topic_count = apply_filters( 'bp_forums_template_total_topic_count', $this->total_topic_count, $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
    7980
    80         if ( !$no_stickies) {
    81             /* Place stickies at the top - not sure why bbPress doesn't do this? */
     81        if ( !$no_stickies ) {
     82            // Place stickies at the top - not sure why bbPress doesn't do this?
    8283            foreach( (array)$this->topics as $topic ) {
    83                 if ( 1 == (int)$topic->topic_sticky )
     84                if ( 1 == (int)$topic->topic_sticky ) {
    8485                    $stickies[] = $topic;
    85                 else
     86                } else {
    8687                    $standard[] = $topic;
     88                }
    8789            }
     90
    8891            $this->topics = array_merge( (array)$stickies, (array)$standard );
    8992        }
    9093
    91         /* Fetch extra information for topics, so we don't have to query inside the loop */
     94        // Fetch extra information for topics, so we don't have to query inside the loop
    9295        $this->topics = bp_forums_get_topic_extras( &$this->topics );
    9396
    94         $this->pag_links = paginate_links( array(
    95             'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ),
    96             'format' => '',
    97             'total' => ceil($this->total_topic_count / $this->pag_num),
    98             'current' => $this->pag_page,
    99             'prev_text' => '←',
    100             'next_text' => '→',
    101             'mid_size' => 1
    102         ));
     97        if ( (int)$this->total_topic_count && (int)$this->pag_num ) {
     98            $this->pag_links = paginate_links( array(
     99                'base'      => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ),
     100                'format'    => '',
     101                'total'     => ceil( (int)$this->total_topic_count / (int)$this->pag_num ),
     102                'current'   => $this->pag_page,
     103                'prev_text' => '←',
     104                'next_text' => '→',
     105                'mid_size'  => 1
     106            ) );
     107        }
    103108    }
    104109
     
    710715        global $bp, $current_user, $forum_template;
    711716
    712         $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
    713         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    714 
    715         $this->topic_id = $topic_id;
     717        $this->pag_page        = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
     718        $this->pag_num         = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     719
     720        $this->order           = $order;
     721        $this->topic_id        = $topic_id;
    716722        $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
    717723
    718         $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) );
     724        $this->posts           = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'order' => $this->order ) );
    719725
    720726        if ( !$this->posts ) {
     
    722728            $this->total_post_count = 0;
    723729        } else {
    724             if ( !$max || $max >= (int) $forum_template->topic->topic_posts )
     730            if ( !$max || $max >= (int) $forum_template->topic->topic_posts ) {
    725731                $this->total_post_count = (int) $forum_template->topic->topic_posts;
    726             else
     732            } else {
    727733                $this->total_post_count = (int)$max;
     734            }
    728735
    729736            if ( $max ) {
    730                 if ( $max >= count($this->posts) )
     737                if ( $max >= count( $this->posts ) ) {
    731738                    $this->post_count = count( $this->posts );
    732                 else
     739                } else {
    733740                    $this->post_count = (int)$max;
     741                }
    734742            } else {
    735743                $this->post_count = count( $this->posts );
     
    737745        }
    738746
    739         $this->pag_links = paginate_links( array(
    740             'base' => add_query_arg( array( 'topic_page' => '%#%', 'num' => $this->pag_num ) ),
    741             'format' => '',
    742             'total' => ceil($this->total_post_count / $this->pag_num),
    743             'current' => $this->pag_page,
    744             'prev_text' => '←',
    745             'next_text' => '→',
    746             'mid_size' => 1
    747         ));
    748         $this->pag->total_pages = ceil($this->total_post_count / $this->pag_num);
     747        if ( (int)$this->total_post_count && (int)$this->pag_num ) {
     748            $this->pag_links = paginate_links( array(
     749                'base'      => add_query_arg( array( 'topic_page' => '%#%', 'num' => (int)$this->pag_num ) ),
     750                'format'    => '',
     751                'total'     => ceil( (int)$this->total_post_count / (int)$this->pag_num ),
     752                'current'   => $this->pag_page,
     753                'prev_text' => '←',
     754                'next_text' => '→',
     755                'mid_size'  => 1
     756            ) );
     757
     758            $this->pag->total_pages = ceil( (int)$this->total_post_count / (int)$this->pag_num );
     759        } else {
     760            $this->pag->total_pages = 1;
     761        }
    749762    }
    750763
  • trunk/bp-groups/bp-groups-templatetags.php

    r3232 r3247  
    2424
    2525        $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page;
    26         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    27 
    28         if ( 'invites' == $type )
     26        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     27
     28        if ( 'invites' == $type ) {
    2929            $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page );
    30         else if ( 'single-group' == $type ) {
     30        } else if ( 'single-group' == $type ) {
    3131            $group = new stdClass;
    3232            $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
    33             $this->groups = array( $group );
    34         } else
     33            $this->groups    = array( $group );
     34        } else {
    3535            $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'include' => $include, 'populate_extras' => $populate_extras ) );
     36        }
    3637
    3738        if ( 'invites' == $type ) {
    3839            $this->total_group_count = (int)$this->groups['total'];
    39             $this->group_count = (int)$this->groups['total'];
     40            $this->group_count       = (int)$this->groups['total'];
     41            $this->groups            = $this->groups['groups'];
     42        } else if ( 'single-group' == $type ) {
     43            $this->single_group      = true;
     44            $this->total_group_count = 1;
     45            $this->group_count       = 1;
     46        } else {
     47            if ( !$max || $max >= (int)$this->groups['total'] ) {
     48                $this->total_group_count = (int)$this->groups['total'];
     49            } else {
     50                $this->total_group_count = (int)$max;
     51            }
     52
    4053            $this->groups = $this->groups['groups'];
    41         } else if ( 'single-group' == $type ) {
    42             $this->single_group = true;
    43             $this->total_group_count = 1;
    44             $this->group_count = 1;
    45         } else {
    46             if ( !$max || $max >= (int)$this->groups['total'] )
    47                 $this->total_group_count = (int)$this->groups['total'];
    48             else
    49                 $this->total_group_count = (int)$max;
    50 
    51             $this->groups = $this->groups['groups'];
    5254
    5355            if ( $max ) {
    54                 if ( $max >= count($this->groups) )
    55                     $this->group_count = count($this->groups);
    56                 else
     56                if ( $max >= count( $this->groups ) ) {
     57                    $this->group_count = count( $this->groups );
     58                } else {
    5759                    $this->group_count = (int)$max;
     60                }
    5861            } else {
    59                 $this->group_count = count($this->groups);
     62                $this->group_count = count( $this->groups );
    6063            }
    6164        }
    6265
    63         $this->pag_links = paginate_links( array(
    64             'base' => add_query_arg( array( 'grpage' => '%#%' ) ),
    65             'format' => '',
    66             'total' => ceil($this->total_group_count / $this->pag_num),
    67             'current' => $this->pag_page,
    68             'prev_text' => '←',
    69             'next_text' => '→',
    70             'mid_size' => 1
    71         ));
     66        // Build pagination links
     67        if ( (int)$this->total_group_count && (int)$this->pag_num ) {
     68            $this->pag_links = paginate_links( array(
     69                'base'      => add_query_arg( array( 'grpage' => '%#%' ) ),
     70                'format'    => '',
     71                'total'     => ceil( (int)$this->total_group_count / (int)$this->pag_num ),
     72                'current'   => $this->pag_page,
     73                'prev_text' => '←',
     74                'next_text' => '→',
     75                'mid_size'  => 1
     76            ) );
     77        }
    7278    }
    7379
  • trunk/bp-messages/bp-messages-templatetags.php

    r3232 r3247  
    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;
     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;
    2929
    3030        if ( 'notices' == $this->box )
     
    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                     $this->thread_count = count($this->threads);
    55                 else
     54                if ( $max >= count( $this->threads ) ) {
     55                    $this->thread_count = count( $this->threads );
     56                } else {
    5657                    $this->thread_count = (int)$max;
     58                }
    5759            } else {
    58                 $this->thread_count = count($this->threads);
     60                $this->thread_count = count( $this->threads );
    5961            }
    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_thread_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.