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 = (double) $this->lat . ' ' . (double) $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; }
static function fromGroup(User_group $group) { $object = new ActivityObject(); if (Event::handle('StartActivityObjectFromGroup', array($group, &$object))) { $object->type = ActivityObject::GROUP; $object->id = $group->getUri(); $object->title = $group->getBestName(); $object->link = $group->getUri(); $object->avatarLinks[] = AvatarLink::fromFilename($group->homepage_logo, AVATAR_PROFILE_SIZE); $object->avatarLinks[] = AvatarLink::fromFilename($group->stream_logo, AVATAR_STREAM_SIZE); $object->avatarLinks[] = AvatarLink::fromFilename($group->mini_logo, AVATAR_MINI_SIZE); $object->poco = PoCo::fromGroup($group); Event::handle('EndActivityObjectFromGroup', array($group, &$object)); } return $object; }
static function fromGroup($group) { $object = new ActivityObject(); $object->type = ActivityObject::GROUP; $object->id = $group->getUri(); $object->title = $group->getBestName(); $object->link = $group->getUri(); $object->avatarLinks[] = AvatarLink::fromFilename($group->homepage_logo, AVATAR_PROFILE_SIZE); $object->avatarLinks[] = AvatarLink::fromFilename($group->stream_logo, AVATAR_STREAM_SIZE); $object->avatarLinks[] = AvatarLink::fromFilename($group->mini_logo, AVATAR_MINI_SIZE); $object->poco = PoCo::fromGroup($group); return $object; }