From 87de83997499a380ef26d72acb6d5fd3df91e95b Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 24 May 2011 20:41:29 -0700 Subject: attachment display --- boot.php | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index faf3c4db4..b328eec0e 100644 --- a/boot.php +++ b/boot.php @@ -2540,8 +2540,40 @@ function link_compare($a,$b) { if(! function_exists('prepare_body')) { -function prepare_body($item) { - return prepare_text($item['body']); +function prepare_body($item,$attach = false) { + + $s = prepare_text($item['body']); + if(! $attach) + return $s; + + $arr = explode(',',$item['attach']); + if(count($arr)) { + foreach($arr as $r) { + $matches = false; + $icon = ''; + $cnt = preg_match('|\[attach\]href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" title=\"(.+?)\"\[\/attach\]|',$r,$matches); + if($cnt) { + $icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/'))); + switch($icontype) { + case 'video': + case 'audio': + case 'image': + case 'text': + $icon = '
'; + break; + default: + $icon = '
'; + break; + } + $title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1])); + $title .= ' ' . $matches[2] . ' ' . t('bytes'); + + $s .= '' . $icon . ''; + } + } + } + $s .= '
'; + return $s; }} if(! function_exists('prepare_text')) { -- cgit v1.2.3