/** * Check whether a username is valid. * * @param string $username The username to validate. * @return boolean Whether the username is valid. */ public function isValidUsername($username = null) { if (is_null($username)) { $username = $this->tweet; } $length = mb_strlen($username); if (empty($username) || !$length) { return false; } $extracted = $this->extractor->extractMentionedScreennames($username); return count($extracted) === 1 && $extracted[0] === substr($username, 1); }
function theme_action_icons($status) { $from = $status->from->screen_name; $retweeted_by = $status->retweeted_by->user->screen_name; $retweeted_id = $status->retweeted_by->id; $geo = $status->geo; $actions = array(); if (!$status->is_direct) { $actions[] = theme('action_icon', "user/{$from}/reply/{$status->id}", 'images/reply.png', '@'); } //Reply All functionality. if (substr_count($status->text, '@') >= 1) { $found = Twitter_Extractor::extractMentionedScreennames($status->text); $to_users = array_unique($found); $key = array_search(user_current_username(), $to_users); // Remove the username of the authenticated user if ($key != NULL || $key !== FALSE) { unset($to_users[$key]); // remove the username from array } if (count($to_users) >= 1) { $actions[] = theme('action_icon', "user/{$from}/replyall/{$status->id}", 'images/replyall.png', 'REPLY ALL'); } } if (!user_is_current_user($from)) { $actions[] = theme('action_icon', "directs/create/{$from}", 'images/dm.png', 'DM'); } if (!$status->is_direct) { if ($status->favorited == '1') { $actions[] = theme('action_icon', "unfavourite/{$status->id}", 'images/star.png', 'UNFAV'); } else { $actions[] = theme('action_icon', "favourite/{$status->id}", 'images/star_grey.png', 'FAV'); } $actions[] = theme('action_icon', "retweet/{$status->id}", 'images/retweet.png', 'RT'); if (user_is_current_user($from)) { $actions[] = theme('action_icon', "confirm/delete/{$status->id}", 'images/trash.gif', 'DEL'); } if ($retweeted_by) { if (user_is_current_user($retweeted_by)) { $actions[] = theme('action_icon', "confirm/delete/{$retweeted_id}", 'images/trash.gif', 'DEL'); } } } else { $actions[] = theme('action_icon', "directs/delete/{$status->id}", 'images/trash.gif', 'DEL'); } if ($geo !== null) { $latlong = $geo->coordinates; $lat = $latlong[0]; $long = $latlong[1]; $actions[] = theme('action_icon', "http://maps.google.co.uk/m?q={$lat},{$long}", 'images/map.png', 'MAP'); } //Search for @ to a user $actions[] = theme('action_icon', "search?query=%40{$from}", 'images/q.png', '?'); return implode(' ', $actions); }