From a50947a4bc3f779df8fa4e6777bc025fcefc8d21 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Fri, 17 Sep 2010 03:10:19 -0700 Subject: like, dislike, activity streams, etc. --- include/items.php | 88 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 12 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index f85a0e64b..8ca0eeb16 100644 --- a/include/items.php +++ b/include/items.php @@ -1,9 +1,9 @@ '%s' OR `item`.`changed` > '%s' ) $sql_extra ORDER BY `parent` %s, `created` ASC LIMIT 0, 300", @@ -193,10 +211,23 @@ function construct_verb($item) { function construct_activity($item) { - if($item['type'] == 'activity') { - - + if($item['object']) { + $o = '' . "\r\n"; + $r = @simplexml_load_string($item['object']); + if($r->type) + $o .= '' . $r->type . '' . "\r\n"; + if($r->id) + $o .= '' . $r->id . '' . "\r\n"; + if($r->link) + $o .= '' . "\r\n"; + if($r->title) + $o .= '' . $r->title . '' . "\r\n"; + if($r->content) + $o .= '' . bbcode($r->content) . '' . "\r\n"; + $o .= '' . "\r\n"; + return $o; } + return ''; } @@ -300,9 +331,42 @@ function get_atom_elements($item) { $res['verb'] = unxmlify($rawverb[0]['data']); $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); + + if($rawobj) { - $res['object-type'] = $rawobj[0]['object-type'][0]['data']; - $res['object'] = $rawobj[0]; + $res['object'] = '' . "\n"; + if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) { + $res['object-type'] = $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']; + $res['object'] .= '' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '' . "\n"; + } + if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) + $res['object'] .= '' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '' . "\n"; + + if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['rel'] == 'alternate') + $res['object'] .= '' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['href'] . '' . "\n"; + if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) + $res['object'] .= '' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '' . "\n"; + if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { + $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; + if(! $body) + $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data']; + if(strpos($body,'<')) { + + $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', + '[youtube]$1[/youtube]', $body); + + $config = HTMLPurifier_Config::createDefault(); + $config->set('Core.DefinitionCache', null); + + $purifier = new HTMLPurifier($config); + $body = $purifier->purify($body); + } + + $body = html2bbcode($body); + $res['object'] .= '' . $body . '' . "\n"; + } + + $res['object'] .= '' . "\n"; } return $res; -- cgit v1.2.3