Changeset 3245 for branches/1.2/bp-forums/bp-forums-templatetags.php
- Timestamp:
- 09/10/2010 08:12:08 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.