-function enriched_to_text($input,$html=false,$just=false,$indent=0,$width=68)
-{
- $text = trim($input);
- if ($html) {
- $text = htmlspecialchars($text);
- $text = str_replace('[b]','<strong>', $text);
- $text = str_replace('[/b]','</strong>', $text);
- $text = str_replace('[i]','<em>', $text);
- $text = str_replace('[/i]','</em>', $text);
- $text = str_replace('[u]','<span style="text-decoration: underline">', $text);
- $text = str_replace('[/u]','</span>', $text);
- $text = preg_replace("!(\\s*\n)*\[title\]!",'<h1>',$text);
- $text = preg_replace("!\[\/title\](\\s*\n)*!", '</h1>',$text);
- $text = preg_replace("!(\\s*\n)*\[subtitle\]!",'<h2>',$text);
- $text = preg_replace("!\[\/subtitle\](\\s*\n)*!",'</h2>',$text);
-
- require_once('url_catcher.inc.php');
- $text = url_catcher($text);
- return nl2br($text);
- } else {
- $text = preg_replace('!\[\/?b\]!','*',$text);
- $text = preg_replace('!\[\/?u\]!','_',$text);
- $text = preg_replace('!\[\/?i\]!','/',$text);
- $text = preg_replace('!\[\/?title\]!','***', $text);
- $text = preg_replace('!\[\/?subtitle\]!','**', $text);
- $text = preg_replace('!(((https?|ftp)://|www\.)[^\r\n\t ]*)!','[\1]', $text);
- $text = preg_replace('!(([a-zA-Z0-9\-_+.]*@[a-zA-Z0-9\-_+.]*)(?:\?[^\r\n\t ]*)?)!','[mailto:\1]', $text);
- $text = $just ? justify($text,$width-$indent) : wordwrap($text,$width-$indent);
- if($indent) {
- $ind = str_pad('',$indent);
- $text = $ind.str_replace("\n","\n$ind",$text);
- }
- return $text;
- }
-}