本文整理汇总了PHP中Avatar::byProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP Avatar::byProfile方法的具体用法?PHP Avatar::byProfile怎么用?PHP Avatar::byProfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Avatar
的用法示例。
在下文中一共展示了Avatar::byProfile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
protected function prepare(array $args = array())
{
parent::prepare($args);
$this->count = 5000;
// max 5000, completely arbitrary...
$this->target = $this->getTargetProfile($this->arg('id'));
if (!$this->target instanceof Profile) {
// TRANS: Client error displayed when requesting a list of followers for a non-existing user.
$this->clientError(_('No such user.'), 404);
}
$this->profiles = $this->getProfiles();
// only keep id, name, nickname and avatar URL
foreach ($this->profiles as $p) {
try {
$avatar = Avatar::byProfile($p, AVATAR_STREAM_SIZE);
$avatar = $avatar->url;
} catch (Exception $e) {
$avatar = false;
}
$this_user = array($p->fullname, $p->nickname, $avatar);
if (!$p->isLocal()) {
$this_user[3] = $p->getUrl();
} else {
$this_user[3] = false;
}
$this->users_stripped[$p->id] = $this_user;
}
return true;
}
示例2: asActivityObject
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;
}