Skip to:
Content

BuddyPress.org

Changeset 4678


Ignore:
Timestamp:
07/18/2011 07:01:49 AM (8 years ago)
Author:
johnjamesjacoby
Message:

Swap '0 seconds ago' out for 'right now.' Includes changes to bp_core_time_since() and removes references to 'ago' as needed to avoid possible 'right now ago' condition.

Location:
trunk
Files:
13 edited

Legend:

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

    r4674 r4678  
    10091009            return false;
    10101010       
    1011         $date_recorded = sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->current_comment->date_recorded ) );
     1011        $date_recorded = bp_core_time_since( $activities_template->activity->current_comment->date_recorded );
    10121012       
    10131013        return apply_filters( 'bp_activity_comment_date_recorded', $date_recorded );
  • trunk/bp-blogs/bp-blogs-template.php

    r4651 r4678  
    315315        global $blogs_template;
    316316
    317         return apply_filters( 'bp_blog_last_active', bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s ago', 'buddypress' ) ) );
     317        return apply_filters( 'bp_blog_last_active', bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s', 'buddypress' ) ) );
    318318    }
    319319
  • trunk/bp-core/bp-core-classes.php

    r4634 r4678  
    169169        $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
    170170        $this->avatar_mini  = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
    171         $this->last_active  = bp_core_get_last_activity( bp_get_user_meta( $this->id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) );
     171        $this->last_active  = bp_core_get_last_activity( bp_get_user_meta( $this->id, 'last_activity', true ), __( 'active %s', 'buddypress' ) );
    172172    }
    173173
  • trunk/bp-core/bp-core-functions.php

    r4663 r4678  
    598598function bp_core_time_since( $older_date, $newer_date = false ) {
    599599
     600    // Setup the strings
     601    $unknown_text   = apply_filters( 'bp_core_time_since_unknown_text',   __( 'sometime',  'buddypress' ) );
     602    $right_now_text = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) );
     603    $ago_text       = apply_filters( 'bp_core_time_since_ago_text',       __( '%s ago',    'buddypress' ) );
     604   
    600605    // array of time period chunks
    601606    $chunks = array(
    602         array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
    603         array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
    604         array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
    605         array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
    606         array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
    607         array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
    608         array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
     607        array( 60 * 60 * 24 * 365 , __( 'year',   'buddypress' ), __( 'years',  'buddypress' ) ),
     608        array( 60 * 60 * 24 * 30 ,  __( 'month',  'buddypress' ), __( 'months', 'buddypress' ) ),
     609        array( 60 * 60 * 24 * 7,    __( 'week',   'buddypress' ), __( 'weeks',  'buddypress' ) ),
     610        array( 60 * 60 * 24 ,       __( 'day',    'buddypress' ), __( 'days',    'buddypress' ) ),
     611        array( 60 * 60 ,            __( 'hour',   'buddypress' ), __( 'hours',  'buddypress' ) ),
     612        array( 60 ,                 __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
     613        array( 1,                   __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
    609614    );
    610615
     
    626631
    627632    // Something went wrong with date calculation and we ended up with a negative date.
    628     if ( 0 > $since )
    629         return __( 'sometime', 'buddypress' );
    630 
     633    if ( 0 > $since ) {
     634        $output = $unknown_text;
     635       
    631636    /**
    632637     * We only want to output two chunks of time here, eg:
     
    635640     * so there's only two bits of calculation below:
    636641     */
    637 
    638     // Step one: the first chunk
    639     for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
    640         $seconds = $chunks[$i][0];
    641 
    642         // Finding the biggest chunk (if the chunk fits, break)
    643         if ( ( $count = floor($since / $seconds) ) != 0 )
    644             break;
    645     }
    646 
    647     // If $i iterates all the way to $j, then the event happened 0 seconds ago
    648     if ( !isset( $chunks[$i] ) )
    649         return '0 ' . __( 'seconds', 'buddypress' );
    650 
    651     // Set output var
    652     $output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
    653 
    654     // Step two: the second chunk
    655     if ( $i + 2 < $j ) {
    656         $seconds2 = $chunks[$i + 1][0];
    657         $name2 = $chunks[$i + 1][1];
    658 
    659         if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
    660             // Add to output var
    661             $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
     642    } else {
     643
     644        // Step one: the first chunk
     645        for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
     646            $seconds = $chunks[$i][0];
     647
     648            // Finding the biggest chunk (if the chunk fits, break)
     649            if ( ( $count = floor($since / $seconds) ) != 0 ) {
     650                break;
     651            }
    662652        }
    663     }
    664 
    665     if ( !(int)trim( $output ) )
    666         $output = '0 ' . __( 'seconds', 'buddypress' );
     653
     654        // If $i iterates all the way to $j, then the event happened 0 seconds ago
     655        if ( !isset( $chunks[$i] ) ) {
     656            $output = $right_now_text;
     657
     658        } else {
     659
     660            // Set output var
     661            $output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
     662
     663            // Step two: the second chunk
     664            if ( $i + 2 < $j ) {
     665                $seconds2 = $chunks[$i + 1][0];
     666                $name2 = $chunks[$i + 1][1];
     667
     668                if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
     669                    // Add to output var
     670                    $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
     671                }
     672            }
     673
     674            // No output, so happened right now
     675            if ( !(int)trim( $output ) ) {
     676                $output = $right_now_text;
     677            }
     678        }
     679    }
     680
     681    // Append 'ago' to the end of time-since if not 'right now'
     682    if ( $output != $right_now_text ) {
     683        $output = sprintf( $ago_text, $output );
     684    }
    667685
    668686    return $output;
  • trunk/bp-groups/bp-groups-template.php

    r4649 r4678  
    10231023                <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5>
    10241024                <span class="activity">
    1025                     <?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?>
     1025                    <?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s', 'buddypress') ); ?>
    10261026                </span>
    10271027
     
    10881088                <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5>
    10891089
    1090                 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
     1090                <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s', 'buddypress') ); ?></span>
    10911091
    10921092                <?php if ( bp_is_active( 'friends' ) ) : ?>
     
    18531853        global $members_template;
    18541854
    1855         return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( $members_template->member->date_modified, __( 'joined %s ago', 'buddypress') ) );
     1855        return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( $members_template->member->date_modified, __( 'joined %s', 'buddypress') ) );
    18561856    }
    18571857
     
    25092509    global $requests_template;
    25102510
    2511     echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) );
     2511    echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) );
    25122512}
    25132513
  • trunk/bp-groups/bp-groups-widgets.php

    r4648 r4678  
    6565                                <?php
    6666                                    if ( 'newest' == $instance['group_default'] )
    67                                         printf( __( 'created %s ago', 'buddypress' ), bp_get_group_date_created() );
     67                                        printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
    6868                                    if ( 'active' == $instance['group_default'] )
    69                                         printf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active() );
     69                                        printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() );
    7070                                    else if ( 'popular' == $instance['group_default'] )
    7171                                        bp_group_member_count();
     
    165165                                <?php
    166166                                if ( 'newest-groups' == $_POST['filter'] ) {
    167                                     printf( __( 'created %s ago', 'buddypress' ), bp_get_group_date_created() );
     167                                    printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
    168168                                } else if ( 'recently-active-groups' == $_POST['filter'] ) {
    169                                     printf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active() );
     169                                    printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() );
    170170                                } else if ( 'popular-groups' == $_POST['filter'] ) {
    171171                                    bp_group_member_count();
  • trunk/bp-members/bp-members-template.php

    r4645 r4678  
    495495
    496496        if ( isset( $members_template->member->last_activity ) )
    497             $last_activity = bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s ago', 'buddypress' ) );
     497            $last_activity = bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s', 'buddypress' ) );
    498498        else
    499499            $last_activity = __( 'Never active', 'buddypress' );
     
    557557        global $members_template;
    558558
    559         $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
     559        $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s', 'buddypress' ) ) );
    560560
    561561        return apply_filters( 'bp_member_last_active', $registered );
     
    751751            $user_id = $bp->displayed_user->id;
    752752
    753         $last_activity = bp_core_get_last_activity( bp_get_user_meta( $user_id, 'last_activity', true ), __('active %s ago', 'buddypress') );
     753        $last_activity = bp_core_get_last_activity( bp_get_user_meta( $user_id, 'last_activity', true ), __('active %s', 'buddypress') );
    754754
    755755        return apply_filters( 'bp_get_last_activity', $last_activity );
  • trunk/bp-messages/bp-messages-template.php

    r4669 r4678  
    848848        global $thread_template;
    849849
    850         return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) );
     850        return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) );
    851851    }
    852852
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r4671 r4678  
    528528                <?php echo bp_loggedin_user_avatar( 'type=thumb&width=30&height=30' ); ?>
    529529
    530                 <strong><a href="<?php echo $bp->loggedin_user->domain ?>"><?php echo $bp->loggedin_user->fullname ?></a> <span class="activity"><?php printf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( bp_core_current_time() ) ) ?></span></strong>
     530                <strong><a href="<?php echo $bp->loggedin_user->domain ?>"><?php echo $bp->loggedin_user->fullname ?></a> <span class="activity"><?php printf( __( 'Sent %s', 'buddypress' ), bp_core_time_since( bp_core_current_time() ) ) ?></span></strong>
    531531
    532532                <?php do_action( 'bp_after_message_meta' ) ?>
  • trunk/bp-themes/bp-default/forums/single/forum-header.php

    r4012 r4678  
    1111<div id="item-header-content">
    1212    <h2><a href="<?php bp_forum_permalink(); ?>" title="<?php bp_forum_name(); ?>"><?php bp_forum_name(); ?></a></h2>
    13     <span class="highlight"><?php //bp_forum_type(); ?></span> <span class="activity"><?php printf( __( 'active %s ago', 'buddypress' ), '' ); //bp_get_forum_last_active() ); ?></span>
     13    <span class="highlight"><?php //bp_forum_type(); ?></span> <span class="activity"><?php printf( __( 'active %s', 'buddypress' ), '' ); //bp_get_forum_last_active() ); ?></span>
    1414
    1515    <?php do_action( 'bp_before_forum_header_meta' ); ?>
  • trunk/bp-themes/bp-default/groups/groups-loop.php

    r3810 r4678  
    4545            <div class="item">
    4646                <div class="item-title"><a href="<?php bp_group_permalink(); ?>"><?php bp_group_name(); ?></a></div>
    47                 <div class="item-meta"><span class="activity"><?php printf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active() ); ?></span></div>
     47                <div class="item-meta"><span class="activity"><?php printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() ); ?></span></div>
    4848
    4949                <div class="item-desc"><?php bp_group_description_excerpt(); ?></div>
  • trunk/bp-themes/bp-default/groups/single/group-header.php

    r3899 r4678  
    4040<div id="item-header-content">
    4141    <h2><a href="<?php bp_group_permalink(); ?>" title="<?php bp_group_name(); ?>"><?php bp_group_name(); ?></a></h2>
    42     <span class="highlight"><?php bp_group_type(); ?></span> <span class="activity"><?php printf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active() ); ?></span>
     42    <span class="highlight"><?php bp_group_type(); ?></span> <span class="activity"><?php printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() ); ?></span>
    4343
    4444    <?php do_action( 'bp_before_group_header_meta' ); ?>
  • trunk/bp-xprofile/bp-xprofile-template.php

    r4558 r4678  
    714714
    715715        if ( $last_updated )
    716             return apply_filters( 'bp_get_profile_last_updated', sprintf( __('Profile updated %s ago', 'buddypress'), bp_core_time_since( strtotime( $last_updated ) ) ) );
     716            return apply_filters( 'bp_get_profile_last_updated', sprintf( __('Profile updated %s', 'buddypress'), bp_core_time_since( strtotime( $last_updated ) ) ) );
    717717
    718718        return false;
Note: See TracChangeset for help on using the changeset viewer.