Changeset 9413
- Timestamp:
- 01/29/2015 04:24:36 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-template.php
r9351 r9413 200 200 public function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) { 201 201 202 $this->pag_page = isset( $_REQUEST[ $page_arg ] ) ? intval( $_REQUEST[ $page_arg ] ) : $page; 203 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 202 $this->pag_arg = sanitize_key( $page_arg ); 203 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); 204 $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); 204 205 205 206 // Backwards compatibility support for blogs by first letter … … 243 244 if ( ! empty( $this->total_blog_count ) && ! empty( $this->pag_num ) ) { 244 245 $this->pag_links = paginate_links( array( 245 'base' => add_query_arg( $ page_arg, '%#%' ),246 'base' => add_query_arg( $this->pag_arg, '%#%' ), 246 247 'format' => '', 247 248 'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ), -
trunk/tests/phpunit/testcases/blogs/template.php
r9224 r9413 203 203 buddypress()->site_options = $old_settings; 204 204 } 205 206 /** 207 * @group BP_Blogs_Template 208 */ 209 public function test_bp_blogs_template_should_give_precedence_to_bpage_URL_param() { 210 if ( ! is_multisite() ) { 211 return; 212 } 213 214 $request = $_REQUEST; 215 $_REQUEST['bpage'] = '5'; 216 217 $r = array( 218 'type' => 'active', 219 'page_arg' => 'bpage', 220 'page' => 8, 221 'per_page' => 20, 222 'max' => false, 223 'user_id' => 0, 224 'include_blog_ids' => false, 225 'search_terms' => '', 226 'update_meta_cache' => true 227 ); 228 229 $at = new BP_Blogs_Template( 230 $r['type'], 231 $r['page'], 232 $r['per_page'], 233 $r['max'], 234 $r['user_id'], 235 $r['search_terms'], 236 $r['page_arg'], 237 $r['update_meta_cache'], 238 $r['include_blog_ids'] 239 ); 240 241 $this->assertEquals( 5, $at->pag_page ); 242 243 $_REQUEST = $request; 244 } 245 246 /** 247 * @group BP_Blogs_Template 248 */ 249 public function test_bp_blogs_template_should_reset_0_pag_page_URL_param_to_default_pag_page_value() { 250 if ( ! is_multisite() ) { 251 return; 252 } 253 254 $request = $_REQUEST; 255 $_REQUEST['bpage'] = '0'; 256 257 $r = array( 258 'type' => 'active', 259 'page_arg' => 'bpage', 260 'page' => 8, 261 'per_page' => 20, 262 'max' => false, 263 'user_id' => 0, 264 'include_blog_ids' => false, 265 'search_terms' => '', 266 'update_meta_cache' => true 267 ); 268 269 $at = new BP_Blogs_Template( 270 $r['type'], 271 $r['page'], 272 $r['per_page'], 273 $r['max'], 274 $r['user_id'], 275 $r['search_terms'], 276 $r['page_arg'], 277 $r['update_meta_cache'], 278 $r['include_blog_ids'] 279 ); 280 281 $this->assertEquals( 8, $at->pag_page ); 282 283 $_REQUEST = $request; 284 } 285 286 /** 287 * @group BP_Blogs_Template 288 */ 289 public function test_bp_blogs_template_should_give_precedence_to_num_URL_param() { 290 if ( ! is_multisite() ) { 291 return; 292 } 293 294 $request = $_REQUEST; 295 $_REQUEST['num'] = '14'; 296 297 $r = array( 298 'type' => 'active', 299 'page_arg' => 'bpage', 300 'page' => 1, 301 'per_page' => 13, 302 'max' => false, 303 'user_id' => 0, 304 'include_blog_ids' => false, 305 'search_terms' => '', 306 'update_meta_cache' => true 307 ); 308 309 $at = new BP_Blogs_Template( 310 $r['type'], 311 $r['page'], 312 $r['per_page'], 313 $r['max'], 314 $r['user_id'], 315 $r['search_terms'], 316 $r['page_arg'], 317 $r['update_meta_cache'], 318 $r['include_blog_ids'] 319 ); 320 321 $this->assertEquals( 14, $at->pag_num ); 322 323 $_REQUEST = $request; 324 } 325 326 /** 327 * @group BP_Blogs_Template 328 */ 329 public function test_bp_blogs_template_should_reset_0_pag_num_URL_param_to_default_pag_num_value() { 330 if ( ! is_multisite() ) { 331 return; 332 } 333 334 $request = $_REQUEST; 335 $_REQUEST['num'] = '0'; 336 337 $r = array( 338 'type' => 'active', 339 'page_arg' => 'bpage', 340 'page' => 1, 341 'per_page' => 13, 342 'max' => false, 343 'user_id' => 0, 344 'include_blog_ids' => false, 345 'search_terms' => '', 346 'update_meta_cache' => true 347 ); 348 349 $at = new BP_Blogs_Template( 350 $r['type'], 351 $r['page'], 352 $r['per_page'], 353 $r['max'], 354 $r['user_id'], 355 $r['search_terms'], 356 $r['page_arg'], 357 $r['update_meta_cache'], 358 $r['include_blog_ids'] 359 ); 360 361 $this->assertEquals( 13, $at->pag_num ); 362 363 $_REQUEST = $request; 364 } 205 365 }
Note: See TracChangeset
for help on using the changeset viewer.