Changeset 3245
- Timestamp:
- 09/10/2010 08:12:08 PM (15 years ago)
- Location:
- branches/1.2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2/bp-activity/bp-activity-templatetags.php
r3214 r3245 20 20 21 21 $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 25 25 $this->disable_blogforum_replies = $bp->site_options['bp-disable-blogforum-comments']; 26 26 27 / * Get an array of the logged in user's favorite activities */27 // Get an array of the logged in user's favorite activities 28 28 $this->my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) ); 29 29 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 ) ) 32 32 $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 34 35 $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 }36 36 37 37 if ( !$max || $max >= (int)$this->activities['total'] ) … … 43 43 44 44 if ( $max ) { 45 if ( $max >= count($this->activities) ) 46 $this->activity_count = count( $this->activities);47 else45 if ( $max >= count($this->activities) ) { 46 $this->activity_count = count( $this->activities ); 47 } else { 48 48 $this->activity_count = (int)$max; 49 } 49 50 } else { 50 $this->activity_count = count( $this->activities);51 $this->activity_count = count( $this->activities ); 51 52 } 52 53 53 54 $this->full_name = $bp->displayed_user->fullname; 54 55 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 56 57 foreach ( (array)$this->activities as $activity ) { 57 if ( 'activity_comment' != $activity->type ) continue; 58 if ( 'activity_comment' != $activity->type ) 59 continue; 60 58 61 $parent_ids[] = $activity->item_id; 59 62 } … … 63 66 64 67 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 66 71 unset( $activity_parents ); 67 72 } 68 73 69 if ( (int) $this->total_activity_count && (int)$this->pag_num ) {74 if ( (int)$this->total_activity_count && (int)$this->pag_num ) { 70 75 $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, 75 80 'prev_text' => '←', 76 81 'next_text' => '→', 77 'mid_size' => 178 ) );82 'mid_size' => 1 83 ) ); 79 84 } 80 85 } -
branches/1.2/bp-blogs/bp-blogs-templatetags.php
r3149 r3245 37 37 38 38 if ( $max ) { 39 if ( $max >= count($this->blogs) ) 40 $this->blog_count = count( $this->blogs);41 else39 if ( $max >= count($this->blogs) ) { 40 $this->blog_count = count( $this->blogs ); 41 } else { 42 42 $this->blog_count = (int)$max; 43 } 43 44 } 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 } 56 59 } 57 60 -
branches/1.2/bp-core/bp-core-templatetags.php
r3238 r3245 22 22 23 23 $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'] ) 28 28 $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras ); 29 } else {29 else 30 30 $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) ); 31 }32 31 33 32 if ( !$max || $max >= (int)$this->members['total'] ) … … 39 38 40 39 if ( $max ) { 41 if ( $max >= count($this->members) ) 42 $this->member_count = count( $this->members);43 else40 if ( $max >= count($this->members) ) { 41 $this->member_count = count( $this->members ); 42 } else { 44 43 $this->member_count = (int)$max; 44 } 45 45 } else { 46 $this->member_count = count( $this->members);46 $this->member_count = count( $this->members ); 47 47 } 48 48 49 if ( (int) $this->total_member_count && (int)$this->pag_num ) {49 if ( (int)$this->total_member_count && (int)$this->pag_num ) { 50 50 $this->pag_links = paginate_links( array( 51 'base' => add_query_arg( 'upage', '%#%' ),52 'format' => '',53 'total' => ceil( (int) $this->total_member_count / (int)$this->pag_num ),54 'current' => (int)$this->pag_page,51 'base' => add_query_arg( 'upage', '%#%' ), 52 'format' => '', 53 'total' => ceil( (int)$this->total_member_count / (int)$this->pag_num ), 54 'current' => (int)$this->pag_page, 55 55 'prev_text' => '←', 56 56 'next_text' => '→', 57 'mid_size' => 158 ) );57 'mid_size' => 1 58 ) ); 59 59 } 60 60 } -
branches/1.2/bp-forums/bp-forums-templatetags.php
r3216 r3245 24 24 global $bp; 25 25 26 $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page;27 $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;28 $this->type = $type;26 $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page; 27 $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page; 28 $this->type = $type; 29 29 $this->search_terms = $search_terms; 30 $this->forum_id = $forum_id;30 $this->forum_id = $forum_id; 31 31 32 32 switch ( $type ) { … … 51 51 52 52 if ( !(int)$this->topics ) { 53 $this->topic_count = 0;53 $this->topic_count = 0; 54 54 $this->total_topic_count = 0; 55 55 } else { … … 63 63 } 64 64 65 if ( !$max || $max >= $topic_count ) 65 if ( !$max || $max >= $topic_count ) { 66 66 $this->total_topic_count = $topic_count; 67 else67 } else { 68 68 $this->total_topic_count = (int)$max; 69 } 69 70 70 71 if ( $max ) { 71 if ( $max >= count($this->topics) ) 72 if ( $max >= count($this->topics) ) { 72 73 $this->topic_count = count( $this->topics ); 73 else74 } else { 74 75 $this->topic_count = (int)$max; 76 } 75 77 } else { 76 78 $this->topic_count = count( $this->topics ); … … 78 80 } 79 81 80 $this->topic_count = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );82 $this->topic_count = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies ); 81 83 $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 ); 82 84 83 if ( !$no_stickies ) {84 / * Place stickies at the top - not sure why bbPress doesn't do this? */85 if ( !$no_stickies ) { 86 // Place stickies at the top - not sure why bbPress doesn't do this? 85 87 foreach( (array)$this->topics as $topic ) { 86 if ( 1 == (int)$topic->topic_sticky ) 88 if ( 1 == (int)$topic->topic_sticky ) { 87 89 $stickies[] = $topic; 88 else90 } else { 89 91 $standard[] = $topic; 92 } 90 93 } 94 91 95 $this->topics = array_merge( (array)$stickies, (array)$standard ); 92 96 } 93 97 94 / * Fetch extra information for topics, so we don't have to query inside the loop */98 // Fetch extra information for topics, so we don't have to query inside the loop 95 99 $this->topics = bp_forums_get_topic_extras( &$this->topics ); 96 100 97 $this->pag_links = paginate_links( array( 98 'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ), 99 'format' => '', 100 'total' => ceil($this->total_topic_count / $this->pag_num), 101 'current' => $this->pag_page, 102 'prev_text' => '←', 103 'next_text' => '→', 104 'mid_size' => 1 105 )); 101 if ( (int)$this->total_topic_count && (int)$this->pag_num ) { 102 $this->pag_links = paginate_links( array( 103 'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ), 104 'format' => '', 105 'total' => ceil( (int)$this->total_topic_count / (int)$this->pag_num), 106 'current' => $this->pag_page, 107 'prev_text' => '←', 108 'next_text' => '→', 109 'mid_size' => 1 110 ) ); 111 } 106 112 } 107 113 … … 725 731 $this->forum_id = $forum_template->topic->forum_id; 726 732 727 $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 ) );733 $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 ) ); 728 734 729 735 if ( !$this->posts ) { 730 $this->post_count = 0;736 $this->post_count = 0; 731 737 $this->total_post_count = 0; 732 738 } else { 733 if ( !$max || $max >= (int) $forum_template->topic->topic_posts )734 $this->total_post_count = (int) 735 else739 if ( !$max || $max >= (int)$forum_template->topic->topic_posts ) { 740 $this->total_post_count = (int)$forum_template->topic->topic_posts; 741 } else { 736 742 $this->total_post_count = (int)$max; 743 } 737 744 738 745 if ( $max ) { 739 if ( $max >= count( $this->posts) )746 if ( $max >= count( $this->posts ) ) { 740 747 $this->post_count = count( $this->posts ); 741 else748 } else { 742 749 $this->post_count = (int)$max; 750 } 743 751 } else { 744 752 $this->post_count = count( $this->posts ); … … 746 754 } 747 755 748 $this->pag_links = paginate_links( array( 749 'base' => add_query_arg( array( 'topic_page' => '%#%', 'num' => $this->pag_num ) ), 750 'format' => '', 751 'total' => ceil($this->total_post_count / $this->pag_num), 752 'current' => $this->pag_page, 753 'prev_text' => '←', 754 'next_text' => '→', 755 'mid_size' => 1 756 )); 757 $this->pag->total_pages = ceil($this->total_post_count / $this->pag_num); 756 if ( (int)$this->total_post_count && (int)$this->pag_num ) { 757 $this->pag_links = paginate_links( array( 758 'base' => add_query_arg( array( 'topic_page' => '%#%', 'num' => (int)$this->pag_num ) ), 759 'format' => '', 760 'total' => ceil( (int)$this->total_post_count / (int)$this->pag_num ), 761 'current' => $this->pag_page, 762 'prev_text' => '←', 763 'next_text' => '→', 764 'mid_size' => 1 765 ) ); 766 767 $this->pag->total_pages = ceil( (int)$this->total_post_count / (int)$this->pag_num ); 768 } else { 769 $this->pag->total_pages = 1; 770 } 758 771 } 759 772 -
branches/1.2/bp-groups/bp-groups-templatetags.php
r3201 r3245 27 27 28 28 $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page; 29 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;30 31 if ( 'invites' == $type ) 29 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 30 31 if ( 'invites' == $type ) { 32 32 $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page ); 33 else if ( 'single-group' == $type ) {33 } else if ( 'single-group' == $type ) { 34 34 $group = new stdClass; 35 35 $group->group_id = BP_Groups_Group::get_id_from_slug($slug); 36 $this->groups = array( $group );37 } else 36 $this->groups = array( $group ); 37 } else { 38 38 $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, 'populate_extras' => $populate_extras ) ); 39 } 39 40 40 41 if ( 'invites' == $type ) { 41 42 $this->total_group_count = (int)$this->groups['total']; 42 $this->group_count = (int)$this->groups['total']; 43 $this->group_count = (int)$this->groups['total']; 44 $this->groups = $this->groups['groups']; 45 } else if ( 'single-group' == $type ) { 46 $this->single_group = true; 47 $this->total_group_count = 1; 48 $this->group_count = 1; 49 } else { 50 if ( !$max || $max >= (int)$this->groups['total'] ) { 51 $this->total_group_count = (int)$this->groups['total']; 52 } else { 53 $this->total_group_count = (int)$max; 54 } 55 43 56 $this->groups = $this->groups['groups']; 44 } else if ( 'single-group' == $type ) {45 $this->single_group = true;46 $this->total_group_count = 1;47 $this->group_count = 1;48 } else {49 if ( !$max || $max >= (int)$this->groups['total'] )50 $this->total_group_count = (int)$this->groups['total'];51 else52 $this->total_group_count = (int)$max;53 54 $this->groups = $this->groups['groups'];55 57 56 58 if ( $max ) { 57 if ( $max >= count($this->groups) ) 58 $this->group_count = count( $this->groups);59 else59 if ( $max >= count($this->groups) ) { 60 $this->group_count = count( $this->groups ); 61 } else { 60 62 $this->group_count = (int)$max; 63 } 61 64 } else { 62 $this->group_count = count( $this->groups);65 $this->group_count = count( $this->groups ); 63 66 } 64 67 } 65 68 66 $this->pag_links = paginate_links( array( 67 'base' => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ), 68 'format' => '', 69 'total' => ceil($this->total_group_count / $this->pag_num), 70 'current' => $this->pag_page, 71 'prev_text' => '←', 72 'next_text' => '→', 73 'mid_size' => 1 74 )); 69 // Build pagination links 70 if ( (int)$this->total_group_count && (int)$this->pag_num ) { 71 $this->pag_links = paginate_links( array( 72 'base' => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ), 73 'format' => '', 74 'total' => ceil( (int)$this->total_group_count / (int)$this->pag_num ), 75 'current' => $this->pag_page, 76 'prev_text' => '←', 77 'next_text' => '→', 78 'mid_size' => 1 79 ) ); 80 } 75 81 } 76 82 -
branches/1.2/bp-messages/bp-messages-templatetags.php
r3206 r3245 22 22 function bp_messages_box_template( $user_id, $box, $per_page, $max, $type ) { 23 23 $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 ) { 31 31 $this->threads = BP_Messages_Notice::get_notices(); 32 else {32 } else { 33 33 $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page ); 34 34 35 $this->threads = $threads['threads'];35 $this->threads = $threads['threads']; 36 36 $this->total_thread_count = $threads['total']; 37 37 } 38 38 39 39 if ( !$this->threads ) { 40 $this->thread_count = 0;40 $this->thread_count = 0; 41 41 $this->total_thread_count = 0; 42 42 } else { … … 44 44 45 45 if ( !$max || $max >= (int)$total_notice_count ) { 46 if ( 'notices' == $this->box ) 46 if ( 'notices' == $this->box ) { 47 47 $this->total_thread_count = (int)$total_notice_count; 48 } 48 49 } else { 49 50 $this->total_thread_count = (int)$max; … … 51 52 52 53 if ( $max ) { 53 if ( $max >= count($this->threads) ) 54 if ( $max >= count($this->threads) ) { 54 55 $this->thread_count = count($this->threads); 55 else56 } else { 56 57 $this->thread_count = (int)$max; 58 } 57 59 } else { 58 60 $this->thread_count = count($this->threads); … … 60 62 } 61 63 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 } 71 75 } 72 76
Note: See TracChangeset
for help on using the changeset viewer.