From 96e668a5b940362c0f2db15fc7519d9baad88f3d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 7 Jan 2017 13:29:32 -0800 Subject: add enclosures and categories to atom feed --- include/feedutils.php | 69 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index df56e3673..68ac20782 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -304,7 +304,7 @@ function get_atom_elements($feed, $item, &$author) { foreach($base as $link) { if($link['attribs']['']['rel'] === 'alternate' && (! $author['author_link'])) { $author['author_link'] = unxmlify($link['attribs']['']['href']); -0 $author['author_is_feed'] = true; + $author['author_is_feed'] = true; } if(! $author['author_photo']) { if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') @@ -1229,31 +1229,62 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { if(strlen($actarg)) $o .= $actarg; - // FIXME -// $tags = item_getfeedtags($item); -// if(count($tags)) { -// foreach($tags as $t) { -// $o .= '' . "\r\n"; -// } -// } -// FIXME -// $o .= item_getfeedattach($item); + if($item['attach']) { + $enclosures = json_decode($item['attach'],true); + if($enclosures) { + foreach($enclosures as $enc) { + $o .= ''; + } + } + } -// $mentioned = get_mentions($item,$tags); -// if($mentioned) -// $o .= $mentioned; + if($item['term']) { + foreach($item['term'] as $term) { + $scheme = ''; + $label = ''; + switch($term['ttype']) { + case TERM_UNKNOWN: + $scheme = NAMESPACE_ZOT . '/term/unknown'; + $label = $term['term']; + break; + case TERM_HASHTAG: + case TERM_COMMUNITYTAG: + $scheme = NAMESPACE_ZOT . '/term/hashtag'; + $label = '#' . $term['term']; + break; + case TERM_MENTION: + $scheme = NAMESPACE_ZOT . '/term/mention'; + $label = '@' . $term['term']; + break; + case TERM_CATEGORY: + $scheme = NAMESPACE_ZOT . '/term/category'; + $label = $term['term']; + break; + default: + break; + } + if(! $scheme) + continue; + + $o .= '' . "\r\n"; + } + } $o .= '' . "\r\n"; $x = [ - 'item' => $item, - 'type' => $type, - 'author' => $author, - 'owner' => $owner, - 'comment' => $comment, + 'item' => $item, + 'type' => $type, + 'author' => $author, + 'owner' => $owner, + 'comment' => $comment, 'abook_id' => $cid, - 'entry' => $o + 'entry' => $o ]; call_hooks('atom_entry', $x); -- cgit v1.2.3