ProtectString($String);
return $this->BBEncode($String);
} else {
return $String;
}
}
function ProtectString ($String) {
$String = str_replace("<", "<", $String);
$String = str_replace("\r\n", "
", $String);
return $String;
}
function BBEncode($String) {
//[img] tags
$String = preg_replace("/\[img\](.+?)\[\/img\]/","",$String);
//[url] tags
$String = preg_replace("/\[url\=(.+?)\](.+?)\[\/url\]/","$2",$String);
$String = preg_replace("/\[url\](.+?)\[\/url\]/","$1",$String);
$String = preg_replace("/\[email\](.+?)\[\/email\]/","$1",$String);
// other stuff
$String = preg_replace("/\[b\](.+?)\[\/b\]/","$1",$String);
$String = preg_replace("/\[u\](.+?)\[\/u\]/","$1",$String);
$String = preg_replace("/\[i\](.+?)\[\/i\]/","$1",$String);
$String = preg_replace("/\[code\](.+?)\[\/code\]/","
$1",$String);
$String = preg_replace("/\[quote\](.+?)\[\/quote\]/","$1",$String);
$String = preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/","$2",$String);
$String = preg_replace("/\[img\](.+?)\[\/img\]/","",$String);
return $String;
}
}
// Instantiate the bbcode object and add it to the string manipulation methods
$BBCodeFormatter = $Context->ObjectFactory->NewObject($Context, "BBCodeFormatter");
$Context->StringManipulator->AddManipulator("BBCode", $BBCodeFormatter);
?>