diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-06-02 17:47:47 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-06-02 17:47:47 -0700 |
commit | 7cbc5048743bc5976e48cd3f81801550c0b7f52f (patch) | |
tree | f9effa684ef44298d1922bd715d7b1ca9823374d /include | |
parent | f3b95f591a7ec49b6fc148913861bae2bb6aa6c7 (diff) | |
parent | 86ff31f5003312a6c1bcb65c7aa25ad001f542d4 (diff) | |
download | volse-hubzilla-7cbc5048743bc5976e48cd3f81801550c0b7f52f.tar.gz volse-hubzilla-7cbc5048743bc5976e48cd3f81801550c0b7f52f.tar.bz2 volse-hubzilla-7cbc5048743bc5976e48cd3f81801550c0b7f52f.zip |
Merge branch 'master' of https://github.com/redmatrix/redmatrix
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 2 | ||||
-rwxr-xr-x | include/items.php | 62 |
2 files changed, 57 insertions, 7 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 0415d8a73..b8a62a2f2 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1008,5 +1008,5 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) function strip_bbimage($s) { - $Text = preg_replace("/\[[zi]mg(.*?)\](.*?)\[\/[zi]mg\]/ism", '', $Text); + return preg_replace("/\[[zi]mg(.*?)\](.*?)\[\/[zi]mg\]/ism", '', $s); } diff --git a/include/items.php b/include/items.php index 818e7f526..2b00b52f8 100755 --- a/include/items.php +++ b/include/items.php @@ -4842,6 +4842,17 @@ function comment_local_origin($item) { } +function gen_asld($items) { + $ret = array(); + if(! $items) + return $ret; + foreach($items as $item) { + $ret[] = i2asld($item); + } + return $ret; +} + + function i2asld($i) { if(! $i) @@ -4849,30 +4860,69 @@ function i2asld($i) { $ret = array(); + $ret['@context'] = array( 'http://www.w3.org/ns/activitystreams', 'zot' => 'http://purl.org/zot/protocol'); + if($i['verb']) { - $ret['@context'] = dirname($i['verb']); - $ret['@type'] = ucfirst(basename($i['verb'])); + if(strpos(dirname($i['verb'],'activitystrea.ms/schema/1.0'))) { + $ret['@type'] = ucfirst(basename($i['verb'])); + } + elseif(strpos(dirname($i['verb'],'purl.org/zot'))) { + $ret['@type'] = 'zot:' . ucfirst(basename($i['verb'])); + } } $ret['@id'] = $i['plink']; + $ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME); - if($i['title']) - $ret['title'] = $i['title']; - $ret['content'] = bbcode($i['body']); + + // we need to pass the parent into this +// if($i['id'] != $i['parent'] && $i['obj_type'] === ACTIVITY_OBJ_NOTE) { +// $ret['inReplyTo'] = asencode_note +// } + + if($i['obj_type'] === ACTIVITY_OBJ_NOTE) + $ret['object'] = asencode_note($i); + $ret['actor'] = asencode_person($i['author']); - $ret['owner'] = asencode_person($i['owner']); return $ret; } +function asencode_note($i) { + + $ret = array(); + + $ret['@type'] = 'Note'; + $ret['@id'] = $i['plink']; + if($i['title']) + $ret['title'] = bbcode($i['title']); + $ret['content'] = bbcode($i['body']); + $ret['zot:owner'] = asencode_person($i['owner']); + $ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME); + if($i['created'] !== $i['edited']) + $ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME); + + return $ret; +} + function asencode_person($p) { $ret = array(); $ret['@type'] = 'Person'; $ret['@id'] = 'acct:' . $p['xchan_addr']; $ret['displayName'] = $p['xchan_name']; + $ret['icon'] = array( + '@type' => 'Link', + 'mediaType' => $p['xchan_photo_mimetype'], + 'href' => $p['xchan_photo_m'] + ); + $ret['url'] = array( + '@type' => 'Link', + 'mediaType' => 'text/html', + 'href' => $p['xchan_url'] + ); return $ret; } |