From 2d3a0a65258be35f4c046b6b3e416bf93baa4940 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 12 Jun 2013 21:12:27 -0700 Subject: feeds are bit more standards compliant and a bit less broken now --- include/items.php | 79 +++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 40 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 7fc132fe2..2b38adb1a 100755 --- a/include/items.php +++ b/include/items.php @@ -204,9 +204,7 @@ function get_public_feed($channel,$params) { } - echo get_feed_for($channel,get_observer_hash(),$params); - killme(); - + return get_feed_for($channel,get_observer_hash(),$params); } function get_feed_for($channel, $observer_hash, $params) { @@ -232,22 +230,19 @@ function get_feed_for($channel, $observer_hash, $params) { $atom = ''; - $hubxml = feed_hublinks(); - - $salmon = feed_salmonlinks($owner_nick); - $atom .= replace_macros($feed_template, array( '$version' => xmlify(RED_VERSION), + '$red' => xmlify(RED_PLATFORM), '$feed_id' => xmlify($channel['channel_url']), '$feed_title' => xmlify($channel['channel_name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now' , ATOM_TIME)) , - '$hub' => feed_hublinks(), - '$salmon' => feed_salmonlinks($channel['channel_address']), + '$hub' => '', // feed_hublinks(), + '$salmon' => '', // feed_salmonlinks($channel['channel_address']), '$name' => xmlify($channel['channel_name']), '$profile_page' => xmlify($channel['channel_url']), - '$mimephoto' => xmlify($channel['channel_photo_mimetype']), - '$photo' => xmlify($channel['channel_photo_l']), - '$thumb' => xmlify($channel['channel_photo_m']), + '$mimephoto' => xmlify($channel['xchan_photo_mimetype']), + '$photo' => xmlify($channel['xchan_photo_l']), + '$thumb' => xmlify($channel['xchan_photo_m']), '$picdate' => '', '$uridate' => '', '$namdate' => '', @@ -285,8 +280,7 @@ function construct_activity_object($item) { if($item['object']) { $o = '' . "\r\n"; - $r = parse_xml_string($item['object'],false); - + $r = json_decode($item['object'],false); if(! $r) return ''; @@ -296,7 +290,8 @@ function construct_activity_object($item) { $o .= '' . xmlify($r->id) . '' . "\r\n"; if($r->title) $o .= '' . xmlify($r->title) . '' . "\r\n"; - if($r->link) { + if($r->links) { + // FIXME!! if(substr($r->link,0,1) === '<') { $r->link = preg_replace('/\/','',$r->link); $o .= $r->link; @@ -317,7 +312,7 @@ function construct_activity_target($item) { if($item['target']) { $o = '' . "\r\n"; - $r = parse_xml_string($item['target'],false); + $r = json_decode($item['target'],false); if(! $r) return ''; if($r->type) @@ -326,7 +321,8 @@ function construct_activity_target($item) { $o .= '' . xmlify($r->id) . '' . "\r\n"; if($r->title) $o .= '' . xmlify($r->title) . '' . "\r\n"; - if($r->link) { + if($r->links) { + // FIXME !!! if(substr($r->link,0,1) === '<') { if(strstr($r->link,'&') && (! strstr($r->link,'&'))) $r->link = str_replace('&','&', $r->link); @@ -3957,7 +3953,7 @@ function lose_sharer($importer,$contact,$datarray,$item) { } -function atom_author($tag,$name,$uri,$h,$w,$photo) { +function atom_author($tag,$name,$uri,$h,$w,$type,$photo) { $o = ''; if(! $tag) return $o; @@ -3971,8 +3967,8 @@ function atom_author($tag,$name,$uri,$h,$w,$photo) { $o .= "<$tag>\r\n"; $o .= "$name\r\n"; $o .= "$uri\r\n"; - $o .= '' . "\r\n"; - $o .= '' . "\r\n"; + $o .= '' . "\r\n"; + $o .= '' . "\r\n"; call_hooks('atom_author', $o); @@ -4000,35 +3996,36 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $o = "\r\n\r\n\r\n"; if(is_array($author)) - $o .= atom_author('author',$author['name'],$author['url'],80,80,$author['thumb']); + $o .= atom_author('author',$author['xchan_name'],$author['xchan_url'],80,80,$author['xchan_photo_mimetype'],$author['xchan_photo_m']); else - $o .= atom_author('author',(($item['author-name']) ? $item['author-name'] : $item['name']),(($item['author-link']) ? $item['author-link'] : $item['url']),80,80,(($item['author-avatar']) ? $item['author-avatar'] : $item['thumb'])); - if(strlen($item['owner-name'])) - $o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']); + $o .= atom_author('author',$item['author']['xchan_name'],$item['author']['xchan_url'],80,80,$item['author']['xchan_photo_mimetype'], $item['author']['xchan_photo_m']); + + $o .= atom_author('zot:owner',$item['owner']['xchan_name'],$item['owner']['xchan_url'],80,80,$item['owner']['xchan_photo_mimetype'],$item['owner']['xchan_photo_m']); if(($item['parent'] != $item['id']) || ($item['parent_mid'] !== $item['mid']) || (($item['thr_parent'] !== '') && ($item['thr_parent'] !== $item['mid']))) { $parent_item = (($item['thr_parent']) ? $item['thr_parent'] : $item['parent_mid']); - $o .= '' . "\r\n"; + $o .= '' . "\r\n"; } $o .= '' . xmlify($item['mid']) . '' . "\r\n"; $o .= '' . xmlify($item['title']) . '' . "\r\n"; $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; - $o .= '' . base64url_encode($body, true) . '' . "\r\n"; + $o .= '' . base64url_encode($body, true) . '' . "\r\n"; + // FIXME for other content types $o .= '' . xmlify((($type === 'html') ? bbcode($body) : $body)) . '' . "\r\n"; - $o .= '' . "\r\n"; + $o .= '' . "\r\n"; if($item['location']) { - $o .= '' . xmlify($item['location']) . '' . "\r\n"; + $o .= '' . xmlify($item['location']) . '' . "\r\n"; $o .= '' . xmlify($item['location']) . '' . "\r\n"; } if($item['coord']) $o .= '' . xmlify($item['coord']) . '' . "\r\n"; - if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) - $o .= '' . (($item['private']) ? $item['private'] : 1) . '' . "\r\n"; + if(($item['item_private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) + $o .= '' . (($item['item_private']) ? $item['item_private'] : 1) . '' . "\r\n"; if($item['app']) @@ -4044,18 +4041,20 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { if(strlen($actarg)) $o .= $actarg; - $tags = item_getfeedtags($item); - if(count($tags)) { - foreach($tags as $t) { - $o .= '' . "\r\n"; - } - } + // FIXME +// $tags = item_getfeedtags($item); +// if(count($tags)) { +// foreach($tags as $t) { +// $o .= '' . "\r\n"; +// } +// } - $o .= item_getfeedattach($item); +// FIXME +// $o .= item_getfeedattach($item); - $mentioned = get_mentions($item,$tags); - if($mentioned) - $o .= $mentioned; +// $mentioned = get_mentions($item,$tags); +// if($mentioned) +// $o .= $mentioned; call_hooks('atom_entry', $o); -- cgit v1.2.3