diff options
author | friendica <info@friendica.com> | 2013-03-21 16:14:08 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-03-21 16:14:08 -0700 |
commit | b3c699d49a5ef2023fcbdaa8226be95fce9589a7 (patch) | |
tree | db463b34b65794b4d798bbfb39d8e355049575d1 /include/text.php | |
parent | c3590f6454f856b7890dee7dc2178cef3f09cb11 (diff) | |
download | volse-hubzilla-b3c699d49a5ef2023fcbdaa8226be95fce9589a7.tar.gz volse-hubzilla-b3c699d49a5ef2023fcbdaa8226be95fce9589a7.tar.bz2 volse-hubzilla-b3c699d49a5ef2023fcbdaa8226be95fce9589a7.zip |
support various and multiple content_types on the display side - still have some work to do on the posting side.
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 35 |
1 files changed, 28 insertions, 7 deletions
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; } |