Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2009 07:54:21 PM (16 years ago)
Author:
apeatling
Message:

Merging 1.1 branch changes and syncing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-templatetags.php

    r2071 r2077  
    88    var $activity;
    99    var $activity_type;
    10    
     10
    1111    var $in_the_loop;
    12    
     12
    1313    var $pag_page;
    1414    var $pag_num;
     
    2626        if ( $type == 'sitewide' )
    2727            $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page, $filter );
    28        
     28
    2929        if ( $type == 'personal' )
    3030            $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter );
     
    3232        if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) )
    3333            $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter );
    34        
     34
    3535        if ( !$max || $max >= (int)$this->activities['total'] )
    3636            $this->total_activity_count = (int)$this->activities['total'];
    3737        else
    3838            $this->total_activity_count = (int)$max;
    39        
     39
    4040        $this->activities = $this->activities['activities'];
    41        
     41
    4242        if ( $max ) {
    4343            if ( $max >= count($this->activities) )
     
    4848            $this->activity_count = count($this->activities);
    4949        }
    50        
     50
    5151        $this->full_name = $bp->displayed_user->fullname;
    5252
     
    6363        }
    6464    }
    65    
     65
    6666    function has_activities() {
    6767        if ( $this->activity_count )
    6868            return true;
    69        
     69
    7070        return false;
    7171    }
    72    
     72
    7373    function next_activity() {
    7474        $this->current_activity++;
    7575        $this->activity = $this->activities[$this->current_activity];
    76        
     76
    7777        return $this->activity;
    7878    }
    79    
     79
    8080    function rewind_activities() {
    8181        $this->current_activity = -1;
     
    8484        }
    8585    }
    86    
    87     function user_activities() { 
     86
     87    function user_activities() {
    8888        if ( $this->current_activity + 1 < $this->activity_count ) {
    8989            return true;
     
    9797        return false;
    9898    }
    99    
     99
    100100    function the_activity() {
    101101        global $activity;
     
    103103        $this->in_the_loop = true;
    104104        $this->activity = $this->next_activity();
    105        
     105
    106106        if ( is_array( $this->activity ) )
    107107            $this->activity = (object) $this->activity;
     
    114114function bp_has_activities( $args = '' ) {
    115115    global $bp, $activities_template;
    116    
     116
    117117    /* Note: any params used for filtering can be a single value, or multiple values comma separated. */
    118    
     118
    119119    $defaults = array(
    120120        'type' => 'sitewide',
     
    138138            $per_page = $max;
    139139    }
    140    
     140
    141141    if ( isset( $_GET['afilter'] ) )
    142142        $filter = array( 'object' => $_GET['afilter'] );
    143143    else
    144144        $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 );
    147147    return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
    148148}
     
    160160function bp_activity_pagination_count() {
    161161    global $bp, $activities_template;
    162    
     162
    163163    $from_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
    164164    $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) ;
     
    173173    function bp_get_activity_pagination_links() {
    174174        global $activities_template;
    175        
     175
    176176        return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
    177177    }
     
    179179function bp_activities_title() {
    180180    global $bp_activity_title;
    181    
     181
    182182    echo bp_get_activities_title();
    183183}
     
    190190function bp_activities_no_activity() {
    191191    global $bp_activity_no_activity;
    192    
     192
    193193    echo bp_get_activities_no_activity();
    194194}
    195195    function bp_get_activities_no_activity() {
    196196        global $bp_activity_no_activity;
    197        
     197
    198198        return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
    199199    }
     
    218218            'height' => 20,
    219219            'class' => 'avatar',
    220             'alt' => __( 'Avatar', 'buddypress' ) 
     220            'alt' => __( 'Avatar', 'buddypress' )
    221221        );
    222222
    223223        $r = wp_parse_args( $args, $defaults );
    224224        extract( $r, EXTR_SKIP );
    225        
     225
    226226        $item_id = false;
    227227        if ( (int)$activities_template->activity->user_id )
     
    235235        if ( $bp->blogs->id == $activities_template->activity->component_name && !(int) $activities_template->activity->user_id )
    236236            $object = 'blog';
    237        
     237
    238238        $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component_name, $object );
    239        
     239
    240240        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 ) ) );
    241241    }
     
    248248
    249249        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 );
    251251        else
    252252            $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false );
     
    254254        /* Add 'the_content' filter to activity to allow existing plugins to replace text as they would on post text. (extra smilies etc) */
    255255        $content = apply_filters( 'the_content', $content );
    256        
     256
    257257        return apply_filters( 'bp_get_activity_content', $content );
    258258    }
     
    260260function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) {
    261261    global $activities_template, $bp;
    262    
     262
    263263    if ( !$content )
    264264        return false;
    265        
     265
    266266    /* Split the content so we don't evaluate and replace text on content we don't want to */
    267267    $content = explode( '%s', $content );
     
    273273    if ( $insert_time )
    274274        $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded );
    275    
     275
    276276    // The "You" and "Your" conversion is only done in english, if a translation file is present
    277277    // then do not translate as it causes problems in other languages.
     
    284284        /* Remove the 'You' and replace if with the persons name */
    285285        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 );
    287287        }
    288288    }
     
    290290    /* Add the delete link if the user has permission on this item */
    291291    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
    294294    $content_new = '';
    295    
     295
    296296    for ( $i = 0; $i < count($content); $i++ )
    297297        $content_new .= $content[$i];
    298    
     298
    299299    return apply_filters( 'bp_activity_content_filter', $content_new );
    300300}
     
    306306    // Make sure we don't have any URL encoding in links when trying to insert the time.
    307307    $content = urldecode($content);
    308    
     308
    309309    return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( '&nbsp; %s ago', 'buddypress' ), bp_core_time_since( strtotime( $date ) ) ) ) );
    310310}
     
    315315    function bp_get_activity_css_class() {
    316316        global $activities_template;
    317        
     317
    318318        return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name );
    319319    }
     
    333333    function bp_get_activity_filter_links( $args = false ) {
    334334        global $activities_template, $bp;
    335        
     335
    336336        $defaults = array(
    337337            'style' => 'list'
     
    340340        $r = wp_parse_args( $args, $defaults );
    341341        extract( $r, EXTR_SKIP );
    342        
     342
    343343        /* Fetch the names of components that have activity recorded in the DB */
    344344        $component_names = BP_Activity_Activity::get_recorded_component_names();
    345        
     345
    346346        if ( !$component_names )
    347347            return false;
    348        
     348
    349349        foreach ( (array) $component_names as $component_name ) {
    350350            if ( isset( $_GET['afilter'] ) && $component_name == $_GET['afilter'] )
     
    352352            else
    353353                unset($selected);
    354            
     354
     355            $component_name = attribute_escape( $component_name );
     356
    355357            $component_name = attribute_escape( $component_name );
    356358
     
    372374                break;
    373375            }
    374            
     376
    375377            $link = add_query_arg( 'afilter', $component_name );
    376378            $link = remove_query_arg( 'acpage' , $link );
    377379
    378380            $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component_name );
    379            
     381
    380382            /* Make sure all core internal component names are translatable */
    381383            $translatable_component_names = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
    382            
     384
    383385            $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component_name, 'buddypress' ) ) . '</a>' . $after;
    384386        }
     
    388390        if ( isset( $_GET['afilter'] ) )
    389391            $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
    390        
    391         return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
     392
     393        return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
    392394    }
    393395
     
    410412            return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/feed' );
    411413        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' );
    413415    }
    414416
     
    421423        global $activities_template;
    422424
    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 ) );
    424426    }
    425427
     
    453455
    454456function bp_activity_feed_item_description() {
    455     echo bp_get_activity_feed_item_description();   
     457    echo bp_get_activity_feed_item_description();
    456458}
    457459    function bp_get_activity_feed_item_description() {
    458460        global $activities_template;
    459461
    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' ) );
    461463    }
    462464
Note: See TracChangeset for help on using the changeset viewer.