diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ItemObject.php | 16 | ||||
-rw-r--r-- | include/conversation.php | 32 | ||||
-rwxr-xr-x | include/items.php | 2 | ||||
-rw-r--r-- | include/photos.php | 2 | ||||
-rw-r--r-- | include/text.php | 88 |
5 files changed, 73 insertions, 67 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php index 5296a1cf0..46bb78ecd 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -278,13 +278,21 @@ class Item extends BaseObject { $children = $this->get_children(); + $is_photo = (($item['resource_type'] == 'photo') ? true : false) && feature_enabled($conv->get_profile_owner(),'large_photos'); + + $has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false); + $tmp_item = array( 'template' => $this->get_template(), 'mode' => $mode, 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), - 'tags' => array(), - 'body' => $body, - 'text' => strip_tags($body), + 'body' => $body['html'], + 'tags' => $body['tags'], + 'categories' => $body['categories'], + 'mentions' => $body['mentions'], + 'attachments' => $body['attachments'], + 'folders' => $body['folders'], + 'text' => strip_tags($body['html']), 'id' => $this->get_id(), 'mid' => $item['mid'], 'isevent' => $isevent, @@ -325,6 +333,8 @@ class Item extends BaseObject { 'owner_url' => $this->get_owner_url(), 'owner_photo' => $this->get_owner_photo(), 'owner_name' => $this->get_owner_name(), + 'is_photo' => $is_photo, + 'has_tags' => $has_tags, // Item toolbar buttons 'like' => $like, diff --git a/include/conversation.php b/include/conversation.php index 0f6f8685b..0d357e2eb 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -629,11 +629,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ if($item['author-link'] && (! $item['author-name'])) $profile_name = $item['author-link']; - - $tags=array(); - $hashtags = array(); - $mentions = array(); - $sp = false; $profile_link = best_link_url($item,$sp); if($sp) @@ -678,14 +673,17 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $unverified = ''; - $tags=array(); - $terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN)); - if(count($terms)) - foreach($terms as $tag) - $tags[] = format_term_for_display($tag); +// $tags=array(); +// $terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN)); +// if(count($terms)) +// foreach($terms as $tag) +// $tags[] = format_term_for_display($tag); $body = prepare_body($item,true); + $is_photo = (($item['resource_type'] == 'photo') ? true : false); + $has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false); + $tmp_item = array( 'template' => $tpl, 'toplevel' => 'toplevel_item', @@ -699,10 +697,12 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ 'lock' => $lock, 'thumb' => $profile_avatar, 'title' => $item['title'], - 'body' => $body, - 'tags' => $tags, - 'hashtags' => $hashtags, - 'mentions' => $mentions, + 'body' => $body['html'], + 'tags' => $body['tags'], + 'categories' => $body['categories'], + 'mentions' => $body['mentions'], + 'attachments' => $body['attachments'], + 'folders' => $body['folders'], 'verified' => $verified, 'unverified' => $unverified, 'forged' => $forged, @@ -712,7 +712,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ 'has_folders' => ((count($folders)) ? 'true' : ''), 'categories' => $categories, 'folders' => $folders, - 'text' => strip_tags($body), + 'text' => strip_tags($body['html']), 'ago' => relative_date($item['created']), 'app' => $item['app'], 'str_app' => sprintf( t('from %s'), $item['app']), @@ -738,6 +738,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ 'previewing' => $previewing, 'wait' => t('Please wait'), 'thread_level' => 1, + 'is_photo' => $is_photo, + 'has_tags' => $has_tags, ); $arr = array('item' => $item, 'output' => $tmp_item); diff --git a/include/items.php b/include/items.php index e7cc02579..3b0072956 100755 --- a/include/items.php +++ b/include/items.php @@ -889,6 +889,7 @@ function get_item_elements($x,$allow_code = false) { $arr['mimetype'] = (($x['mimetype']) ? htmlspecialchars($x['mimetype'], ENT_COMPAT,'UTF-8',false) : ''); $arr['obj_type'] = (($x['object_type']) ? htmlspecialchars($x['object_type'], ENT_COMPAT,'UTF-8',false) : ''); $arr['tgt_type'] = (($x['target_type']) ? htmlspecialchars($x['target_type'], ENT_COMPAT,'UTF-8',false) : ''); + $arr['resource_type'] = (($x['resource_type']) ? htmlspecialchars($x['resource_type'], ENT_COMPAT,'UTF-8',false) : ''); $arr['public_policy'] = (($x['public_scope']) ? htmlspecialchars($x['public_scope'], ENT_COMPAT,'UTF-8',false) : ''); if($arr['public_policy'] === 'public') @@ -1285,6 +1286,7 @@ function encode_item($item,$mirror = false) { $x['verb'] = $item['verb']; $x['object_type'] = $item['obj_type']; $x['target_type'] = $item['tgt_type']; + $x['resource_type'] = $item['resource_type']; $x['permalink'] = $item['plink']; $x['location'] = $item['location']; $x['longlat'] = $item['coord']; diff --git a/include/photos.php b/include/photos.php index 49aab6865..c0917ce28 100644 --- a/include/photos.php +++ b/include/photos.php @@ -281,7 +281,7 @@ function photo_upload($channel, $observer, $args) { } } else { - $title = ''; + $title = $args['filename'] ? $args['filename'] : ''; $mid = item_message_id(); $arr = array(); diff --git a/include/text.php b/include/text.php index 205736502..0354402af 100644 --- a/include/text.php +++ b/include/text.php @@ -1216,36 +1216,13 @@ function theme_attachments(&$item) { if(is_array($arr) && count($arr)) { $attaches = array(); foreach($arr as $r) { - $icon = ''; - $icontype = substr($r['type'],0,strpos($r['type'],'/')); - /** - * @FIXME This should probably be a giant "if" statement in the - * template so that we don't have icon names embedded in php code. - */ + $icon = getIconFromType($r['type']); - switch($icontype) { - case 'video': - $icon = 'icon-facetime-video'; - break; - case 'audio': - $icon = 'icon-volume-up'; - break; - case 'image': - $icon = 'icon-picture'; - break; - case 'text': - $icon = 'icon-align-justify'; - break; - default: - $icon = 'icon-question'; - break; - } - - $title = htmlspecialchars($r['title'], ENT_COMPAT,'UTF-8'); + $label = urldecode(htmlspecialchars($r['title'], ENT_COMPAT, 'UTF-8')); if(! $title) $title = t('unknown.???'); - $title .= ' ' . (($r['length']) ? $r['length'] . ' ' . t('bytes') : ''); + $title = t('Attachment') . (($r['length']) ? ' ' . userReadableSize($r['length']) : ''); require_once('include/identity.php'); if(is_foreigner($item['author_xchan'])) @@ -1253,14 +1230,14 @@ function theme_attachments(&$item) { else $url = z_root() . '/magic?f=&hash=' . $item['author_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision']; - $s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>'; - $attaches[] = array('title' => $title, 'url' => $url, 'icon' => $icon ); + //$s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>'; + $attaches[] = array('label' => $label, 'url' => $url, 'icon' => $icon, 'title' => $title); } - } - $s = replace_macros(get_markup_template('item_attach.tpl'), array( - '$attaches' => $attaches - )); + $s = replace_macros(get_markup_template('item_attach.tpl'), array( + '$attaches' => $attaches + )); + } return $s; } @@ -1279,11 +1256,12 @@ function format_categories(&$item,$writeable) { $removelink = (($writeable) ? z_root() . '/filerm/' . $item['id'] . '?f=&cat=' . urlencode($t['term']) : ''); $categories[] = array('term' => $term, 'writeable' => $writeable, 'removelink' => $removelink, 'url' => zid($t['url'])); } + + $s = replace_macros(get_markup_template('item_categories.tpl'),array( + '$remove' => t('remove category'), + '$categories' => $categories + )); } - $s = replace_macros(get_markup_template('item_categories.tpl'),array( - '$remove' => t('remove category'), - '$categories' => $categories - )); return $s; } @@ -1294,6 +1272,7 @@ function format_categories(&$item,$writeable) { * @param[in] array &$item * @return string HTML link of hashtag */ + function format_hashtags(&$item) { $s = ''; @@ -1354,11 +1333,12 @@ function format_filer(&$item) { $removelink = z_root() . '/filerm/' . $item['id'] . '?f=&term=' . urlencode($t['term']); $categories[] = array('term' => $term, 'removelink' => $removelink); } + + $s = replace_macros(get_markup_template('item_filer.tpl'),array( + '$remove' => t('remove from file'), + '$categories' => $categories + )); } - $s = replace_macros(get_markup_template('item_filer.tpl'),array( - '$remove' => t('remove from file'), - '$categories' => $categories - )); return $s; } @@ -1411,19 +1391,19 @@ function prepare_body(&$item,$attach = false) { } } - $s .= theme_attachments($item); + $attachments = theme_attachments($item); $writeable = ((get_observer_hash() == $item['owner_xchan']) ? true : false); - $s .= format_hashtags($item); + $tags = format_hashtags($item); if($item['resource_type']) - $s .= format_mentions($item); + $mentions = format_mentions($item); - $s .= format_categories($item,$writeable); + $categories = format_categories($item,$writeable); if(local_channel() == $item['uid']) - $s .= format_filer($item); + $filer = format_filer($item); $s = sslify($s); @@ -1456,9 +1436,19 @@ function prepare_body(&$item,$attach = false) { $s = substr($s, 0, $pos).$authorreplace.substr($s, $pos+strlen($authorsearch)); } - $prep_arr = array('item' => $item, 'html' => $s); + $prep_arr = array( + 'item' => $item, + 'html' => $s, + 'categories' => $categories, + 'folders' => $filer, + 'tags' => $tags, + 'mentions' => $mentions, + 'attachments' => $attachments + ); + call_hooks('prepare_body_final', $prep_arr); - return $prep_arr['html']; + + return $prep_arr; } /** @@ -2490,6 +2480,7 @@ function linkify_tags($a, &$body, $uid, $diaspora = false) { * * @param string $type mime type * @return string + * @todo rename to get_icon_from_type() */ function getIconFromType($type) { $iconMap = array( @@ -2542,6 +2533,7 @@ function getIconFromType($type) { * * @param int $size filesize in bytes * @return string human readable formatted filesize + * @todo rename to user_readable_size() */ function userReadableSize($size) { $ret = ''; @@ -2607,4 +2599,4 @@ function item_url_replace($channel,&$item,$old,$new) { $item['item_verified'] = 1; } -}
\ No newline at end of file +} |