function wfUserProfileLatestThought( $user_profile ) { global $wgUser, $wgOut; $user_id = $user_profile->user_id; $s = new UserStatus(); $user_update = $s->getStatusMessages( $user_id, 0, 0, 1, 1 ); $user_update = ( !empty( $user_update[0] ) ? $user_update[0] : array() ); // Safe URLs $more_thoughts_link = SpecialPage::getTitleFor( 'UserStatus' ); $thought_link = SpecialPage::getTitleFor( 'ViewThought' ); $output = ''; if ( $user_update ) { $output .= '<div class="user-section-heading"> <div class="user-section-title">' . wfMsg( 'sportsteams-profile-latest-thought' ) . '</div> <div class="user-section-actions"> <div class="action-right"> <a href="' . $more_thoughts_link->escapeFullURL( 'user='******'" rel="nofollow">' . wfMsg( 'sportsteams-profile-view-all' ) . '</a> </div> <div class="cleared"></div> </div> </div>'; $vote_count = $vote_link = ''; // If someone agrees with the most recent status update, show the count // next to the timestamp to the owner of the status update // After all, there's no point in showing "0 people agree with this"... if( $wgUser->getName() == $user_update['user_name'] && $user_update['plus_count'] > 0 ) { $vote_count = wfMsgExt( 'sportsteams-profile-num-agree', 'parsemag', $user_update['plus_count'] ); } $view_thought_link = '<a href="' . $thought_link->escapeFullURL( "id={$user_update['id']}" ) . "\" rel=\"nofollow\">{$vote_count}</a>"; // Allow registered users who are not owners of this status update to // vote for it unless they've already voted; if they have voted, show // the amount of people who agree with the status update if( $wgUser->isLoggedIn() && $wgUser->getName() != $user_update['user_name'] ) { if( !$user_update['voted'] ) { $vote_link = "<a href=\"javascript:void(0);\" onclick=\"SportsTeamsUserProfile.voteStatus({$user_update['id']},1)\" rel=\"nofollow\">" . wfMsg( 'sportsteams-profile-do-you-agree' ) . '</a>'; } else { $vote_count = wfMsgExt( 'sportsteams-profile-num-agree', 'parsemag', $user_update['plus_count'] ); } } $output .= '<div class="status-container" id="status-update"> <div id="status-update" class="status-message">' . SportsTeams::getLogo( $user_update['sport_id'], $user_update['team_id'], 's' ) . "{$user_update['text']} </div> <div class=\"user-status-profile-vote\"> <span class=\"user-status-date\">" . wfMsg( 'sportsteams-profile-ago', SportsTeams::getTimeAgo( $user_update['timestamp'] ) ) . "</span> {$vote_link} {$view_thought_link} </div> </div>"; } else { $output .= "<script type=\"text/javascript\">var __thoughts_text__ = \"" . wfMsg( 'sportsteams-profile-latest-thought' ) . '"; var __view_all__ = "' . wfMsg( 'sportsteams-profile-view-all' ) . '"; var __more_thoughts_url__ = "' . $more_thoughts_link->escapeFullURL( 'user='******'";</script>'; } $wgOut->addHTML( $output ); return true; }