CODE
final protected function parseBody($data) {
// First clean up the data
$data = nl2br(htmlspecialchars(trim($data)));
// Make links 'clickable
$data = preg_replace('/(^|\s)(http|https|news|ftp):\/\/([^\s]*)/i', '<a href="\\2://\\3" title="Visit \\2://\\3">\\2://\\3</a>', $data);
// Patterns to replace
$patterns = array('/\[b\](.*?)\[\/b\]/i',
'/\[u\](.*?)\[\/u\]/i',
'/\[i\](.*?)\[\/i\]/i',
'/\[url=(.*?)\](.*?)\[\/url\]/i',
'/\[url\](.*?)\[\/url\]/i',
'/\[img\](.*?)\[\/img\]/i',
'/\[color=(.*?)\](.*?)\[\/color\]/i',
'/\[font=(.*?)\](.*?)\[\/font\]/i',
'/\[size=(.*?)\](.*?)\[\/size\]/i'
);
// Text to replace
$replacements = array('<strong>\\1</strong>',
'<u>\\1</u>',
'<em>\\1</em>',
'<a href="\\1" title="Visit \\2">\\2</a>',
'<a href="\\1" title="Visit \\1">\\1</a>',
'<img src="\\1" alt="Posted image" />',
'<span style="color: \\1">\\2</span>',
'<span style="font-family: \\1">\\2</span>',
'<span style="font-size: \\1">\\2</span>'
);
return preg_replace($patterns, $replacements, $data);
}
// First clean up the data
$data = nl2br(htmlspecialchars(trim($data)));
// Make links 'clickable
$data = preg_replace('/(^|\s)(http|https|news|ftp):\/\/([^\s]*)/i', '<a href="\\2://\\3" title="Visit \\2://\\3">\\2://\\3</a>', $data);
// Patterns to replace
$patterns = array('/\[b\](.*?)\[\/b\]/i',
'/\[u\](.*?)\[\/u\]/i',
'/\[i\](.*?)\[\/i\]/i',
'/\[url=(.*?)\](.*?)\[\/url\]/i',
'/\[url\](.*?)\[\/url\]/i',
'/\[img\](.*?)\[\/img\]/i',
'/\[color=(.*?)\](.*?)\[\/color\]/i',
'/\[font=(.*?)\](.*?)\[\/font\]/i',
'/\[size=(.*?)\](.*?)\[\/size\]/i'
);
// Text to replace
$replacements = array('<strong>\\1</strong>',
'<u>\\1</u>',
'<em>\\1</em>',
'<a href="\\1" title="Visit \\2">\\2</a>',
'<a href="\\1" title="Visit \\1">\\1</a>',
'<img src="\\1" alt="Posted image" />',
'<span style="color: \\1">\\2</span>',
'<span style="font-family: \\1">\\2</span>',
'<span style="font-size: \\1">\\2</span>'
);
return preg_replace($patterns, $replacements, $data);
}
Can someone help me at [ list ] tags, and collapsing of multiple spans into single, ie
CODE
[font=arial][color=red][size=6]
becomes
CODE
<span style="font-family: arial; color: red; font-size: 6;">
instead of
CODE
<span style="font-family: arial;"><span style="color: red;"><span style="font-size: 6;">