Exemplo n.º 1
0
function autolink(&$text, $nofollow = false)
{
    // grab anything that looks like a URL...
    $urls = _autolink_find_URLS($text);
    if (!empty($urls)) {
        //array_walk( $urls, '_autolink_create_html_tags', array('target'=>$target, 'nofollow'=>$nofollow) );
        array_walk($urls, '_autolink_create_html_tags', array('nofollow' => $nofollow));
        $text = strtr($text, $urls);
    }
}
function twitterit(&$text, $twitter_username, $target = '_blank', $nofollow = true)
{
    $urls = _autolink_find_URLS($text);
    if (!empty($urls)) {
        array_walk($urls, '_autolink_create_html_tags', array('target' => $target, 'nofollow' => $nofollow));
        $text = strtr($text, $urls);
    }
    $text = preg_replace("/(\\s@|^@)([a-zA-Z0-9]{1,15})/", "\$1<a href=\"http://twitter.com/\$2\" target=\"_blank\" rel=\"nofollow\">\$2</a>", $text);
    $text = preg_replace("/(\\s#|^#)([a-zA-Z0-9]{1,15})/", "\$1<a href=\"http://twitter.com/#!/search?q=\$2\" target=\"_blank\" rel=\"nofollow\">\$2</a>", $text);
    $text = str_replace($twitter_username . ": ", "", $text);
    return $text;
}