const BOOKMARK = 'http://activitystrea.ms/schema/1.0/bookmark';
const PERSON = 'http://activitystrea.ms/schema/1.0/person';
const GROUP = 'http://activitystrea.ms/schema/1.0/group';
+ const _LIST = 'http://activitystrea.ms/schema/1.0/list'; // LIST is reserved
const PLACE = 'http://activitystrea.ms/schema/1.0/place';
const COMMENT = 'http://activitystrea.ms/schema/1.0/comment';
// ^^^^^^^^^^ tea!
public $title;
public $summary;
public $content;
+ public $owner;
public $link;
public $source;
public $avatarLinks = array();
Activity::MEDIA
);
}
+ if ($this->type == self::_LIST) {
+ $owner = ActivityUtils::child($this->element, Activity::AUTHOR, Activity::SPEC);
+ $this->owner = new ActivityObject($owner);
+ }
}
private function _fromAuthor($element)
AVATAR_MINI_SIZE);
$object->poco = PoCo::fromGroup($group);
-
- Event::handle('EndActivityObjectFromGroup', array($group, &$object));
+ Event::handle('EndActivityObjectFromGroup', array($group, &$object));
}
return $object;
}
+ static function fromPeopletag($ptag)
+ {
+ $object = new ActivityObject();
+ if (Event::handle('StartActivityObjectFromPeopletag', array($ptag, &$object))) {
+ $object->type = ActivityObject::_LIST;
+
+ $object->id = $ptag->getUri();
+ $object->title = $ptag->tag;
+ $object->summary = $ptag->description;
+ $object->link = $ptag->homeUrl();
+ $object->owner = Profile::staticGet('id', $ptag->tagger);
+ $object->poco = PoCo::fromProfile($object->owner);
+ Event::handle('EndActivityObjectFromPeopletag', array($ptag, &$object));
+ }
+ return $object;
+ }
+
function outputTo($xo, $tag='activity:object')
{
if (!empty($tag)) {
}
}
+ if(!empty($this->owner)) {
+ $owner = $this->owner->asActivityNoun(self::AUTHOR);
+ $xo->raw($owner);
+ }
+
if (!empty($this->geopoint)) {
$xo->element(
'georss:point',
{
$object = array();
- // TODO: attachedObjects
+ // XXX: attachedObjects are added by Activity
// displayName
$object['displayName'] = $this->title;
-
// TODO: downstreamDuplicates
- // TODO: embedCode (video)
+
+ // embedCode (used for video)
// id
+ //
+ // XXX: Should we use URL here? or a crazy tag URI?
$object['id'] = $this->id;
if ($this->type == ActivityObject::PERSON
|| $this->type == ActivityObject::GROUP) {
// XXX: Not sure what the best avatar is to use for the
- // author's "image". For now, I'm using the stream size
- // one, but possibly it should be large
- $avatarLink = null;
+ // author's "image". For now, I'm using the large size.
+
+ $avatarLarge = null;
+ $avatarMediaLinks = array();
foreach ($this->avatarLinks as $a) {
- if ($a->height == AVATAR_STREAM_SIZE) {
- $avatarLink = $a;
- break;
+
+ // Make a MediaLink for every other Avatar
+ $avatar = new ActivityStreamsMediaLink(
+ $a->url,
+ $a->width,
+ $a->height,
+ $a->type,
+ 'avatar'
+ );
+
+ // Find the big avatar to use as the "image"
+ if ($a->height == AVATAR_PROFILE_SIZE) {
+ $imgLink = $avatar;
}
+
+ $avatarMediaLinks[] = $avatar->asArray();
}
- $imgLink = new ActivityStreamsMediaLink(
- $avatarLink->url,
- $avatarLink->width,
- $avatarLink->height,
- $avatarLink->type
- );
+ $object['avatarLinks'] = $avatarMediaLinks; // extension
+ // image
$object['image'] = $imgLink->asArray();
}
// url (XXX: need to put the right thing here...)
$object['url'] = $this->id;
- // TODO: extensions (OStatus stuff, etc.)
+ /* Extensions */
+
+ foreach ($this->extra as $e) {
+ list($objectName, $props, $txt) = $e;
+ $object[$objectName] = $props;
+ }
+
+ // GeoJSON
+
+ if (!empty($this->geopoint)) {
+
+ list($lat, $long) = explode(' ', $this->geopoint);
+
+ $object['geopoint'] = array(
+ 'type' => 'Point',
+ 'coordinates' => array($lat, $long)
+ );
+ }
+
+ if (!empty($this->poco)) {
+ $object['contact'] = $this->poco->asArray();
+ }
return array_filter($object);
}