本文整理匯總了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;
}