Beispiel #1
0
function twitter_parse_tags($input, $entities = false)
{
    //Expanded t.co links to find thumbnails etc
    if ($entities) {
        foreach ($entities->urls as $urls) {
            if ($urls->expanded_url != "") {
                $input = str_replace($urls->url, $urls->expanded_url, $input);
            }
        }
    }
    $urls = Twitter_Extractor::extractURLS($input);
    $out = $input;
    foreach ($urls as $value) {
        $out = str_replace($value, long_url($value), $out);
    }
    $autolink = new Dabr_Autolink();
    $out = $autolink->autolink($out);
    //If this is worksafe mode - don't display any images
    if (!in_array(setting_fetch('browser'), array('text', 'worksafe'))) {
        //Add in images
        $out = twitter_embed_thumbnails($out);
    }
    //Linebreaks.  Some clients insert \n for formatting.
    $out = nl2br($out);
    //Return t.co links back else breaking Twitter T&Cs
    if ($entities) {
        foreach ($entities->urls as $urls) {
            if ($urls->expanded_url != "") {
                $out = preg_replace('#(?<=(\\"|\'|\\>))' . preg_quote($urls->expanded_url, '#') . '(?=(\\"|\'|\\<))#i', $urls->url, $out);
            }
        }
    }
    //Return the completed string
    return $out;
}
Beispiel #2
0
function twitter_parse_tags($input)
{
    $urls = Twitter_Extractor::extractURLS($input);
    $out = $input;
    foreach ($urls as $value) {
        $out = str_replace($value, long_url($value), $out);
    }
    $autolink = new Dabr_Autolink();
    $out = $autolink->autolink($out);
    //If this is worksafe mode - don't display any images
    if (!in_array(setting_fetch('browser'), array('text', 'worksafe'))) {
        //Add in images
        $out = twitter_photo_replace($out);
    }
    //Linebreaks.  Some clients insert \n for formatting.
    $out = nl2br($out);
    //Return the completed string
    return $out;
}