Beispiel #1
0
function theme_timeline($feed)
{
    if (count($feed) == 0) {
        return theme('no_tweets');
    }
    if (count($feed) < 2) {
        $hide_pagination = true;
    }
    $rows = array();
    $page = menu_current_page();
    $date_heading = false;
    $first = 0;
    // Add the hyperlinks *BEFORE* adding images
    foreach ($feed as &$status) {
        $status->text = twitter_parse_tags($status->text, $status->entities);
    }
    unset($status);
    // Only embed images in suitable browsers
    if (!in_array(setting_fetch('browser'), array('text', 'worksafe'))) {
        if (EMBEDLY_KEY !== '') {
            embedly_embed_thumbnails($feed);
        }
    }
    foreach ($feed as $status) {
        if ($first == 0) {
            $since_id = $status->id;
            $first++;
        } else {
            $max_id = $status->id;
            if ($status->original_id) {
                $max_id = $status->original_id;
            }
        }
        $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;
        }
        $text = $status->text;
        if (!in_array(setting_fetch('browser'), array('text', 'worksafe'))) {
            $media = twitter_get_media($status);
        }
        $link = theme('status_time_link', $status, !$status->is_direct);
        $actions = theme('action_icons', $status);
        $avatar = theme('avatar', theme_get_avatar($status->from));
        $source = $status->source ? " from " . str_replace('rel="nofollow"', 'rel="nofollow" target="' . get_target() . '"', preg_replace('/&(?![a-z][a-z0-9]*;|#[0-9]+;|#x[0-9a-f]+;)/i', '&amp;', $status->source)) : '';
        //need to replace & in links with &amps and force new window on links
        if ($status->place->name) {
            $source .= " " . $status->place->name . ", " . $status->place->country;
        }
        if ($status->in_reply_to_status_id) {
            $source .= " <a href='status/{$status->in_reply_to_status_id_str}'>in reply to {$status->in_reply_to_screen_name}</a>";
        }
        if ($status->retweet_count) {
            $source .= " <a href='retweeted_by/{$status->id}'>retweeted ";
            switch ($status->retweet_count) {
                case 1:
                    $source .= "once</a>";
                    break;
                case 2:
                    $source .= "twice</a>";
                    break;
                default:
                    $source .= $status->retweet_count . " times</a>";
            }
        }
        if ($status->retweeted_by) {
            $retweeted_by = $status->retweeted_by->user->screen_name;
            $source .= "<br /><a href='retweeted_by/{$status->id}'>retweeted</a> by <a href='user/{$retweeted_by}'>{$retweeted_by}</a>";
        }
        $html = "<b><a href='user/{$status->from->screen_name}'>{$status->from->screen_name}</a></b> {$actions} {$link}<br />{$text}<br />{$media}<small>{$source}</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 ($page != '' && !$hide_pagination) {
        $content .= theme('pagination');
    } else {
        if (!$hide_pagination) {
            //Doesn't work. since_id returns the most recent tweets up to since_id, not since. Grrr
            //$links[] = "<a href='{$_GET['q']}?since_id=$since_id'>Newer</a>";
            if (is_64bit()) {
                $max_id = intval($max_id) - 1;
            }
            //stops last tweet appearing as first tweet on next page
            $links[] = "<a href='{$_GET['q']}?max_id={$max_id}' accesskey='9'>Older</a> 9";
            $content .= '<p>' . implode(' | ', $links) . '</p>';
        }
    }
    return $content;
}
Beispiel #2
0
function theme_timeline($feed, $paginate = true)
{
    if (count($feed) == 0) {
        return theme('no_tweets');
    }
    if (count($feed) < 2) {
        $hide_pagination = true;
    }
    $rows = array();
    $page = menu_current_page();
    $date_heading = false;
    $first = 0;
    // Add the hyperlinks *BEFORE* adding images
    foreach ($feed as &$status) {
        $status->text = twitter_parse_tags($status->text, $status->entities);
    }
    unset($status);
    // Only embed images in suitable browsers
    if (!setting_fetch('hide_inline') && !in_array(setting_fetch('browser'), array('text', 'worksafe'))) {
        embedly_embed_thumbnails($feed);
    }
    foreach ($feed as $status) {
        if ($first == 0) {
            $since_id = $status->id;
            $first++;
        } else {
            $max_id = $status->id;
            if ($status->original_id) {
                $max_id = $status->original_id;
            }
        }
        $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;
        }
        $text = $status->text;
        if (!in_array(setting_fetch('browser'), array('text', 'worksafe'))) {
            $media = twitter_get_media($status);
        }
        $link = theme('status_time_link', $status, !$status->is_direct);
        $actions = theme('action_icons', $status);
        $avatar = theme('avatar', theme_get_avatar($status->from));
        $source = $status->source ? " from " . str_replace('rel="nofollow"', 'rel="nofollow" target="' . get_target() . '"', preg_replace('/&(?![a-z][a-z0-9]*;|#[0-9]+;|#x[0-9a-f]+;)/i', '&amp;', $status->source)) : '';
        //need to replace & in links with &amps and force new window on links
        if ($status->place->name) {
            $source .= ", " . $status->place->name . ", " . $status->place->country;
        }
        if ($status->in_reply_to_status_id) {
            $source .= ", in reply to <a href='status/{$status->in_reply_to_status_id_str}'>{$status->in_reply_to_screen_name}</a>";
        }
        if ($status->retweet_count) {
            $source .= ", <a href='retweeted_by/{$status->id}'>retweeted " . x_times($status->retweet_count) . "</a>";
        }
        $retweeted = '';
        if ($status->retweeted_by) {
            $retweeted_by = $status->retweeted_by->user->screen_name;
            $retweeted = "<br /><small>" . theme('action_icon', "retweeted_by/{$status->id}", 'images/retweet.png', 'RT') . "retweeted by <a href='user/{$retweeted_by}'>{$retweeted_by}</a></small>";
            //$source .= "<br /><a href='retweeted_by/{$status->id}'>retweeted</a> by <a href='user/{$retweeted_by}'>{$retweeted_by}</a>";
        }
        if ($status->favorite_count) {
            $source .= ', favourited ' . x_times($status->favorite_count);
        }
        //$html = "<b><a href='user/{$status->from->screen_name}'>{$status->from->screen_name}</a></b> $actions $link<br />{$text}<br />$media<small>$source</small>";
        $html = "<b><a href='user/{$status->from->screen_name}'>{$status->from->screen_name}</a></b> {$actions} {$link}{$retweeted}<br />{$text}<br />{$media}<span class='from'>{$source}</span>";
        unset($row);
        $class = 'status';
        if ($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 (!$hide_pagination) {
        if ($paginate) {
            if ($page == 'some-unknown-method-which-doesnt-take-max_id') {
                $content .= theme('pagination');
            } else {
                if (is_64bit()) {
                    $max_id = intval($max_id) - 1;
                }
                //stops last tweet appearing as first tweet on next page
                $content .= theme('pagination', $max_id);
            }
        }
    }
    return $content;
}
Beispiel #3
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;
}
Beispiel #4
0
function theme_timeline($feed)
{
    if (count($feed) == 0) {
        return theme('no_tweets');
    }
    if (count($feed) < 2) {
        $hide_pagination = true;
    }
    $rows = array();
    $page = menu_current_page();
    $date_heading = false;
    $first = 0;
    // Add the hyperlinks *BEFORE* adding images
    foreach ($feed as &$status) {
        $status->text = twitter_parse_tags($status->text, $status->entities, $status->id_str);
    }
    unset($status);
    //Add in images
    if (EMBEDLY_KEY !== '') {
        embedly_embed_thumbnails($feed);
    }
    foreach ($feed as $status) {
        if ($first == 0) {
            $since_id = $status->id;
            $first++;
        } else {
            $max_id = $status->id;
            if ($status->original_id) {
                $max_id = $status->original_id;
            }
        }
        $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;
        }
        // Old Filter
        /*
        if ((setting_fetch('filtero', 'no') == 'yes') && twitter_timeline_filter($status->text)) {
            $text = "<a href='status/{$status->id}' class='filter'><span class='texts'>[Tweet Filtered]</span></a>";
        } else {
            $text = $status->text;
            setting_fetch('hide_inline') || $media = twitter_get_media($status);
        }
        */
        $text = $status->text;
        setting_fetch('hide_inline') || setting_fetch('filtero', 'no') == 'yes' || setting_fetch('filterc') || ($media = twitter_get_media($status));
        setting_fetch('buttontime', 'yes') == 'yes' && ($link = theme('status_time_link', $status, !$status->is_direct));
        $actions = theme('action_icons', $status);
        if (setting_fetch('avataro', 'yes') !== 'yes') {
            $avatar = theme('avatar', theme_get_avatar($status->from), htmlspecialchars($status->from->name, ENT_QUOTES, 'UTF-8'));
        }
        if (setting_fetch('buttonfrom', 'yes') == 'yes') {
            if (substr($_GET['q'], 0, 4) == 'user' || setting_fetch('browser') == 'touch' || setting_fetch('browser') == 'desktop' || setting_fetch('browser') == 'bigtouch') {
                $source = $status->source ? " via " . str_replace('rel="nofollow"', 'rel="external nofollow noreferrer"', preg_replace('/&(?![a-z][a-z0-9]*;|#[0-9]+;|#x[0-9a-f]+;)/i', '&amp;', $status->source)) : '';
                //need to replace & in links with &amps and force new window on links
            } else {
                $source = $status->source ? " via " . strip_tags($status->source) . "" : '';
            }
        } else {
            $source = NULL;
        }
        if ($status->place->name) {
            $source .= " " . $status->place->name . ", " . $status->place->country;
        }
        if ($status->in_reply_to_status_id) {
            $source .= " <a href='status/{$status->in_reply_to_status_id_str}'>in reply to {$status->in_reply_to_screen_name}</a>";
        }
        if ($status->retweet_count) {
            $source .= " <a href='retweeted_by/{$status->id}'>retweeted ";
            switch ($status->retweet_count) {
                case 1:
                    $source .= "once</a>";
                    break;
                case 2:
                    $source .= "twice</a>";
                    break;
                    //Twitter are uncapping the retweet count (https://dev.twitter.com/discussions/5129) will need to correctly format large numbers
                //Twitter are uncapping the retweet count (https://dev.twitter.com/discussions/5129) will need to correctly format large numbers
                case is_int($status->retweet_count):
                    $source .= number_format($status->retweet_count) . " times</a>";
                    break;
                    //Legacy for old tweets where the retweet count is a string (usually "100+")
                //Legacy for old tweets where the retweet count is a string (usually "100+")
                default:
                    $source .= $status->retweet_count . " times</a>";
            }
        }
        if ($status->retweeted_by) {
            $retweeted_by = $status->retweeted_by->user->screen_name;
            $source .= "<br /><a href='retweeted_by/{$status->id}'>retweeted</a> by <a href='user/{$retweeted_by}'>{$retweeted_by}</a>";
        }
        $html = "<span class='textb'><a href='user/{$status->from->screen_name}'>{$status->from->screen_name}</a></span> {$actions} <span class='texts'>{$link}</span><br />{$text}<br />{$media}<span class='texts'>{$source}</span>";
        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 ($page != '' && !$hide_pagination) {
        $content .= theme('pagination');
    } else {
        if (!$hide_pagination) {
            //Doesn't work. since_id returns the most recent tweets up to since_id, not since. Grrr
            //$links[] = "<a href='{$_GET['q']}?since_id=$since_id'>Newer</a>";
            if (is_64bit()) {
                $max_id = intval($max_id) - 1;
            }
            //stops last tweet appearing as first tweet on next page
            $links[] = "<a href='{$_GET['q']}?max_id={$max_id}' accesskey='9'>Older</a> 9";
            $content .= '<p>' . implode(' | ', $links) . '</p>';
        }
    }
    return $content;
}