Esempio n. 1
0
/**
 * Helper for displaying formatted text
 *
 * @package    phpCollab3
 * @subpackage idProjectManagmentPlugin Helpers
 * @author     Filippo (p16) De Santis <*****@*****.**>
 * @author     Andrea (giorg) Giorgini <*****@*****.**>
 */
function auto_link($text, $link = 'all')
{
    if ($link == 'all') {
        return _auto_link(_auto_link_email_addresses($text));
    } else {
        if ($link == 'email_addresses') {
            return _auto_link_email_addresses($text);
        } else {
            if ($link == 'urls') {
                return _auto_link($text);
            }
        }
    }
}
Esempio n. 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);
            }
        }
    }
}
Esempio n. 3
0
/**
 * op_auto_link_text_for_mobile
 *
 * @param string  $text
 * @param mixed   $link         Types of text that is linked. (all|urls|email_addresses|phone_numbers)
 * @param boolean $truncate
 * @param integer $truncate_len
 * @param string  $pad
 * @param boolean $is_allow_outer_url
 */
function op_auto_link_text_for_mobile($text, $link = null, $href_options = array(), $truncate = true, $truncate_len = 37, $pad = '...', $is_allow_outer_url = null)
{
    use_helper('Text');
    if (null === $link) {
        $link = sfConfig::get('op_default_mobile_auto_link_type', 'urls');
    }
    if (!$link) {
        return $text;
    }
    if (!is_array($link)) {
        $link = array($link);
    }
    if (in_array('all', $link)) {
        $link = array('urls', 'email_addresses', 'phone_numbers');
    }
    if (null === $is_allow_outer_url) {
        $is_allow_outer_url = sfConfig::get('op_default_mobile_auto_link_is_allow_outer_url', true);
    }
    $result = $text;
    if (in_array('email_addresses', $link)) {
        $result = _auto_link_email_addresses($result);
    }
    if (in_array('phone_numbers', $link)) {
        $result = _op_auto_links_phone_number($result);
    }
    if (in_array('urls', $link)) {
        $result = _op_auto_links_urls($result, $href_options, $truncate, $truncate_len, $pad);
        if ($is_allow_outer_url) {
            $result = _op_auto_links_outer_urls($result, $href_options, $truncate, $truncate_len, $pad);
        }
    }
    return $result;
}
Esempio n. 4
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())
{
    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);
            }
        }
    }
}