Skip to:
Content

BuddyPress.org

Changeset 5891


Ignore:
Timestamp:
03/06/2012 07:15:09 AM (15 years ago)
Author:
djpaul
Message:

Allow pagination arguments for template loops to be renamed. Remove PHP4 constructors. Fixes #3679, props r-a-y and cnorris23

Location:
trunk
Files:
6 edited

Legend:

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

    r5758 r5891  
    105105        var $full_name;
    106106
    107         function __construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false, $spam = 'ham_only' ) {
     107        function __construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false, $spam = 'ham_only', $page_arg = 'acpage' ) {
    108108                global $bp;
    109109
    110                 $this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : $page;
     110                $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
    111111                $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    112112
    … …  
    164164                if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
    165165                        $this->pag_links = paginate_links( array(
    166                                 'base'      => add_query_arg( 'acpage', '%#%' ),
     166                                'base'      => add_query_arg( $page_arg, '%#%' ),
    167167                                'format'    => '',
    168168                                'total'     => ceil( (int) $this->total_activity_count / (int) $this->pag_num ),
    … …  
    300300                'spam'             => 'ham_only',   // Hide spammed items
    301301
     302                'page_arg'         => 'acpage',     // See https://buddypress.trac.wordpress.org/ticket/3679
     303
    302304                // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
    303305                'scope'            => $scope,
    … …  
    388390                $spam = 'all';
    389391
    390         $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in, $spam );
     392        $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in, $spam, $page_arg );
    391393
    392394        return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template );
    … …  
    897899                        $dn_default = $activities_template->current_comment->display_name;
    898900                }
    899                
     901
    900902                $alt_default = isset( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $activities_template->activity->display_name ) : __( 'Profile picture', 'buddypress' );
    901                
     903
    902904                $defaults = array(
    903905                        'alt'     => $alt_default,
    … …  
    993995                                $object  = 'group';
    994996                                $item_id = $activities_template->activity->item_id;
    995                                
     997
    996998                                if ( empty( $alt ) ) {
    997999                                        $group = groups_get_group( $item_id );
  • trunk/bp-blogs/bp-blogs-template.php

    r5729 r5891  
    103103        var $total_blog_count;
    104104
    105         function bp_blogs_template( $type, $page, $per_page, $max, $user_id, $search_terms ) {
    106                 $this->__construct( $type, $page, $per_page, $max, $user_id, $search_terms );
    107         }
    108 
    109         function __construct( $type, $page, $per_page, $max, $user_id, $search_terms ) {
    110 
    111                 $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : $page;
     105        function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage' ) {
     106
     107                $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
    112108                $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    113109
    … …  
    136132                if ( (int) $this->total_blog_count && (int) $this->pag_num ) {
    137133                        $this->pag_links = paginate_links( array(
    138                                 'base'      => add_query_arg( 'bpage', '%#%' ),
     134                                'base'      => add_query_arg( $page_arg, '%#%' ),
    139135                                'format'    => '',
    140136                                'total'     => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
    … …  
    209205        $search_terms = null;
    210206
    211         /* User filtering */
     207        // User filtering
    212208        if ( bp_displayed_user_id() )
    213209                $user_id = bp_displayed_user_id();
    … …  
    219215                'max'          => false,
    220216
    221                 'user_id'      => $user_id, // Pass a user_id to limit to only blogs this user has higher than subscriber access to
    222                 'search_terms' => $search_terms // Pass search terms to filter on the blog title or description.
     217                'page_arg'     => 'bpage',        // See https://buddypress.trac.wordpress.org/ticket/3679
     218
     219                'user_id'      => $user_id,       // Pass a user_id to limit to only blogs this user has higher than subscriber access to
     220                'search_terms' => $search_terms   // Pass search terms to filter on the blog title or description.
    223221        );
    224222
    … …  
    239237        }
    240238
    241         $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms );
     239        $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg );
    242240        return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template );
    243241}
    … …  
    280278        function bp_get_blog_avatar( $args = '' ) {
    281279                global $blogs_template;
    282                
     280
    283281                $defaults = array(
    284282                        'type'    => 'full',
    … …  
    528526        function bp_blogs_get_subdomain_base() {
    529527                global $current_site;
    530                
     528
    531529                return apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
    532530        }
  • trunk/bp-forums/bp-forums-template.php

    r5886 r5891  
    9797        var $sort_by;
    9898        var $order;
    99 
    100         function BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) {
    101                 $this->__construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset, $number );
    102         }
    10399
    104100        function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) {
  • trunk/bp-groups/bp-groups-template.php

    r5758 r5891  
    108108        var $order;
    109109
    110         function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras, $include = false, $exclude = false, $show_hidden = false ) {
    111                 $this->__construct( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $include, $populate_extras, $exclude, $show_hidden );
    112         }
    113 
    114         function __construct( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras, $include = false, $exclude = false, $show_hidden = false ){
    115 
    116                 $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page;
     110        function __construct( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras, $include = false, $exclude = false, $show_hidden = false, $page_arg = 'grpage' ){
     111
     112                $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
    117113                $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    118114
    … …  
    171167                if ( (int) $this->total_group_count && (int) $this->pag_num ) {
    172168                        $this->pag_links = paginate_links( array(
    173                                 'base'      => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ),
     169                                'base'      => add_query_arg( array( $page_arg => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ),
    174170                                'format'    => '',
    175171                                'total'     => ceil( (int) $this->total_group_count / (int) $this->pag_num ),
    … …  
    266262                'show_hidden'     => false,
    267263
     264                'page_arg'        => 'grpage', // See https://buddypress.trac.wordpress.org/ticket/3679
     265
    268266                'user_id'         => $user_id, // Pass a user ID to limit to groups this user has joined
    269267                'slug'            => $slug,    // Pass a group slug to only return that group
    … …  
    287285        }
    288286
    289         $groups_template = new BP_Groups_Template( (int) $user_id, $type, (int) $page, (int) $per_page, (int) $max, $slug, $search_terms, (bool)$populate_extras, $include, $exclude, $show_hidden );
     287        $groups_template = new BP_Groups_Template( (int) $user_id, $type, (int) $page, (int) $per_page, (int) $max, $slug, $search_terms, (bool)$populate_extras, $include, $exclude, $show_hidden, $page_arg );
    290288        return apply_filters( 'bp_has_groups', $groups_template->has_groups(), $groups_template );
    291289}
  • trunk/bp-members/bp-members-template.php

    r5824 r5891  
    170170        var $total_member_count;
    171171
    172         function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value ) {
    173 
    174                 $this->pag_page = !empty( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : (int) $page_number;
     172        function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage' ) {
     173
     174                $this->pag_page = !empty( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : (int) $page_number;
    175175                $this->pag_num  = !empty( $_REQUEST['num'] )   ? intval( $_REQUEST['num'] )   : (int) $per_page;
    176176                $this->type     = $type;
    … …  
    200200                if ( (int) $this->total_member_count && (int) $this->pag_num ) {
    201201                        $this->pag_links = paginate_links( array(
    202                                 'base'      => add_query_arg( 'upage', '%#%' ),
     202                                'base'      => add_query_arg( $page_arg, '%#%' ),
    203203                                'format'    => '',
    204204                                'total'     => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
    … …  
    286286                'max'             => false,
    287287
     288                'page_arg'        => 'upage',       // See https://buddypress.trac.wordpress.org/ticket/3679
     289
    288290                'include'         => false,         // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users
    289291                'exclude'         => false,         // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
    … …  
    317319                return false;
    318320
    319         $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude, $meta_key, $meta_value );
     321        $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude, $meta_key, $meta_value, $page_arg );
    320322        return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template );
    321323}
    … …  
    867869
    868870function bp_displayed_user_id() {
    869        
     871
    870872        static $id = 0;
    871        
     873
    872874        if ( empty( $id ) ) {
    873875                global $bp;
    … …  
    881883
    882884        static $id = 0;
    883        
     885
    884886        if ( empty( $id ) ) {
    885887                global $bp;
  • trunk/bp-messages/bp-messages-template.php

    r5822 r5891  
    3030        var $search_terms;
    3131
    32         function bp_messages_box_template( $user_id, $box, $per_page, $max, $type ) {
    33                 $this->__construct( $user_id, $box, $per_page, $max, $type );
    34         }
    35 
    36         function __construct( $user_id, $box, $per_page, $max, $type, $search_terms ) {
    37                 $this->pag_page = isset( $_GET['mpage'] ) ? intval( $_GET['mpage'] ) : 1;
     32        function __construct( $user_id, $box, $per_page, $max, $type, $search_terms, $page_arg = 'mpage' ) {
     33                $this->pag_page = isset( $_GET[$page_arg] ) ? intval( $_GET[$page_arg] ) : 1;
    3834                $this->pag_num  = isset( $_GET['num'] )   ? intval( $_GET['num'] )   : $per_page;
    3935
    … …  
    4238                $this->type         = $type;
    4339                $this->search_terms = $search_terms;
    44                
     40
    4541                if ( 'notices' == $this->box ) {
    4642                        $this->threads = BP_Messages_Notice::get_notices();
    … …  
    7975                if ( (int) $this->total_thread_count && (int) $this->pag_num ) {
    8076                        $this->pag_links = paginate_links( array(
    81                                 'base'      => add_query_arg( 'mpage', '%#%' ),
     77                                'base'      => add_query_arg( $page_arg, '%#%' ),
    8278                                'format'    => '',
    8379                                'total'     => ceil( (int) $this->total_thread_count / (int) $this->pag_num ),
    … …  
    176172                'max'          => false,
    177173                'type'         => 'all',
    178                 'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''
     174                'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '',
     175                'page_arg'     => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679
    179176        );
    180177
    … …  
    197194                }
    198195
    199                 $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type, $search_terms );
     196                $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type, $search_terms, $page_arg );
    200197        }
    201198
    … …  
    323320        function bp_get_message_thread_avatar() {
    324321                global $messages_template;
    325                
     322
    326323                return apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array( 'item_id' => $messages_template->thread->last_sender_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname( $messages_template->thread->last_sender_id ) ) ) ) );
    327324        }
Note: See TracChangeset for help on using the changeset viewer.