'\1', 'html' => false ); $options = array_merge($default, $options); extract($options); if (is_array($phrase)) { $replace = array(); $with = array(); foreach ($phrase as $key => $segment) { $segment = "($segment)"; if ($html) { $segment = "(?![^<]+>)$segment(?![^<]+>)"; } $with[] = (is_array($format)) ? $format[$key] : $format; $replace[] = "|$segment|iu"; } return preg_replace($replace, $with, $text); } else { $phrase = "($phrase)"; if ($html) { $phrase = "(?![^<]+>)$phrase(?![^<]+>)"; } return preg_replace("|$phrase|iu", $format, $text); } } /** * Strips given text of all links (]+>|im', '', preg_replace('|<\/a>|im', '', $text)); } /** * Adds links (_linkOptions = $htmlOptions; $text = preg_replace_callback( '#(?)((?:https?|ftp|nntp)://[^\s<>()]+)#i', array(&$this, '_linkBareUrl'), $text ); return preg_replace_callback( '#(?)(?Html->link($matches[0], $matches[0], $this->_linkOptions); } /** * Links urls missing http:// * * @param array $matches * @return string * @see TextHelper::autoLinkUrls() */ private function _linkUrls($matches) { return $this->Html->link($matches[0], 'http://' . $matches[0], $this->_linkOptions); } /** * Links email addresses * * @param array $matches * @return string * @see TextHelper::autoLinkUrls() */ private function _linkEmails($matches) { return $this->Html->link($matches[0], 'mailto:' . $matches[0], $this->_linkOptions); } /** * Adds email links (