Changeset 2077 for trunk/bp-activity/bp-activity-templatetags.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-templatetags.php
r2071 r2077 8 8 var $activity; 9 9 var $activity_type; 10 10 11 11 var $in_the_loop; 12 12 13 13 var $pag_page; 14 14 var $pag_num; … … 26 26 if ( $type == 'sitewide' ) 27 27 $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page, $filter ); 28 28 29 29 if ( $type == 'personal' ) 30 30 $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter ); … … 32 32 if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) ) 33 33 $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter ); 34 34 35 35 if ( !$max || $max >= (int)$this->activities['total'] ) 36 36 $this->total_activity_count = (int)$this->activities['total']; 37 37 else 38 38 $this->total_activity_count = (int)$max; 39 39 40 40 $this->activities = $this->activities['activities']; 41 41 42 42 if ( $max ) { 43 43 if ( $max >= count($this->activities) ) … … 48 48 $this->activity_count = count($this->activities); 49 49 } 50 50 51 51 $this->full_name = $bp->displayed_user->fullname; 52 52 … … 63 63 } 64 64 } 65 65 66 66 function has_activities() { 67 67 if ( $this->activity_count ) 68 68 return true; 69 69 70 70 return false; 71 71 } 72 72 73 73 function next_activity() { 74 74 $this->current_activity++; 75 75 $this->activity = $this->activities[$this->current_activity]; 76 76 77 77 return $this->activity; 78 78 } 79 79 80 80 function rewind_activities() { 81 81 $this->current_activity = -1; … … 84 84 } 85 85 } 86 87 function user_activities() { 86 87 function user_activities() { 88 88 if ( $this->current_activity + 1 < $this->activity_count ) { 89 89 return true; … … 97 97 return false; 98 98 } 99 99 100 100 function the_activity() { 101 101 global $activity; … … 103 103 $this->in_the_loop = true; 104 104 $this->activity = $this->next_activity(); 105 105 106 106 if ( is_array( $this->activity ) ) 107 107 $this->activity = (object) $this->activity; … … 114 114 function bp_has_activities( $args = '' ) { 115 115 global $bp, $activities_template; 116 116 117 117 /* Note: any params used for filtering can be a single value, or multiple values comma separated. */ 118 118 119 119 $defaults = array( 120 120 'type' => 'sitewide', … … 138 138 $per_page = $max; 139 139 } 140 140 141 141 if ( isset( $_GET['afilter'] ) ) 142 142 $filter = array( 'object' => $_GET['afilter'] ); 143 143 else 144 144 $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id ); 145 146 $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter ); 145 146 $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter ); 147 147 return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template ); 148 148 } … … 160 160 function bp_activity_pagination_count() { 161 161 global $bp, $activities_template; 162 162 163 163 $from_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1; 164 164 $to_num = ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1) ; … … 173 173 function bp_get_activity_pagination_links() { 174 174 global $activities_template; 175 175 176 176 return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links ); 177 177 } … … 179 179 function bp_activities_title() { 180 180 global $bp_activity_title; 181 181 182 182 echo bp_get_activities_title(); 183 183 } … … 190 190 function bp_activities_no_activity() { 191 191 global $bp_activity_no_activity; 192 192 193 193 echo bp_get_activities_no_activity(); 194 194 } 195 195 function bp_get_activities_no_activity() { 196 196 global $bp_activity_no_activity; 197 197 198 198 return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity ); 199 199 } … … 218 218 'height' => 20, 219 219 'class' => 'avatar', 220 'alt' => __( 'Avatar', 'buddypress' ) 220 'alt' => __( 'Avatar', 'buddypress' ) 221 221 ); 222 222 223 223 $r = wp_parse_args( $args, $defaults ); 224 224 extract( $r, EXTR_SKIP ); 225 225 226 226 $item_id = false; 227 227 if ( (int)$activities_template->activity->user_id ) … … 235 235 if ( $bp->blogs->id == $activities_template->activity->component_name && !(int) $activities_template->activity->user_id ) 236 236 $object = 'blog'; 237 237 238 238 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component_name, $object ); 239 239 240 240 return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height ) ) ); 241 241 } … … 248 248 249 249 if ( bp_is_home() && $activities_template->activity_type == 'personal' ) 250 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name ); 250 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name ); 251 251 else 252 252 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false ); … … 254 254 /* Add 'the_content' filter to activity to allow existing plugins to replace text as they would on post text. (extra smilies etc) */ 255 255 $content = apply_filters( 'the_content', $content ); 256 256 257 257 return apply_filters( 'bp_get_activity_content', $content ); 258 258 } … … 260 260 function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) { 261 261 global $activities_template, $bp; 262 262 263 263 if ( !$content ) 264 264 return false; 265 265 266 266 /* Split the content so we don't evaluate and replace text on content we don't want to */ 267 267 $content = explode( '%s', $content ); … … 273 273 if ( $insert_time ) 274 274 $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded ); 275 275 276 276 // The "You" and "Your" conversion is only done in english, if a translation file is present 277 277 // then do not translate as it causes problems in other languages. … … 284 284 /* Remove the 'You' and replace if with the persons name */ 285 285 if ( $filter_you && $full_name != '' ) { 286 $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 ); 286 $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 ); 287 287 } 288 288 } … … 290 290 /* Add the delete link if the user has permission on this item */ 291 291 if ( ( $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() ) 292 $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1]; 293 292 $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1]; 293 294 294 $content_new = ''; 295 295 296 296 for ( $i = 0; $i < count($content); $i++ ) 297 297 $content_new .= $content[$i]; 298 298 299 299 return apply_filters( 'bp_activity_content_filter', $content_new ); 300 300 } … … 306 306 // Make sure we don't have any URL encoding in links when trying to insert the time. 307 307 $content = urldecode($content); 308 308 309 309 return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( ' %s ago', 'buddypress' ), bp_core_time_since( strtotime( $date ) ) ) ) ); 310 310 } … … 315 315 function bp_get_activity_css_class() { 316 316 global $activities_template; 317 317 318 318 return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name ); 319 319 } … … 333 333 function bp_get_activity_filter_links( $args = false ) { 334 334 global $activities_template, $bp; 335 335 336 336 $defaults = array( 337 337 'style' => 'list' … … 340 340 $r = wp_parse_args( $args, $defaults ); 341 341 extract( $r, EXTR_SKIP ); 342 342 343 343 /* Fetch the names of components that have activity recorded in the DB */ 344 344 $component_names = BP_Activity_Activity::get_recorded_component_names(); 345 345 346 346 if ( !$component_names ) 347 347 return false; 348 348 349 349 foreach ( (array) $component_names as $component_name ) { 350 350 if ( isset( $_GET['afilter'] ) && $component_name == $_GET['afilter'] ) … … 352 352 else 353 353 unset($selected); 354 354 355 $component_name = attribute_escape( $component_name ); 356 355 357 $component_name = attribute_escape( $component_name ); 356 358 … … 372 374 break; 373 375 } 374 376 375 377 $link = add_query_arg( 'afilter', $component_name ); 376 378 $link = remove_query_arg( 'acpage' , $link ); 377 379 378 380 $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component_name ); 379 381 380 382 /* Make sure all core internal component names are translatable */ 381 383 $translatable_component_names = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) ); 382 384 383 385 $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component_name, 'buddypress' ) ) . '</a>' . $after; 384 386 } … … 388 390 if ( isset( $_GET['afilter'] ) ) 389 391 $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>'; 390 391 392 393 return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) ); 392 394 } 393 395 … … 410 412 return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/feed' ); 411 413 else 412 return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ); 414 return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ); 413 415 } 414 416 … … 421 423 global $activities_template; 422 424 423 return apply_filters( 'bp_get_activity_feed_item_title', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) ); 425 return apply_filters( 'bp_get_activity_feed_item_title', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) ); 424 426 } 425 427 … … 453 455 454 456 function bp_activity_feed_item_description() { 455 echo bp_get_activity_feed_item_description(); 457 echo bp_get_activity_feed_item_description(); 456 458 } 457 459 function bp_get_activity_feed_item_description() { 458 460 global $activities_template; 459 461 460 return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) ); 462 return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) ); 461 463 } 462 464
Note: See TracChangeset
for help on using the changeset viewer.