public function getAvatar($width) { if ($this->facebook) { return "http://graph.facebook.com/{$this->facebook->oauth_uid}/picture?type=large&width={$width}&height={$width}"; } return Gravatar::src($this->email, 275); }
if (!in_array($image_size, ['large', 'small'])) { throw new \InvalidArgumentException('Requested image_size not recognized.'); } if ($currentUser->twitter_image_url) { if ($image_size == 'large') { return HTML::userTwitterImageUrl($currentUser, 'bigger'); } return HTML::userTwitterImageUrl($currentUser, 'normal'); } if ($currentUser->facebook_uid) { if ($image_size == 'large') { return HTML::userFacebookImageUrl($currentUser, 'large'); } return HTML::userFacebookImageUrl($currentUser, 'small'); } return Gravatar::src($currentUser->email); }); HTML::macro('userFacebookImageUrl', function ($currentUser, $image_size = 'large') { if (!in_array($image_size, ['large', 'small'])) { throw new \InvalidArgumentException('Requested image_size not recognized.'); } $url = 'http://graph.facebook.com/' . $currentUser->facebook_uid . '/picture'; if ($image_size == 'large') { $url .= '?type=large'; } return $url; }); HTML::macro('userTwitterImageUrl', function ($currentUser, $image_size = 'normal') { if (!in_array($image_size, ['normal', 'bigger', 'mini', 'original'])) { throw new \InvalidArgumentException('Requested image_size not recognized.'); }
<div id="lobby"> <div class="caption">Lobby</div> <div id="chatbox"> <form action="' . $_SERVER['REQUEST_URI'] . '" method="post"><div> <input type="hidden" name="lobby" value="1" /> <input id="chat" type="text" name="chat" /> </div></form>'; if (is_array($chat_data)) { $lobby .= ' <dl id="chats">'; foreach ($chat_data as $chat) { // preserve spaces in the chat text $chat['message'] = str_replace("\t", ' ', $chat['message']); $chat['message'] = str_replace(' ', ' ', $chat['message']); if (!isset($gravatars[$chat['email']])) { $gravatars[$chat['email']] = Gravatar::src($chat['email']); } $grav_img = '<img src="' . $gravatars[$chat['email']] . '" alt="" /> '; if ('' == $chat['username']) { $chat['username'] = '******'; } $lobby .= ' <dt>' . $grav_img . '<span>' . ldate(Settings::read('short_date'), strtotime($chat['create_date'])) . '</span> ' . $chat['username'] . '</dt> <dd>' . htmlentities($chat['message'], ENT_QUOTES, 'UTF-8', false) . '</dd>'; } $lobby .= ' </dl> <!-- #chats -->'; } $lobby .= ' </div> <!-- #chatbox --> </div> <!-- #lobby -->';