Changeset 8758
- Timestamp:
- 08/05/2014 04:10:55 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-blogs/bp-blogs-template.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-template.php
r8757 r8758 91 91 * @var int 92 92 */ 93 var$current_blog = -1;93 public $current_blog = -1; 94 94 95 95 /** … … 99 99 * @var int 100 100 */ 101 var $blog_count;101 public $blog_count = 0; 102 102 103 103 /** … … 107 107 * @var array 108 108 */ 109 var $blogs;109 public $blogs = array(); 110 110 111 111 /** … … 115 115 * @var object 116 116 */ 117 var$blog;117 public $blog; 118 118 119 119 /** … … 123 123 * @var bool 124 124 */ 125 var $in_the_loop;125 public $in_the_loop = false; 126 126 127 127 /** … … 131 131 * @var public 132 132 */ 133 var $pag_page;133 public $pag_page = 1; 134 134 135 135 /** … … 139 139 * @var public 140 140 */ 141 var $pag_num;141 public $pag_num = 20; 142 142 143 143 /** … … 147 147 * @var string 148 148 */ 149 var $pag_links;149 public $pag_links = ''; 150 150 151 151 /** … … 155 155 * @var int 156 156 */ 157 var $total_blog_count;157 public $total_blog_count = 0; 158 158 159 159 /** … … 174 174 * @param array $include_blog_ids Array of blog IDs to include. 175 175 */ 176 function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) { 177 178 $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page; 179 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 180 181 if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) { 176 public function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) { 177 178 $this->pag_page = isset( $_REQUEST[ $page_arg ] ) ? intval( $_REQUEST[ $page_arg ] ) : $page; 179 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 180 181 // Backwards compatibility support for blogs by first letter 182 if ( ! empty( $_REQUEST['letter'] ) ) { 182 183 $this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 184 185 // Typical blogs query 183 186 } else { 184 187 $this->blogs = bp_blogs_get_blogs( array( … … 193 196 } 194 197 195 if ( !$max || $max >= (int) $this->blogs['total'] ) 198 // Set the total blog count 199 if ( empty( $max ) || ( $max >= (int) $this->blogs['total'] ) ) { 196 200 $this->total_blog_count = (int) $this->blogs['total']; 197 else201 } else { 198 202 $this->total_blog_count = (int) $max; 199 203 } 204 205 // Set the blogs array (to loop through later 200 206 $this->blogs = $this->blogs['blogs']; 201 207 202 if ( $max ) {203 if ( $max >= count($this->blogs) ) {204 $this->blog_count = count( $this->blogs ); 205 } else {206 $this->blog_count = (int) $max;207 }208 // Get the current blog count to compare maximum against 209 $blog_count = count( $this->blogs ); 210 211 // Set the current blog count 212 if ( empty( $max ) || ( $max >= (int) $blog_count ) ) { 213 $this->blog_count = (int) $blog_count; 208 214 } else { 209 $this->blog_count = count( $this->blogs ); 210 } 211 212 if ( (int) $this->total_blog_count && (int) $this->pag_num ) { 215 $this->blog_count = (int) $max; 216 } 217 218 // Build pagination links based on total blogs and current page number 219 if ( ! empty( $this->total_blog_count ) && ! empty( $this->pag_num ) ) { 213 220 $this->pag_links = paginate_links( array( 214 221 'base' => add_query_arg( $page_arg, '%#%' ), … … 217 224 'current' => (int) $this->pag_page, 218 225 'prev_text' => _x( '←', 'Blog pagination previous text', 'buddypress' ), 219 'next_text' => _x( '→', 'Blog pagination next text', 'buddypress' ),226 'next_text' => _x( '→', 'Blog pagination next text', 'buddypress' ), 220 227 'mid_size' => 1 221 228 ) ); … … 230 237 * @return bool True if there are items in the loop, otherwise false. 231 238 */ 232 function has_blogs() { 233 if ( $this->blog_count ) 234 return true; 235 236 return false; 239 public function has_blogs() { 240 return (bool) ! empty( $this->blog_count ); 237 241 } 238 242 … … 242 246 * @return object The next blog to iterate over. 243 247 */ 244 function next_blog() {248 public function next_blog() { 245 249 $this->current_blog++; 246 $this->blog = $this->blogs[ $this->current_blog];250 $this->blog = $this->blogs[ $this->current_blog ]; 247 251 248 252 return $this->blog; … … 252 256 * Rewind the blogs and reset blog index. 253 257 */ 254 function rewind_blogs() {258 public function rewind_blogs() { 255 259 $this->current_blog = -1; 256 260 if ( $this->blog_count > 0 ) { … … 270 274 * @return bool True if there are more blogs to show, otherwise false. 271 275 */ 272 function blogs() {273 if ( $this->current_blog + 1< $this->blog_count ) {276 public function blogs() { 277 if ( ( $this->current_blog + 1 ) < $this->blog_count ) { 274 278 return true; 275 } elseif ( $this->current_blog + 1== $this->blog_count ) {276 do_action( 'blog_loop_end');279 } elseif ( ( $this->current_blog + 1 ) === $this->blog_count ) { 280 do_action( 'blog_loop_end' ); 277 281 // Do some cleaning up after the loop 278 282 $this->rewind_blogs(); … … 292 296 * @see bp_the_blog() 293 297 */ 294 function the_blog() {298 public function the_blog() { 295 299 296 300 $this->in_the_loop = true; 297 301 $this->blog = $this->next_blog(); 298 302 299 if ( 0 == $this->current_blog ) // loop has just started 300 do_action('blog_loop_start'); 303 // loop has just started 304 if ( 0 === $this->current_blog ) { 305 do_action( 'blog_loop_start' ); 306 } 301 307 } 302 308 }
Note: See TracChangeset
for help on using the changeset viewer.