support various and multiple content_types on the display side - still have some work to do on the posting side.

This commit is contained in:
friendica 2013-03-21 16:14:08 -07:00
parent c3590f6454
commit b3c699d49a

View File

@ -969,7 +969,7 @@ function prepare_body($item,$attach = false) {
$a = get_app(); $a = get_app();
call_hooks('prepare_body_init', $item); call_hooks('prepare_body_init', $item);
$s = prepare_text($item['body']); $s = prepare_text($item['body'],$item['mimetype']);
$prep_arr = array('item' => $item, 'html' => $s); $prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body', $prep_arr); call_hooks('prepare_body', $prep_arr);
@ -1080,14 +1080,35 @@ function prepare_body($item,$attach = false) {
// Given a text string, convert from bbcode to html and add smilie icons. // Given a text string, convert from bbcode to html and add smilie icons.
function prepare_text($text) { function prepare_text($text,$content_type = 'text/bbcode') {
require_once('include/bbcode.php');
if(stristr($text,'[nosmile]')) switch($content_type) {
$s = bbcode($text);
else case 'text/plain':
$s = smilies(bbcode($text)); $s = escape_tags($text);
break;
case 'text/html':
$s = $text;
break;
case 'text/markdown':
require_once('library/markdown.php');
$s = Markdown($text);
break;
case 'text/bbcode':
case '':
default:
require_once('include/bbcode.php');
if(stristr($text,'[nosmile]'))
$s = bbcode($text);
else
$s = smilies(bbcode($text));
break;
}
return $s; return $s;
} }