static function fromProfile(Profile $profile)
 {
     $object = new ActivityObject();
     if (Event::handle('StartActivityObjectFromProfile', array($profile, &$object))) {
         $object->type = ActivityObject::PERSON;
         $object->id = $profile->getUri();
         $object->title = $profile->getBestName();
         $object->link = $profile->profileurl;
         $orig = $profile->getOriginalAvatar();
         if (!empty($orig)) {
             $object->avatarLinks[] = AvatarLink::fromAvatar($orig);
         }
         $sizes = array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE);
         foreach ($sizes as $size) {
             $alink = null;
             $avatar = $profile->getAvatar($size);
             if (!empty($avatar)) {
                 $alink = AvatarLink::fromAvatar($avatar);
             } else {
                 $alink = new AvatarLink();
                 $alink->type = 'image/png';
                 $alink->height = $size;
                 $alink->width = $size;
                 $alink->url = Avatar::defaultImage($size);
                 if ($size == AVATAR_PROFILE_SIZE) {
                     // Hack for Twitter import: we don't have a 96x96 image,
                     // but we do have a 73x73 image. For now, fake it with that.
                     $avatar = $profile->getAvatar(73);
                     if ($avatar) {
                         $alink = AvatarLink::fromAvatar($avatar);
                         $alink->height = $size;
                         $alink->width = $size;
                     }
                 }
             }
             $object->avatarLinks[] = $alink;
         }
         if (isset($profile->lat) && isset($profile->lon)) {
             $object->geopoint = (double) $profile->lat . ' ' . (double) $profile->lon;
         }
         $object->poco = PoCo::fromProfile($profile);
         Event::handle('EndActivityObjectFromProfile', array($profile, &$object));
     }
     return $object;
 }
Beispiel #2
0
 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 fromProfile(Profile $profile)
 {
     $object = new ActivityObject();
     $object->type = ActivityObject::PERSON;
     $object->id = $profile->getUri();
     $object->title = $profile->getBestName();
     $object->link = $profile->profileurl;
     $orig = $profile->getOriginalAvatar();
     if (!empty($orig)) {
         $object->avatarLinks[] = AvatarLink::fromAvatar($orig);
     }
     $sizes = array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE);
     foreach ($sizes as $size) {
         $alink = null;
         $avatar = $profile->getAvatar($size);
         if (!empty($avatar)) {
             $alink = AvatarLink::fromAvatar($avatar);
         } else {
             $alink = new AvatarLink();
             $alink->type = 'image/png';
             $alink->height = $size;
             $alink->width = $size;
             $alink->url = Avatar::defaultImage($size);
         }
         $object->avatarLinks[] = $alink;
     }
     if (isset($profile->lat) && isset($profile->lon)) {
         $object->geopoint = (double) $profile->lat . ' ' . (double) $profile->lon;
     }
     $object->poco = PoCo::fromProfile($profile);
     return $object;
 }