Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/21/2011 12:03:25 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Move more user functions out of core component and into user component. Fixes to loaders. More code clean-up.

File:
1 edited

Legend:

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

    r3755 r3778  
    218218     * pass their parameters directly to the loop.
    219219     */
    220     $user_id = false;
    221     $include = false;
    222     $exclude = false;
    223     $in = false;
     220    $user_id     = false;
     221    $include     = false;
     222    $exclude     = false;
     223    $in          = false;
    224224    $show_hidden = false;
    225     $object = false;
    226     $primary_id = false;
     225    $object      = false;
     226    $primary_id  = false;
    227227
    228228    // User filtering
     
    309309                        $primary_id = implode( ',', (array)$groups['groups'] );
    310310
    311                         $user_id = false;
     311                        $user_id = 0;
    312312                    }
    313313                    break;
     
    324324                    $search_terms = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '<'; // Start search at @ symbol and stop search at closing tag delimiter.
    325325                    $display_comments = 'stream';
    326                     $user_id = false;
     326                    $user_id = 0;
    327327                    break;
    328328            }
     
    330330    }
    331331
    332     if ( $max ) {
    333         if ( $per_page > $max )
    334             $per_page = $max;
    335     }
     332    // Do not exceed the maximum per page
     333    if ( !empty( $max ) && ( (int)$per_page > (int)$max ) )
     334        $per_page = $max;
    336335
    337336    // Support for basic filters in earlier BP versions.
     
    365364
    366365        $start_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
    367         $from_num = bp_core_number_format( $start_num );
    368         $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
    369         $total = bp_core_number_format( $activities_template->total_activity_count );
     366        $from_num  = bp_core_number_format( $start_num );
     367        $to_num    = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
     368        $total     = bp_core_number_format( $activities_template->total_activity_count );
    370369
    371370        return sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' &nbsp; <span class="ajax-loader"></span>';
     
    393392   
    394393    $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) );
    395    
    396     $has_more_items = (int)$remaining_pages ? true : false;
     394    $has_more_items  = (int)$remaining_pages ? true : false;
    397395   
    398396    return apply_filters( 'bp_activity_has_more_items', $has_more_items );
     
    646644
    647645        $action = $activities_template->activity->action;
    648 
    649646        $action = apply_filters( 'bp_get_activity_action_pre_meta', $action, &$activities_template->activity );
    650647
     
    661658        global $activities_template;
    662659
    663         /* Backwards compatibility if action is not being used */
     660        // Backwards compatibility if action is not being used
    664661        if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
    665662            $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
     
    744741        extract( $r, EXTR_SKIP );
    745742
    746         /* Get the ID of the parent activity content */
     743        // Get the ID of the parent activity content
    747744        if ( !$parent_id = $activities_template->activity->item_id )
    748745            return false;
    749746
    750         /* Get the content of the parent */
     747        // Get the content of the parent
    751748        if ( empty( $activities_template->activity_parents[$parent_id] ) )
    752749            return false;
     
    757754            $content = $activities_template->activity_parents[$parent_id]->action . ' ' . $activities_template->activity_parents[$parent_id]->content;
    758755
    759         /* Remove the time since content for backwards compatibility */
     756        // Remove the time since content for backwards compatibility
    760757        $content = str_replace( '<span class="time-since">%s</span>', '', $content );
    761758
    762         /* Remove images */
     759        // Remove images
    763760        $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
    764761
     
    788785        return apply_filters( 'bp_activity_get_comments', $comments_html );
    789786    }
    790         /* TODO: The HTML in this function is temporary and will be moved to the template in a future version. */
     787        // TODO: The HTML in this function is temporary and will be moved
     788        // to the template in a future version
    791789        function bp_activity_recurse_comments( $comment ) {
    792790            global $activities_template, $bp;
     
    804802                $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_acomment_name', $comment->user_fullname, $comment ) . '</a> &middot; ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $comment->date_recorded ) );
    805803
    806                 /* Reply link - the span is so that threaded reply links can be hidden when JS is off. */
     804                // Reply link - the span is so that threaded reply links can be
     805                // hidden when JS is off.
    807806                if ( is_user_logged_in() && bp_activity_can_comment_reply( $comment ) )
    808807                    $content .= apply_filters( 'bp_activity_comment_reply_link', '<span class="acomment-replylink"> &middot; <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a></span>', $comment );
    809808
    810                 /* Delete link */
     809                // Delete link
    811810                if ( $bp->loggedin_user->is_super_admin || $bp->loggedin_user->id == $comment->user_id ) {
    812811                    $delete_url = wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/?cid=' . $comment->id, 'bp_activity_delete_link' );
     
    950949    }
    951950
    952 function bp_activity_latest_update( $user_id = false ) {
     951function bp_activity_latest_update( $user_id = 0 ) {
    953952    echo bp_get_activity_latest_update( $user_id );
    954953}
    955     function bp_get_activity_latest_update( $user_id = false ) {
     954    function bp_get_activity_latest_update( $user_id = 0 ) {
    956955        global $bp;
    957956
     
    981980        extract( $r, EXTR_SKIP );
    982981
    983         /* Fetch the names of components that have activity recorded in the DB */
     982        // Fetch the names of components that have activity recorded in the DB
    984983        $components = BP_Activity_Activity::get_recorded_components();
    985984
     
    10221021            $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
    10231022
    1024             /* Make sure all core internal component names are translatable */
     1023            // Make sure all core internal component names are translatable
    10251024            $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
    10261025
     
    10641063}
    10651064
    1066 function bp_total_favorite_count_for_user( $user_id = false ) {
     1065function bp_total_favorite_count_for_user( $user_id = 0 ) {
    10671066    echo bp_get_total_favorite_count_for_user( $user_id );
    10681067}
    1069     function bp_get_total_favorite_count_for_user( $user_id = false ) {
     1068    function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
    10701069        return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) );
    10711070    }
    10721071
    1073 function bp_total_mention_count_for_user( $user_id = false ) {
     1072function bp_total_mention_count_for_user( $user_id = 0 ) {
    10741073    echo bp_get_total_favorite_count_for_user( $user_id );
    10751074}
    1076     function bp_get_total_mention_count_for_user( $user_id = false ) {
     1075    function bp_get_total_mention_count_for_user( $user_id = 0 ) {
    10771076        return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true ) );
    10781077    }
     
    10881087
    10891088        return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) );
     1089    }
     1090
     1091function bp_mentioned_user_display_name( $user_id_or_username ) {
     1092    echo bp_get_mentioned_user_display_name( $user_id_or_username );
     1093}
     1094    function bp_get_mentioned_user_display_name( $user_id_or_username ) {
     1095        if ( !$name = bp_core_get_user_displayname( $user_id_or_username ) )
     1096            $name = __( 'a user', 'buddypress' );
     1097
     1098        return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
    10901099    }
    10911100
     
    11531162        global $bp;
    11541163
    1155         $link = '';
    1156 
    11571164        if ( $bp->current_component == $bp->profile->slug || 'just-me' == $bp->current_action )
    11581165            $link = $bp->displayed_user->domain . $bp->activity->slug . '/feed/';
     
    11651172        elseif ( 'mentions' == $bp->current_action )
    11661173            $link = $bp->displayed_user->domain . $bp->activity->slug . '/mentions/feed/';
     1174        else
     1175            $link = '';
    11671176
    11681177        return apply_filters( 'bp_get_activities_member_rss_link', $link );
     
    11711180
    11721181
    1173 /* Template tags for RSS feed output */
     1182/** Template tags for RSS feed output *****************************************/
    11741183
    11751184function bp_activity_feed_item_guid() {
     
    12421251 * @since 1.3
    12431252 */
    1244 function bp_dtheme_sitewide_feed() {
     1253function bp_activity_sitewide_feed() {
    12451254?>
    1246 <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_sitewide_activity_feed_link() ?>" />
     1255
     1256    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_sitewide_activity_feed_link() ?>" />
     1257
    12471258<?php
    12481259}
    1249 add_action( 'bp_head', 'bp_dtheme_sitewide_feed' );
    1250 
    1251 /**
    1252  * Template tag so we can hook member activity feed to <head>
    1253  *
    1254  * @since 1.3
    1255  */
    1256 function bp_dtheme_member_feed() {
    1257     if ( !bp_is_member() )
    1258         return;
     1260add_action( 'bp_head', 'bp_activity_sitewide_feed' );
     1261
    12591262?>
    1260         <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php bp_displayed_user_fullname() ?> | <?php _e( 'Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_member_activity_feed_link() ?>" />
    1261 <?php
    1262 }
    1263 add_action( 'bp_head', 'bp_dtheme_member_feed' );
    1264 
    1265 /**
    1266  * Template tag so we can hook group activity feed to <head>
    1267  *
    1268  * @since 1.3
    1269  */
    1270 function bp_dtheme_group_feed() {
    1271     if ( !bp_is_active( 'groups' ) || !bp_is_group() )
    1272         return;
    1273 ?>
    1274         <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php bp_current_group_name() ?> | <?php _e( 'Group Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_group_activity_feed_link() ?>" />
    1275 <?php
    1276 }
    1277 add_action( 'bp_head', 'bp_dtheme_group_feed' );
    1278 ?>
Note: See TracChangeset for help on using the changeset viewer.