From b3c699d49a5ef2023fcbdaa8226be95fce9589a7 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 21 Mar 2013 16:14:08 -0700 Subject: support various and multiple content_types on the display side - still have some work to do on the posting side. --- include/text.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 3899d8915..13e95f2d1 100644 --- a/include/text.php +++ b/include/text.php @@ -969,7 +969,7 @@ function prepare_body($item,$attach = false) { $a = get_app(); 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); 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. -function prepare_text($text) { +function prepare_text($text,$content_type = 'text/bbcode') { - require_once('include/bbcode.php'); - if(stristr($text,'[nosmile]')) - $s = bbcode($text); - else - $s = smilies(bbcode($text)); + switch($content_type) { + + case 'text/plain': + $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; } -- cgit v1.2.3