Example #1
0
function worksafe_theme_timeline($feed)
{
    if (count($feed) == 0) {
        return theme('no_tweets');
    }
    $rows = array();
    $page = menu_current_page();
    $date_heading = false;
    foreach ($feed as $status) {
        $time = strtotime($status->created_at);
        if ($time > 0) {
            $date = twitter_date('l jS F Y', strtotime($status->created_at));
            if ($date_heading !== $date) {
                $date_heading = $date;
                $rows[] = array(array('data' => "<b>{$date}</b>", 'colspan' => 2));
            }
        } else {
            $date = $status->created_at;
        }
        $text = twitter_parse_tags($status->text);
        $link = theme('status_time_link', $status, !$status->is_direct);
        $actions = theme('action_icons', $status);
        $source = $status->source ? " from {$status->source}" : '';
        $from = '';
        if ($status->in_reply_to_status_id) {
            $from = "<small>in reply to <a href='status/{$status->in_reply_to_status_id}'>{$status->in_reply_to_screen_name}</a></small>";
        }
        $html = "<b><a href='user/{$status->from->screen_name}'>{$status->from->screen_name}</a></b> {$actions} {$link} {$source}<br /><span class='text'>{$text} {$from}</span>";
        if ($status->retweeted_by) {
            $retweeted_by = $status->retweeted_by->user->screen_name;
            $html .= "<br /><small>retweeted to you by <a href='user/{$retweeted_by}'>{$retweeted_by}</a></small>";
        }
        $row = array($html);
        if ($page != 'user' && $avatar) {
            array_unshift($row, $avatar);
        }
        if ($page != 'replies' && twitter_is_reply($status)) {
            $row = array('class' => 'reply', 'data' => $row);
        }
        $rows[] = $row;
    }
    $content = theme('table', array(), $rows, array('class' => 'timeline'));
    if (count($feed) >= 15) {
        $content .= theme('pagination');
    }
    return $content;
}
Example #2
0
function theme_users_list($feed, $hide_pagination = false)
{
    if (isset($feed->users)) {
        $users = $feed->users;
    } else {
        $users = $feed;
    }
    $rows = array();
    if (count($users) == 0 || $users == '[]') {
        return '<p>No users to display.</p>';
    }
    foreach ($users as $user) {
        $content = "";
        if ($user->user) {
            $user = $user->user;
        }
        $name = theme('full_name', $user);
        $tweets_per_day = twitter_tweets_per_day($user);
        $last_tweet = strtotime($user->status->created_at);
        // $vicon = ($user->verified) ? theme('action_icon', "", '✔', 'verified') : '';
        $content = "{$name}<br />";
        //" <span class=\"actionicons\">{$vicon}</span>";
        $content .= "<span class='about'>";
        if ($user->description != "") {
            $content .= "Bio: " . twitter_parse_tags($user->description, $user->entities->description) . "<br />";
        }
        if ($user->location != "") {
            $content .= theme('action_icon', "https://maps.google.com/maps?q=" . urlencode($user->location), "<span class='icons'>⌖</span> {$user->location}", 'Location');
            $content .= "<br />";
        }
        $content .= "Info: ";
        $content .= pluralise('tweet', $user->statuses_count, true) . ", ";
        $content .= pluralise('friend', $user->friends_count, true) . ", ";
        $content .= pluralise('follower', $user->followers_count, true) . ", ";
        $content .= "~" . pluralise('tweet', $tweets_per_day, true) . " per day<br />";
        if ($user->status->created_at) {
            $content .= "Last tweet: ";
            if ($user->protected == 'true' && $last_tweet == 0) {
                $content .= "Private";
            } else {
                if ($last_tweet == 0) {
                    $content .= "Never tweeted";
                } else {
                    $content .= twitter_date('l jS F Y', $last_tweet);
                }
            }
        }
        $content .= "</span>";
        $rows[] = array('data' => array(array('data' => theme('avatar', theme_get_avatar($user)), 'class' => 'avatar'), array('data' => $content, 'class' => 'status shift')), 'class' => 'tweet');
    }
    $content = theme('table', array(), $rows, array('class' => 'followers'));
    if (!$hide_pagination) {
        #$content .= theme('pagination');
        $content .= theme('list_pagination', $feed);
    }
    return $content;
}
Example #3
0
function theme_search_results($feed)
{
    $rows = array();
    foreach ($feed->results as $status) {
        $text = twitter_parse_tags($status->text, $status->entities);
        $link = theme('status_time_link', $status);
        $actions = theme('action_icons', $status);
        $row = array(theme('avatar', $status->profile_image_url), "<a href='user/{$status->from_user}'>{$status->from_user}</a> {$actions} - {$link}<br />{$text}");
        if (twitter_is_reply($status)) {
            $row = array('class' => 'reply', 'data' => $row);
        }
        $rows[] = $row;
    }
    $content = theme('table', array(), $rows, array('class' => 'timeline'));
    $content .= theme('pagination');
    return $content;
}
Example #4
0
function twitter_user_page($query)
{
    $screen_name = $query[1];
    // echo "<h1>q1 = {$screen_name}</h1>";
    $subaction = $query[2];
    // echo "<h1>q2 = {$subaction}</h1>";
    $in_reply_to_id = (string) $query[3];
    // echo "<h1>q3 = {$in_reply_to_id}</h1>";
    $content = '';
    if (!$screen_name) {
        // theme('error', 'No username given');
        //	Ugly cludge because @user is a real user
        twitter_refresh('user/user');
    }
    // Load up user profile information and one tweet
    $user = twitter_user_info($screen_name);
    // If the user has at least one tweet
    if (isset($user->status)) {
        // Fetch the timeline early, so we can try find the tweet they're replying to
        $cb = get_codebird();
        $api_options = "";
        $per_page = setting_fetch('perPage', 20);
        $api_options = "&count={$per_page}";
        //	If we're paginating through
        if ($_GET['max_id']) {
            $api_options .= '&max_id=' . $_GET['max_id'];
        }
        $api_options .= "&screen_name={$screen_name}";
        $user_timeline = $cb->statuses_userTimeline($api_options);
        twitter_api_status($user_timeline);
        $tl = twitter_standard_timeline($user_timeline, 'user');
        // $content = theme('status_form');
        // $content .= theme('timeline', $tl);
        // theme('page', 'user', $content);
    }
    // Build an array of people we're talking to
    $to_users = array($user->screen_name);
    // Build an array of hashtags being used
    $hashtags = array();
    // Are we replying to anyone?
    if (is_numeric($in_reply_to_id)) {
        $tweet = twitter_find_tweet_in_timeline($in_reply_to_id, $tl);
        $out = twitter_parse_tags($tweet->text);
        $content .= "<p>In reply to:<br />{$out}</p>";
        // if ($subaction == 'replyall') {
        $found = Twitter_Extractor::create($tweet->text)->extractMentionedUsernames();
        $to_users = array_unique(array_merge($to_users, $found));
        // }
        if ($tweet->entities->hashtags) {
            $hashtags = $tweet->entities->hashtags;
        }
    }
    // Build a status message to everyone we're talking to
    $status = '';
    foreach ($to_users as $username) {
        if (!user_is_current_user($username)) {
            $status .= "@{$username} ";
        }
    }
    // Add in the hashtags they've used
    foreach ($hashtags as $hashtag) {
        $status .= "#{$hashtag->text} ";
    }
    $content .= theme('status_form', $status, $in_reply_to_id);
    $content .= theme('user_header', $user);
    $content .= theme('timeline', $tl);
    theme('page', "User {$screen_name}", $content);
}
Example #5
0
function theme_timeline($feed)
{
    if (count($feed) == 0) {
        return theme('no_tweets');
    }
    $hide_pagination = count($feed) < 5 ? true : false;
    $rows = array();
    $page = menu_current_page();
    $date_heading = false;
    $max_id = false;
    foreach ($feed as &$status) {
        $max_id = isset($status->retweeted_by) ? $status->retweeted_by->id_str : $status->id_str;
        $status->text = twitter_parse_tags($status->text, $status->entities, $status->id_str, strip_tags($status->source));
    }
    unset($status);
    // Only embed images in suitable browsers
    if (EMBEDLY_KEY !== '' && setting_fetch('showthumbs', 'yes') == 'yes') {
        embedly_embed_thumbnails($feed);
    }
    foreach ($feed as $status) {
        $time = strtotime($status->created_at);
        if ($time > 0) {
            $date = twitter_date('l jS F Y', strtotime($status->created_at));
            if ($date_heading !== $date) {
                $date_heading = $date;
                $rows[] = array('data' => array("{$date}"), 'class' => 'date');
            }
        } else {
            $date = $status->created_at;
        }
        $link = theme('status_time_link', $status, !$status->is_direct);
        $actions = theme('action_icons', $status);
        $avatar = theme('avatar', img_proxy_url(theme_get_avatar($status->from)));
        if (substr($_GET['q'], 0, 4) == 'user' || setting_fetch('browser') == 'touch' || setting_fetch('browser', 'desktop') == 'desktop') {
            $source = $status->source ? " " . __("via") . " {$status->source}" : '';
        } else {
            $source = $status->source ? " " . __("via") . " " . strip_tags($status->source) . "" : '';
        }
        if ($status->in_reply_to_status_id_str) {
            $replyto = "<a href='" . BASE_URL . "status/{$status->in_reply_to_status_id_str}'>>></a>";
        } else {
            $replyto = null;
        }
        if (setting_fetch('dispnick') == 'yes') {
            $showname = $status->from->name;
        } else {
            $showname = $status->from->screen_name;
        }
        $html = "<b class='suser'><a href='" . BASE_URL . "user/{$status->from->screen_name}'>{$showname}</a></b> ";
        if (setting_fetch('buttonend') == 'yes') {
            $html .= "<span class='stext'>{$status->text}</span><br /><small class='sbutton'>{$actions} {$link} ";
        } else {
            $html .= "<small class='sbutton'>{$actions}</small><br /><span class='stext'>{$status->text}</span><br /><small class='sbutton'>{$link}";
        }
        $html .= " {$source} {$replyto}</small>";
        if ($status->retweeted_by) {
            if (setting_fetch('dispnick') == 'yes') {
                $showrtname = $status->retweeted_by->user->name;
            } else {
                $showrtname = $status->retweeted_by->user->screen_name;
            }
            $retweeted_by = $status->retweeted_by->user->screen_name;
            $retweeted_times = $status->retweet_count;
            $retweeted_times_minus = is_numeric($retweeted_times) ? $retweeted_times - 1 : $retweeted_times;
            $retweeted_times_str = $retweeted_times && $retweeted_times_minus ? "+{$retweeted_times_minus}" : "";
            $html .= " <small class='sretweet'>" . __("retweeted by") . " <a href='" . BASE_URL . "user/{$retweeted_by}'>{$showrtname}</a>{$retweeted_times_str} " . __("<span style='display:none;'>zhuanfa</span>") . "</small>";
        }
        unset($row);
        $class = 'status';
        if ($page != 'user' && $avatar) {
            $row[] = array('data' => $avatar, 'class' => 'avatar');
            $class .= ' shift';
        }
        $row[] = array('data' => $html, 'class' => $class);
        $class = 'tweet';
        if ($page != 'replies' && twitter_is_reply($status)) {
            $class .= ' reply';
        }
        $row = array('data' => $row, 'class' => $class);
        $rows[] = $row;
    }
    $content = theme('table', array(), $rows, array('class' => 'timeline'));
    if ($max_id) {
        if (function_exists('bcsub')) {
            $max_id = bcsub($max_id, '1');
        }
        if (setting_fetch('browser') != 'blackberry' && !$hide_pagination) {
            $content .= theme('pagination', $max_id);
        } else {
            global $blackberry_pagination;
            $blackberry_pagination = theme('pagination', $max_id);
        }
    }
    return $content;
}
Example #6
0
function theme_search_results($feed)
{
    $rows = array();
    foreach ($feed->results as $status) {
        $text = twitter_parse_tags($status->text, $status->entities, $status->id_str);
        $link = theme('status_time_link', $status);
        $actions = theme('action_icons', $status);
        if (setting_fetch('avataro', 'yes') !== 'yes') {
            $row = array(theme('avatar', theme_get_avatar($status), htmlspecialchars($status->name, ENT_QUOTES, 'UTF-8')), "<a href='user/{$status->from_user}'>{$status->from_user}</a> {$actions} - {$link}<br />{$text}");
        } else {
            $row = array("<a href='user/{$status->from_user}'>{$status->from_user}</a> {$actions} - {$link}<br />{$text}");
        }
        if (twitter_is_reply($status)) {
            $row = array('class' => 'reply', 'data' => $row);
        }
        $rows[] = $row;
    }
    $content = theme('table', array(), $rows, array('class' => 'timeline'));
    $content .= theme('pagination');
    return $content;
}
Example #7
0
function theme_users_list($feed, $hide_pagination = false)
{
    if (isset($feed->users)) {
        $users = $feed->users;
    } else {
        $users = $feed;
    }
    $rows = array();
    if (count($users) == 0 || $users == '[]') {
        return '<p>' . _(NO_USERS_FOUND) . '</p>';
    }
    foreach ($users as $user) {
        $content = "";
        if ($user->user) {
            $user = $user->user;
        }
        $name = theme('full_name', $user);
        $tweets_per_day = twitter_tweets_per_day($user);
        $last_tweet = strtotime($user->status->created_at);
        $content = "{$name}<br />";
        $content .= "<span class='about'>";
        if ($user->description != "") {
            $content .= _(PROFILE_BIO) . ": " . twitter_parse_tags($user->description, $user->entities->description) . "<br />";
        }
        if ($user->location != "") {
            $content .= theme('action_icon', "https://maps.google.com/maps?q=" . urlencode($user->location), "<span class='icons'>⌖</span> {$user->location}", _(PROFILE_LOCATION));
            $content .= "<br />";
        }
        $content .= theme_user_info($user);
        if ($user->status->created_at) {
            $content .= " " . _(LAST_TWEET) . ": ";
            if ($user->protected == 'true' && $last_tweet == 0) {
                $content .= _(LAST_TWEET_PRIVATE);
            } else {
                if ($last_tweet == 0) {
                    $content .= _(LAST_TWEET_NEVER);
                } else {
                    $content .= twitter_date('l jS F Y', $last_tweet);
                }
            }
        }
        $content .= "</span>";
        $rows[] = array('data' => array(array('data' => theme('avatar', theme_get_avatar($user)), 'class' => 'avatar'), array('data' => $content, 'class' => 'status shift')), 'class' => 'tweet');
    }
    $content = theme('table', array(), $rows, array('class' => 'followers'));
    if (!$hide_pagination) {
        #$content .= theme('pagination');
        $content .= theme('list_pagination', $feed);
    }
    return $content;
}