Changeset 2077 for trunk/bp-friends/bp-friends-templatetags.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-friends/bp-friends-templatetags.php (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends/bp-friends-templatetags.php
r2032 r2077 6 6 var $friendships; 7 7 var $friendship; 8 8 9 9 var $in_the_loop; 10 10 11 11 var $pag_page; 12 12 var $pag_num; 13 13 var $pag_links; 14 14 var $total_friend_count; 15 15 16 16 function bp_friendship_template( $user_id, $type, $per_page, $max, $filter ) { 17 17 global $bp; … … 19 19 if ( !$user_id ) 20 20 $user_id = $bp->displayed_user->id; 21 21 22 22 $this->pag_page = isset( $_REQUEST['frpage'] ) ? intval( $_REQUEST['frpage'] ) : 1; 23 23 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 28 28 $this->friendships = friends_get_newest( $user_id, $this->pag_num, $this->pag_page, $filter ); 29 29 break; 30 30 31 31 case 'alphabetical': 32 $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter ); 32 $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter ); 33 33 break; 34 34 … … 38 38 39 39 case 'active': default: 40 $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter ); 40 $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter ); 41 41 break; 42 42 } … … 74 74 )); 75 75 } 76 76 77 77 function has_friendships() { 78 78 if ( $this->friendship_count ) 79 79 return true; 80 80 81 81 return false; 82 82 } 83 83 84 84 function next_friendship() { 85 85 $this->current_friendship++; 86 86 $this->friendship = $this->friendships[$this->current_friendship]; 87 87 88 88 return $this->friendship; 89 89 } 90 90 91 91 function rewind_friendships() { 92 92 $this->current_friendship = -1; … … 95 95 } 96 96 } 97 98 function user_friendships() { 97 98 function user_friendships() { 99 99 if ( $this->current_friendship + 1 < $this->friendship_count ) { 100 100 return true; … … 108 108 return false; 109 109 } 110 110 111 111 function the_friendship() { 112 112 global $friendship, $bp; … … 123 123 else 124 124 $user_id = $this->friendship->user_id; 125 125 126 126 $this->friendship = new stdClass; 127 127 128 128 if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) { 129 129 $this->friendship->friend = new BP_Core_User( $user_id ); 130 130 wp_cache_set( 'bp_user_' . $user_id, $this->friendship->friend, 'bp' ); 131 131 } 132 132 133 133 /* Make sure the user_id is available in the friend object. */ 134 134 $this->friendship->friend->user_id = $user_id; … … 153 153 $r = wp_parse_args( $args, $defaults ); 154 154 extract( $r, EXTR_SKIP ); 155 155 156 156 /* The following code will auto set parameters based on the page being viewed. 157 157 * for example on example.com/members/andy/friends/my-friends/newest/ … … 167 167 $type = 'requests'; 168 168 } 169 169 170 170 if ( isset( $_REQUEST['friend-search-box'] ) ) 171 171 $filter = $_REQUEST['friend-search-box']; … … 190 190 function bp_get_friend_id() { 191 191 global $friends_template; 192 193 return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id ); 192 193 return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id ); 194 194 } 195 195 … … 208 208 function bp_get_friend_name() { 209 209 global $friends_template; 210 211 return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) ); 212 } 213 210 211 return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) ); 212 } 213 214 214 function bp_friend_link() { 215 215 echo bp_get_friend_link(); … … 238 238 return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active ); 239 239 } 240 240 241 241 function bp_friend_time_since_requested() { 242 242 echo bp_get_friend_time_since_requested(); … … 248 248 return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) ); 249 249 } 250 250 251 251 return false; 252 252 } … … 267 267 global $friends_template, $bp; 268 268 269 return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) ); 269 return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) ); 270 270 } 271 271 … … 275 275 function bp_get_friend_pagination() { 276 276 global $friends_template; 277 277 278 278 return apply_filters( 'bp_friend_pagination', $friends_template->pag_links ); 279 279 } … … 286 286 287 287 echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?> 288 <span class="ajax-loader"></span><?php 288 <span class="ajax-loader"></span><?php 289 289 } 290 290 … … 295 295 return apply_filters( 'bp_get_friend_total_for_member', BP_Friends_Friendship::total_friend_count() ); 296 296 } 297 297 298 298 function bp_friend_search_form() { 299 299 global $friends_template, $bp; … … 306 306 <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label> 307 307 <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> /> 308 308 309 309 <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?> 310 310 <input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" /> 311 311 312 312 </form> 313 313 <?php … … 317 317 if ( isset( $_POST['friend-search-box'] ) ) 318 318 return true; 319 319 320 320 return false; 321 321 } … … 328 328 function bp_friend_latest_update_link() { 329 329 global $bp; 330 echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' ); 330 echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' ); 331 331 } 332 332 333 333 function bp_friend_recent_activity_link() { 334 334 global $bp; 335 echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' ); 335 echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' ); 336 336 } 337 337 338 338 function bp_friend_recent_status_link() { 339 339 global $bp; 340 echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' ); 340 echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' ); 341 341 } 342 342 … … 346 346 function bp_get_add_friend_button( $potential_friend_id = false ) { 347 347 global $bp, $friends_template; 348 348 349 349 $button = false; 350 350 351 351 if ( is_user_logged_in() ) { 352 352 353 353 if ( !$potential_friend_id && $friends_template->friendship->friend ) 354 354 $potential_friend_id = $friends_template->friendship->friend->id; … … 371 371 $button .= '</div>'; 372 372 } 373 373 374 374 return apply_filters( 'bp_get_add_friend_button', $button ); 375 375 } … … 387 387 function bp_friends_filter_title() { 388 388 global $bp; 389 389 390 390 $current_filter = $bp->action_variables[0]; 391 391 392 392 switch ( $current_filter ) { 393 393 case 'recently-active': default: … … 405 405 function bp_friends_random_friends() { 406 406 global $bp; 407 407 408 408 if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) { 409 409 $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id ); 410 410 wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' ); 411 411 } 412 ?> 412 ?> 413 413 <div class="info-group"> 414 414 <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> »</a></span></h4> 415 415 416 416 <?php if ( $friend_ids ) { ?> 417 417 <ul class="horiz-gallery"> … … 435 435 function bp_friends_random_members( $total_members = 5 ) { 436 436 global $bp; 437 437 438 438 if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) { 439 439 $user_ids = BP_Core_User::get_random_users( $total_members ); 440 440 wp_cache_set( 'friends_random_users', $user_ids, 'bp' ); 441 441 } 442 ?> 442 ?> 443 443 <?php if ( $user_ids['users'] ) { ?> 444 444 <ul class="item-list" id="random-members-list"> … … 454 454 </div> 455 455 <?php } ?> 456 456 457 457 <div class="action"> 458 458 <?php if ( function_exists( 'bp_add_friend_button' ) ) { ?> … … 466 466 <div id="message" class="info"> 467 467 <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ) ?></p> 468 </div> 468 </div> 469 469 <?php } ?> 470 470 <?php
Note: See TracChangeset
for help on using the changeset viewer.