+ public function asActivityObject()
+ {
+ $object = new ActivityObject();
+
+ if (Event::handle('StartActivityObjectFromProfile', array($this, &$object))) {
+ $object->type = $this->getObjectType();
+ $object->id = $this->getUri();
+ $object->title = $this->getBestName();
+ $object->link = $this->getUrl();
+ $object->summary = $this->getDescription();
+
+ try {
+ $avatar = Avatar::getUploaded($this);
+ $object->avatarLinks[] = AvatarLink::fromAvatar($avatar);
+ } catch (NoAvatarException $e) {
+ // Could not find an original avatar to link
+ }
+
+ $sizes = array(
+ AVATAR_PROFILE_SIZE,
+ AVATAR_STREAM_SIZE,
+ AVATAR_MINI_SIZE
+ );
+
+ foreach ($sizes as $size) {
+ $alink = null;
+ try {
+ $avatar = Avatar::byProfile($this, $size);
+ $alink = AvatarLink::fromAvatar($avatar);
+ } catch (NoAvatarException $e) {
+ $alink = new AvatarLink();
+ $alink->type = 'image/png';
+ $alink->height = $size;
+ $alink->width = $size;
+ $alink->url = Avatar::defaultImage($size);
+ }
+
+ $object->avatarLinks[] = $alink;
+ }
+
+ if (isset($this->lat) && isset($this->lon)) {
+ $object->geopoint = (float)$this->lat
+ . ' ' . (float)$this->lon;
+ }
+
+ $object->poco = PoCo::fromProfile($this);
+
+ if ($this->isLocal()) {
+ $object->extra[] = array('followers', array('url' => common_local_url('subscribers', array('nickname' => $this->getNickname()))));
+ }
+
+ Event::handle('EndActivityObjectFromProfile', array($this, &$object));
+ }
+
+ return $object;
+ }
+