showAvatar functions deduplicated into Widget class
This commit is contained in:
parent
10105a9965
commit
e4f1c77d6b
|
@ -359,6 +359,8 @@ class ShowprofiletagAction extends Action
|
||||||
|
|
||||||
class Peopletag extends PeopletagListItem
|
class Peopletag extends PeopletagListItem
|
||||||
{
|
{
|
||||||
|
protected $avatarSize = AVATAR_PROFILE_SIZE;
|
||||||
|
|
||||||
function showStart()
|
function showStart()
|
||||||
{
|
{
|
||||||
$mode = $this->peopletag->private ? 'private' : 'public';
|
$mode = $this->peopletag->private ? 'private' : 'public';
|
||||||
|
@ -370,9 +372,4 @@ class Peopletag extends PeopletagListItem
|
||||||
{
|
{
|
||||||
$this->out->elementEnd('div');
|
$this->out->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAvatar()
|
|
||||||
{
|
|
||||||
parent::showAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ class SubscriptionsListItem extends SubscriptionListItem
|
||||||
function showProfile()
|
function showProfile()
|
||||||
{
|
{
|
||||||
$this->startProfile();
|
$this->startProfile();
|
||||||
$this->showAvatar();
|
$this->showAvatar($this->profile);
|
||||||
$this->showFullName();
|
$this->showFullName();
|
||||||
$this->showLocation();
|
$this->showLocation();
|
||||||
$this->showHomepage();
|
$this->showHomepage();
|
||||||
|
|
|
@ -63,11 +63,6 @@ class AccountProfileBlock extends ProfileBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function avatar()
|
|
||||||
{
|
|
||||||
return $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
function name()
|
function name()
|
||||||
{
|
{
|
||||||
return $this->profile->getBestName();
|
return $this->profile->getBestName();
|
||||||
|
|
|
@ -52,12 +52,17 @@ class GroupProfileBlock extends ProfileBlock
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->group = $group;
|
$this->group = $group;
|
||||||
|
$this->profile = $this->group->getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
function avatar()
|
protected function showAvatar(Profile $profile, $size=null)
|
||||||
{
|
{
|
||||||
return ($this->group->homepage_logo) ?
|
$avatar_url = $profile->getGroup()->homepage_logo ?: User_group::defaultLogo($size ?: $this->avatarSize());
|
||||||
$this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
|
$this->out->element('img', array('src' => $avatar_url,
|
||||||
|
'class' => 'avatar u-photo',
|
||||||
|
'width' => $this->avatarSize(),
|
||||||
|
'height' => $this->avatarSize(),
|
||||||
|
'alt' => $profile->getBestName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
function name()
|
function name()
|
||||||
|
|
|
@ -218,9 +218,8 @@ class NoticeListItem extends Widget
|
||||||
'title' => $this->profile->nickname);
|
'title' => $this->profile->nickname);
|
||||||
|
|
||||||
$this->out->elementStart('a', $attrs);
|
$this->out->elementStart('a', $attrs);
|
||||||
$this->showAvatar();
|
$this->showAvatar($this->profile);
|
||||||
$this->out->text(' ');
|
$this->out->text($this->profile->getStreamName());
|
||||||
$this->out->element('span',array('class' => 'fn'), $this->profile->getStreamName());
|
|
||||||
$this->out->elementEnd('a');
|
$this->out->elementEnd('a');
|
||||||
|
|
||||||
$this->out->elementEnd('span');
|
$this->out->elementEnd('span');
|
||||||
|
@ -275,35 +274,6 @@ class NoticeListItem extends Widget
|
||||||
return $this->notice->getReplyProfiles();
|
return $this->notice->getReplyProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* show the avatar of the notice's author
|
|
||||||
*
|
|
||||||
* This will use the default avatar if no avatar is assigned for the author.
|
|
||||||
* It makes a link to the author's profile.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function showAvatar()
|
|
||||||
{
|
|
||||||
$avatar_size = $this->avatarSize();
|
|
||||||
|
|
||||||
$avatarUrl = $this->profile->avatarUrl($avatar_size);
|
|
||||||
|
|
||||||
$this->out->element('img', array('src' => $avatarUrl,
|
|
||||||
'class' => 'avatar photo',
|
|
||||||
'width' => $avatar_size,
|
|
||||||
'height' => $avatar_size,
|
|
||||||
'alt' =>
|
|
||||||
($this->profile->fullname) ?
|
|
||||||
$this->profile->fullname :
|
|
||||||
$this->profile->nickname));
|
|
||||||
}
|
|
||||||
|
|
||||||
function avatarSize()
|
|
||||||
{
|
|
||||||
return AVATAR_STREAM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show the nickname of the author
|
* show the nickname of the author
|
||||||
*
|
*
|
||||||
|
|
|
@ -231,11 +231,8 @@ class PeopletagListItem extends Widget
|
||||||
$attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
|
$attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
|
||||||
}
|
}
|
||||||
$this->out->elementStart('a', $attrs);
|
$this->out->elementStart('a', $attrs);
|
||||||
$this->showAvatar();
|
$this->showAvatar($this->profile);
|
||||||
$this->out->text(' ');
|
$this->out->text($this->profile->getNickname());
|
||||||
$this->out->element('span', 'nickname fn',
|
|
||||||
htmlspecialchars($this->profile->nickname));
|
|
||||||
|
|
||||||
$this->out->elementEnd('a');
|
$this->out->elementEnd('a');
|
||||||
$this->out->elementEnd('span');
|
$this->out->elementEnd('span');
|
||||||
}
|
}
|
||||||
|
@ -272,29 +269,6 @@ class PeopletagListItem extends Widget
|
||||||
$this->out->elementEnd('span');
|
$this->out->elementEnd('span');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* show the avatar of the peopletag's creator
|
|
||||||
*
|
|
||||||
* This will use the default avatar if no avatar is assigned for the author.
|
|
||||||
* It makes a link to the author's profile.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
function showAvatar($size=AVATAR_STREAM_SIZE)
|
|
||||||
{
|
|
||||||
$avatarUrl = $this->profile->avatarUrl($size);
|
|
||||||
|
|
||||||
$this->out->element('img', array('src' => $avatarUrl,
|
|
||||||
'class' => 'avatar photo',
|
|
||||||
'width' => $size,
|
|
||||||
'height' => $size,
|
|
||||||
'alt' =>
|
|
||||||
($this->profile->fullname) ?
|
|
||||||
$this->profile->fullname :
|
|
||||||
$this->profile->nickname));
|
|
||||||
}
|
|
||||||
|
|
||||||
function showActions()
|
function showActions()
|
||||||
{
|
{
|
||||||
$this->out->elementStart('div', 'entity_actions');
|
$this->out->elementStart('div', 'entity_actions');
|
||||||
|
|
|
@ -48,6 +48,8 @@ define('PEOPLETAGS_PER_SECTION', 6);
|
||||||
*/
|
*/
|
||||||
class PeopletagSection extends Section
|
class PeopletagSection extends Section
|
||||||
{
|
{
|
||||||
|
protected $avatarSize = AVATAR_MINI_SIZE;
|
||||||
|
|
||||||
function showContent()
|
function showContent()
|
||||||
{
|
{
|
||||||
$tags = $this->getPeopletags();
|
$tags = $this->getPeopletags();
|
||||||
|
@ -135,9 +137,4 @@ class PeopletagSectionItem extends PeopletagListItem
|
||||||
htmlspecialchars($this->peopletag->tag));
|
htmlspecialchars($this->peopletag->tag));
|
||||||
$this->out->elementEnd('span');
|
$this->out->elementEnd('span');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAvatar()
|
|
||||||
{
|
|
||||||
parent::showAvatar(AVATAR_MINI_SIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ if (!defined('STATUSNET')) {
|
||||||
|
|
||||||
abstract class ProfileBlock extends Widget
|
abstract class ProfileBlock extends Widget
|
||||||
{
|
{
|
||||||
abstract function avatar();
|
protected $avatarSize = AVATAR_PROFILE_SIZE;
|
||||||
|
|
||||||
abstract function name();
|
abstract function name();
|
||||||
abstract function url();
|
abstract function url();
|
||||||
abstract function location();
|
abstract function location();
|
||||||
|
@ -57,7 +58,7 @@ abstract class ProfileBlock extends Widget
|
||||||
function show()
|
function show()
|
||||||
{
|
{
|
||||||
$this->showActions();
|
$this->showActions();
|
||||||
$this->showAvatar();
|
$this->showAvatar($this->profile);
|
||||||
$this->showName();
|
$this->showName();
|
||||||
$this->showLocation();
|
$this->showLocation();
|
||||||
$this->showHomepage();
|
$this->showHomepage();
|
||||||
|
@ -66,22 +67,6 @@ abstract class ProfileBlock extends Widget
|
||||||
$this->showTags();
|
$this->showTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAvatar()
|
|
||||||
{
|
|
||||||
$size = $this->avatarSize();
|
|
||||||
|
|
||||||
$this->out->element(
|
|
||||||
'img',
|
|
||||||
array(
|
|
||||||
'src' => $this->avatar(),
|
|
||||||
'class' => 'ur_face',
|
|
||||||
'alt' => $this->name(),
|
|
||||||
'width' => $size,
|
|
||||||
'height' => $size
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showName()
|
function showName()
|
||||||
{
|
{
|
||||||
$name = $this->name();
|
$name = $this->name();
|
||||||
|
@ -161,11 +146,6 @@ abstract class ProfileBlock extends Widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function avatarSize()
|
|
||||||
{
|
|
||||||
return AVATAR_PROFILE_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showTags()
|
function showTags()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/widget.php';
|
|
||||||
require_once INSTALLDIR.'/lib/peopletags.php';
|
require_once INSTALLDIR.'/lib/peopletags.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,11 +106,6 @@ class ProfileList extends Widget
|
||||||
{
|
{
|
||||||
return PROFILES_PER_PAGE;
|
return PROFILES_PER_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function avatarSize()
|
|
||||||
{
|
|
||||||
return AVATAR_STREAM_SIZE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProfileListItem extends Widget
|
class ProfileListItem extends Widget
|
||||||
|
@ -157,7 +151,10 @@ class ProfileListItem extends Widget
|
||||||
$this->startProfile();
|
$this->startProfile();
|
||||||
if (Event::handle('StartProfileListItemProfileElements', array($this))) {
|
if (Event::handle('StartProfileListItemProfileElements', array($this))) {
|
||||||
if (Event::handle('StartProfileListItemAvatar', array($this))) {
|
if (Event::handle('StartProfileListItemAvatar', array($this))) {
|
||||||
|
$aAttrs = $this->linkAttributes();
|
||||||
|
$this->out->elementStart('a', $aAttrs);
|
||||||
$this->showAvatar();
|
$this->showAvatar();
|
||||||
|
$this->out->elementEnd('a');
|
||||||
Event::handle('EndProfileListItemAvatar', array($this));
|
Event::handle('EndProfileListItemAvatar', array($this));
|
||||||
}
|
}
|
||||||
if (Event::handle('StartProfileListItemFullName', array($this))) {
|
if (Event::handle('StartProfileListItemFullName', array($this))) {
|
||||||
|
@ -190,26 +187,6 @@ class ProfileListItem extends Widget
|
||||||
$this->out->elementStart('div', 'entity_profile vcard entry-content');
|
$this->out->elementStart('div', 'entity_profile vcard entry-content');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAvatar()
|
|
||||||
{
|
|
||||||
$avatarUrl = $this->profile->avatarUrl(AVATAR_STREAM_SIZE);
|
|
||||||
$aAttrs = $this->linkAttributes();
|
|
||||||
$this->out->elementStart('a', $aAttrs);
|
|
||||||
$this->out->element('img', array('src' => $avatarUrl,
|
|
||||||
'class' => 'photo avatar',
|
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
|
||||||
'alt' =>
|
|
||||||
($this->profile->fullname) ? $this->profile->fullname :
|
|
||||||
$this->profile->nickname));
|
|
||||||
$this->out->text(' ');
|
|
||||||
$hasFN = (!empty($this->profile->fullname)) ? 'nickname' : 'fn nickname';
|
|
||||||
$this->out->elementStart('span', $hasFN);
|
|
||||||
$this->out->raw($this->highlight($this->profile->nickname));
|
|
||||||
$this->out->elementEnd('span');
|
|
||||||
$this->out->elementEnd('a');
|
|
||||||
}
|
|
||||||
|
|
||||||
function showFullName()
|
function showFullName()
|
||||||
{
|
{
|
||||||
if (!empty($this->profile->fullname)) {
|
if (!empty($this->profile->fullname)) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ class SubscriptionListItem extends ProfileListItem
|
||||||
function showProfile()
|
function showProfile()
|
||||||
{
|
{
|
||||||
$this->startProfile();
|
$this->startProfile();
|
||||||
$this->showAvatar();
|
$this->showAvatar($this->profile);
|
||||||
$this->showFullName();
|
$this->showFullName();
|
||||||
$this->showLocation();
|
$this->showLocation();
|
||||||
$this->showHomepage();
|
$this->showHomepage();
|
||||||
|
|
|
@ -51,6 +51,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
|
||||||
class Widget
|
class Widget
|
||||||
{
|
{
|
||||||
|
protected $avatarSize = AVATAR_STREAM_SIZE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTMLOutputter to use for output
|
* HTMLOutputter to use for output
|
||||||
*/
|
*/
|
||||||
|
@ -105,4 +107,22 @@ class Widget
|
||||||
{
|
{
|
||||||
return call_user_func_array(array($this->out, $name), $arguments);
|
return call_user_func_array(array($this->out, $name), $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default avatar size for this widget.
|
||||||
|
*/
|
||||||
|
public function avatarSize()
|
||||||
|
{
|
||||||
|
return $this->avatarSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function showAvatar(Profile $profile, $size=null)
|
||||||
|
{
|
||||||
|
$avatar_url = $profile->avatarUrl($size ?: $this->avatarSize());
|
||||||
|
$this->out->element('img', array('src' => $avatar_url,
|
||||||
|
'class' => 'avatar u-photo',
|
||||||
|
'width' => $this->avatarSize(),
|
||||||
|
'height' => $this->avatarSize(),
|
||||||
|
'alt' => $profile->getBestName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,37 +167,15 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAvatar()
|
function showAvatar(Profile $profile, $size=null)
|
||||||
{
|
{
|
||||||
$logo = ($this->profile->stream_logo) ?
|
$logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize());
|
||||||
$this->profile->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE);
|
|
||||||
|
|
||||||
$this->out->elementStart(
|
$this->out->element('img', array('src' => $logo,
|
||||||
'a',
|
'class' => 'photo avatar',
|
||||||
array(
|
'width' => AVATAR_STREAM_SIZE,
|
||||||
'href' => $this->profile->homeUrl(),
|
'height' => AVATAR_STREAM_SIZE,
|
||||||
'class' => 'url entry-title',
|
'alt' => $profile->getBestName()));
|
||||||
'rel' => 'contact group'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->out->element(
|
|
||||||
'img',
|
|
||||||
array(
|
|
||||||
'src' => $logo,
|
|
||||||
'class' => 'photo avatar',
|
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
|
||||||
'alt' => ($this->profile->fullname)
|
|
||||||
? $this->profile->fullname : $this->profile->nickname
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->out->text(' ');
|
|
||||||
$hasFN = ($this->profile->fullname) ? 'nickname' : 'fn org nickname';
|
|
||||||
$this->out->elementStart('span', $hasFN);
|
|
||||||
$this->out->raw($this->highlight($this->profile->nickname));
|
|
||||||
$this->out->elementEnd('span');
|
|
||||||
$this->out->elementEnd('a');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show()
|
function show()
|
||||||
|
@ -226,7 +204,17 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||||
function showProfile()
|
function showProfile()
|
||||||
{
|
{
|
||||||
$this->startProfile();
|
$this->startProfile();
|
||||||
$this->showAvatar();
|
|
||||||
|
$hasFN = ($this->profile->fullname) ? 'nickname' : 'fn org nickname';
|
||||||
|
$this->out->elementStart('a', array('href' => $this->profile->homeUrl(),
|
||||||
|
'class' => 'h-card org nickname',
|
||||||
|
'rel' => 'contact group'));
|
||||||
|
// getProfile here is because $this->profile is a User_group, which it should stop
|
||||||
|
// being by making sure the group listing runs a ->getGroup when it's necessary.
|
||||||
|
$this->showAvatar($this->profile->getProfile());
|
||||||
|
$this->out->text($this->profile->getNickname());
|
||||||
|
$this->out->elementEnd('a');
|
||||||
|
|
||||||
$this->showFullName();
|
$this->showFullName();
|
||||||
$this->showLocation();
|
$this->showLocation();
|
||||||
$this->showHomepage();
|
$this->showHomepage();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user