<?php
/**
* Filter for bold url Tags
* @access public
* @author Jörg Stöber <hide@address.com>
* @version 0.5.3 ($Id: url.class.php,v 1.1 2004/03/29 22:45:31 cb_fog Exp $)
*/
class BB_FILTER_url {
/* Parse a given text after url BB Tags
* @access public
* @param string $text text to parse
* @return string $text parsed text
*/
function parse($text) {
$text = preg_replace('/\[url](.*)\[\/url\]/miUs', '<a href="\1" target=_blank>\1</a>', $text);
$text = preg_replace('/\[url=((["\']?)([^"\'\(\)\%\;\=]*))\2](.*)\[\/url\]/miUs', '<a href="\3" target=_blank>\4</a>', $text);
return $text;
}
/* Reverse the parsing process (HTML -> BB)
* @access public
* @param string $text text to parse
* @return string $text parsed text
*/
function parseReverse($text) {
$text = preg_replace("/<a href=\"(http|https|ftp)?(:\/\/\S+)?([\.a-z0-9-_]*)\">(http|https|ftp)?(:\/\/\S+)?([ a-z0-9_-]*)<\/a>/is" , "[url=\\1\\2\\3\]\\4\\5\\6[/url]" , $text);
$text = preg_replace("/<a href=\"(http|https|ftp)?(:\/\/\S+)?([\.a-z0-9-_]*)\" target=_blank>(http|https|ftp)?(:\/\/\S+)?([ a-z0-9_-]*)<\/a>/is" , "[url=\\1\\2\\3\]\\4\\5\\6[/url]" , $text);
return $text;
}
}
?>