/**
 * Turns all urls and email addresses into clickable links. The +link+ parameter can limit what should be linked.
 * Options are :all (default), :email_addresses, and :urls.
 *
 * Example:
 *   auto_link("Go to http://www.symfony-project.com and say hello to fabien.potencier@example.com") =>
 *     Go to <a href="http://www.symfony-project.com">http://www.symfony-project.com</a> and
 *     say hello to <a href="mailto:fabien.potencier@example.com">fabien.potencier@example.com</a>
 */
function auto_link_text($text, $link = 'all', $href_options = array())
{
    if ($link == 'all') {
        return _auto_link_urls(_auto_link_email_addresses($text), $href_options);
    } else {
        if ($link == 'email_addresses') {
            return _auto_link_email_addresses($text);
        } else {
            if ($link == 'urls') {
                return _auto_link_urls($text, $href_options);
            }
        }
    }
}
示例#2
0
/**
 * Turns all urls and email addresses into clickable links. The +link+ parameter can limit what should be linked.
 * Options are :all (default), :email_addresses, and :urls.
 *
 * Example:
 *   auto_link("Go to http://www.symfony-project.com and say hello to fabien.potencier@example.com") =>
 *     Go to <a href="http://www.symfony-project.com">http://www.symfony-project.com</a> and
 *     say hello to <a href="mailto:fabien.potencier@example.com">fabien.potencier@example.com</a>
 */
function auto_link_text($text, $link = 'all', $href_options = array(), $truncate = false, $truncate_len = 35, $pad = '...')
{
    if ($link == 'all') {
        return _auto_link_urls(_auto_link_email_addresses($text), $href_options, $truncate, $truncate_len, $pad);
    } else {
        if ($link == 'email_addresses') {
            return _auto_link_email_addresses($text);
        } else {
            if ($link == 'urls') {
                return _auto_link_urls($text, $href_options, $truncate, $truncate_len, $pad);
            }
        }
    }
}
/**
 * Turns all URIs into clickable links.
 * Fixes a tokenization problem with hash URIs
 */
function auto_link_uri($text, $href_options = array())
{
  $link = _auto_link_urls($text, $href_options);

  return preg_replace('/#(.+)/', '%23$1', $link);
}