Esempio n. 1
0
 /**
  * Auto-links URLs in plain text. This text should generally already be HTML
  * escaped, because it can't be done after the linking.
  *
  * @param string $string
  * @param boolean $htmlEncoded Denotes whether the text is already encoded; if false, the URL will be encoded before being put into the link
  *
  * @return string Text with links added
  */
 public static function autoLinkPlainText($string, $htmlEncoded = true)
 {
     self::$_alptHtmlEncoded = $htmlEncoded;
     return preg_replace_callback('#(?<=[^a-z0-9@-]|^)(https?://|ftp://|www\\.)[^\\s"]+#i', array('self', '_autoLinkPlainTextCallback'), $string);
 }
Esempio n. 2
0
 /**
  * Auto-links URLs in plain text. This text should generally already be HTML
  * escaped, because it can't be done after the linking.
  *
  * @param string $string
  * @param boolean $htmlEncoded Denotes whether the text is already encoded; if false, the URL will be encoded before being put into the link
  *
  * @return string Text with links added
  */
 public static function autoLinkPlainText($string, $htmlEncoded = true)
 {
     self::$_alptHtmlEncoded = $htmlEncoded;
     $string = self::moveHtmlToPlaceholders($string);
     $string = preg_replace_callback('#(?<=[^a-z0-9@-]|^)(https?://|www\\.)[^\\s"]+#i', array('self', '_autoLinkPlainTextCallback'), $string);
     $string = self::restoreHtmlPlaceholders($string);
     return $string;
 }