Exemple #1
0
 public static function formatText($text)
 {
     $text = preg_replace_callback('/<code_html>(.*?)<\\/code_html>/is', create_function('$matches', 'return htmlspecialchars($matches[1]);'), $text);
     $text = preg_replace_callback('/<code_php>(.*?)<\\/code_php>/is', create_function('$matches', 'return highlight_string("<?php $matches[1] ?>", true);'), $text);
     $text = preg_replace('/<br \\/>/is', '', $text);
     $text = preg_replace('#(^|\\s)([a-z]+://([^\\s\\w/]?[\\w/])*)(\\s|$)#im', '\\1<a href="\\2">\\2</a>\\4', $text);
     $text = preg_replace('#(^|\\s)wp:?([a-z]{2}|):([\\w]+)#im', '\\1<a href="http://\\2.wikipedia.org/wiki/\\3">\\3</a>', $text);
     $text = str_replace('http://.wikipedia.org/wiki/', 'http://www.wikipedia.org/wiki/', $text);
     $text = str_replace('\\wp:', 'wp:', $text);
     $text = str_replace('\\http:', 'http:', $text);
     $text = MyTool::formatBBCode($text);
     $text = nl2br($text);
     return $text;
 }