Changeset 2381 for trunk/bp-activity/bp-activity-templatetags.php
- Timestamp:
- 01/20/2010 04:21:20 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-activity/bp-activity-templatetags.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-templatetags.php
r2375 r2381 266 266 function bp_get_activity_object_name() { 267 267 global $activities_template; 268 return apply_filters( 'bp_get_activity_object_name', $activities_template->activity->component_name ); 269 } 270 271 function bp_activity_action_name() { 272 echo bp_get_activity_action_name(); 273 } 274 function bp_get_activity_action_name() { 275 global $activities_template; 276 return apply_filters( 'bp_get_activity_action_name', $activities_template->activity->component_action ); 277 } 268 return apply_filters( 'bp_get_activity_object_name', $activities_template->activity->component ); 269 } 270 271 function bp_activity_type() { 272 echo bp_get_activity_type(); 273 } 274 function bp_get_activity_type() { 275 global $activities_template; 276 return apply_filters( 'bp_get_activity_type', $activities_template->activity->type ); 277 } 278 function bp_activity_action_name() { echo bp_activity_type(); } 279 function bp_get_activity_action_name() { return bp_get_activity_type(); } 278 280 279 281 function bp_activity_user_id() { … … 310 312 311 313 $object = 'user'; 312 if ( $bp->groups->id == $activities_template->activity->component _name&& !(int) $activities_template->activity->user_id )314 if ( $bp->groups->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id ) 313 315 $object = 'group'; 314 if ( $bp->blogs->id == $activities_template->activity->component _name&& !(int) $activities_template->activity->user_id )316 if ( $bp->blogs->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id ) 315 317 $object = 'blog'; 316 318 317 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component _name, $object );319 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, $object ); 318 320 319 321 /* If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. */ … … 324 326 } 325 327 328 function bp_activity_action() { 329 echo bp_get_activity_action(); 330 } 331 function bp_get_activity_action() { 332 global $activities_template; 333 334 return apply_filters( 'bp_get_activity_action', bp_activity_content_filter( $activities_template->activity->action, $activities_template->activity->date_recorded ), $activities_template->activity->component, $activities_template->activity->type ); 335 } 336 337 function bp_activity_content_body() { 338 echo bp_get_activity_content_body(); 339 } 340 function bp_get_activity_content_body() { 341 global $activities_template; 342 343 if ( empty( $activities_template->activity->action ) ) 344 $activities_template->activity->content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded ); 345 346 return apply_filters( 'bp_get_activity_content_body', $activities_template->activity->content ); 347 } 348 326 349 function bp_activity_content() { 327 350 echo bp_get_activity_content(); 328 351 } 329 352 function bp_get_activity_content() { 330 global $activities_template, $allowed_tags, $bp; 331 332 if ( bp_is_home() && $activities_template->activity_type == 'personal' ) 333 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name ); 334 else 335 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false ); 336 337 return apply_filters( 'bp_get_activity_content', $content, $activities_template->activity->component_name, $activities_template->activity->component_action ); 338 } 339 340 function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) { 353 global $activities_template; 354 355 if ( empty( $activities_template->activity->action ) ) 356 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded ); 357 else { 358 $content = bp_activity_content_filter( $activities_template->activity->action, $activities_template->activity->date_recorded ); 359 $content .= $activities_template->activity->content; 360 } 361 362 return apply_filters( 'bp_get_activity_content', $content, $activities_template->activity->component, $activities_template->activity->type ); 363 } 364 365 function bp_activity_content_filter( $content, $date_recorded ) { 341 366 global $activities_template, $bp; 342 367 … … 351 376 352 377 /* Insert the time since */ 353 if ( $insert_time ) 354 $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded ); 355 356 // The "You" and "Your" conversion is only done in english, if a translation file is present 357 // then do not translate as it causes problems in other languages. 358 if ( '' == get_locale() ) { 359 /* Switch 'their/your' depending on whether the user is logged in or not and viewing their profile */ 360 if ( $filter_words ) { 361 $content[0] = preg_replace( '/their\s/', 'your ', $content[0] ); 362 } 363 364 /* Remove the 'You' and replace if with the persons name */ 365 if ( $filter_you && $full_name != '' ) { 366 $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 ); 367 } 368 } 378 $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded ); 369 379 370 380 /* Add the permalink */ … … 559 569 560 570 $class = ''; 561 if ( in_array( $activities_template->activity-> component_action, (array)$mini_activity_actions ) )571 if ( in_array( $activities_template->activity->type, (array)$mini_activity_actions ) ) 562 572 $class = ' mini'; 563 573 … … 565 575 $class .= ' has-comments'; 566 576 567 return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component _name . ' ' . $activities_template->activity->component_action. $class );577 return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class ); 568 578 } 569 579 … … 609 619 610 620 /* Fetch the names of components that have activity recorded in the DB */ 611 $component _names = BP_Activity_Activity::get_recorded_component_names();612 613 if ( !$component _names )621 $components = BP_Activity_Activity::get_recorded_components(); 622 623 if ( !$components ) 614 624 return false; 615 625 616 foreach ( (array) $component _names as $component_name) {626 foreach ( (array) $components as $component ) { 617 627 /* Skip the activity comment filter */ 618 if ( 'activity' == $component _name)628 if ( 'activity' == $component ) 619 629 continue; 620 630 621 if ( isset( $_GET['afilter'] ) && $component _name== $_GET['afilter'] )631 if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) 622 632 $selected = ' class="selected"'; 623 633 else 624 634 unset($selected); 625 635 626 $component _name = attribute_escape( $component_name);636 $component = attribute_escape( $component ); 627 637 628 638 switch ( $style ) { 629 639 case 'list': 630 640 $tag = 'li'; 631 $before = '<li id="afilter-' . $component _name. '"' . $selected . '>';641 $before = '<li id="afilter-' . $component . '"' . $selected . '>'; 632 642 $after = '</li>'; 633 643 break; 634 644 case 'paragraph': 635 645 $tag = 'p'; 636 $before = '<p id="afilter-' . $component _name. '"' . $selected . '>';646 $before = '<p id="afilter-' . $component . '"' . $selected . '>'; 637 647 $after = '</p>'; 638 648 break; 639 649 case 'span': 640 650 $tag = 'span'; 641 $before = '<span id="afilter-' . $component _name. '"' . $selected . '>';651 $before = '<span id="afilter-' . $component . '"' . $selected . '>'; 642 652 $after = '</span>'; 643 653 break; 644 654 } 645 655 646 $link = add_query_arg( 'afilter', $component _name);656 $link = add_query_arg( 'afilter', $component ); 647 657 $link = remove_query_arg( 'acpage' , $link ); 648 658 649 $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component _name);659 $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component ); 650 660 651 661 /* Make sure all core internal component names are translatable */ 652 $translatable_component _names = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );653 654 $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component _name, 'buddypress' ) ) . '</a>' . $after;662 $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) ); 663 664 $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after; 655 665 } 656 666 … … 745 755 global $activities_template; 746 756 747 $content = explode( '<span', $activities_template->activity->content ); 757 if ( !empty( $activities_template->activity->action ) ) 758 $content = $activities_template->activity->action; 759 else 760 $content = $activities_template->activity->content; 761 762 $content = explode( '<span', $content ); 748 763 $title = trim( strip_tags( html_entity_decode( $content[0] ) ) ); 749 764 … … 751 766 $title = substr( $title, 0, -1 ); 752 767 753 if ( 'activity_update' == $activities_template->activity-> component_action) {768 if ( 'activity_update' == $activities_template->activity->type ) { 754 769 $content = explode( '<div class="activity-inner">', $activities_template->activity->content ); 755 770 $title .= ': ' . strip_tags( bp_create_excerpt( $content[1], 15 )); … … 783 798 global $activities_template; 784 799 785 return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) ); 800 if ( empty( $activities_template->activity->action ) ) 801 $content = $activities_template->activity->content; 802 else 803 $content = $activities_template->activity->action . $activities_template->activity->content; 804 805 return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $content ), ENT_COMPAT, 'UTF-8' ) ); 786 806 } 787 807
Note: See TracChangeset
for help on using the changeset viewer.