21 lines
642 B
PHP
21 lines
642 B
PHP
<?php
|
|
|
|
class Zend_View_Helper_MatchUrl extends Zend_View_Helper_Abstract {
|
|
|
|
public function MatchUrl($text){
|
|
|
|
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
|
|
|
|
preg_match_all($reg_exUrl, $text, $matches);
|
|
$usedPatterns = array();
|
|
foreach($matches[0] as $pattern){
|
|
if(!array_key_exists($pattern, $usedPatterns)){
|
|
$usedPatterns[$pattern]=true;
|
|
$text = str_replace($pattern, '<a href="'.$pattern.'" rel="nofollow" target="_blank" >'.$pattern.'</a>', $text);
|
|
}
|
|
}
|
|
return $text;
|
|
}
|
|
|
|
}
|