diff --git a/actions/showprofiletag.php b/actions/showprofiletag.php index 4524e4aa8c..6b1bc5e5b5 100644 --- a/actions/showprofiletag.php +++ b/actions/showprofiletag.php @@ -359,6 +359,8 @@ class ShowprofiletagAction extends Action class Peopletag extends PeopletagListItem { + protected $avatarSize = AVATAR_PROFILE_SIZE; + function showStart() { $mode = $this->peopletag->private ? 'private' : 'public'; @@ -370,9 +372,4 @@ class Peopletag extends PeopletagListItem { $this->out->elementEnd('div'); } - - function showAvatar() - { - parent::showAvatar(AVATAR_PROFILE_SIZE); - } } diff --git a/actions/subscriptions.php b/actions/subscriptions.php index c4dda3f627..733823d21b 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -172,7 +172,7 @@ class SubscriptionsListItem extends SubscriptionListItem function showProfile() { $this->startProfile(); - $this->showAvatar(); + $this->showAvatar($this->profile); $this->showFullName(); $this->showLocation(); $this->showHomepage(); diff --git a/lib/accountprofileblock.php b/lib/accountprofileblock.php index 5d4aba9558..143675063c 100644 --- a/lib/accountprofileblock.php +++ b/lib/accountprofileblock.php @@ -63,11 +63,6 @@ class AccountProfileBlock extends ProfileBlock } } - function avatar() - { - return $this->profile->avatarUrl(AVATAR_PROFILE_SIZE); - } - function name() { return $this->profile->getBestName(); diff --git a/lib/groupprofileblock.php b/lib/groupprofileblock.php index 87ec174dc6..1a15c34bb1 100644 --- a/lib/groupprofileblock.php +++ b/lib/groupprofileblock.php @@ -52,12 +52,17 @@ class GroupProfileBlock extends ProfileBlock { parent::__construct($out); $this->group = $group; + $this->profile = $this->group->getProfile(); } - function avatar() - { - return ($this->group->homepage_logo) ? - $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE); + protected function showAvatar(Profile $profile, $size=null) + { + $avatar_url = $profile->getGroup()->homepage_logo ?: User_group::defaultLogo($size ?: $this->avatarSize()); + $this->out->element('img', array('src' => $avatar_url, + 'class' => 'avatar u-photo', + 'width' => $this->avatarSize(), + 'height' => $this->avatarSize(), + 'alt' => $profile->getBestName())); } function name() diff --git a/lib/noticelistitem.php b/lib/noticelistitem.php index 75a1bdaab5..0687a4d931 100644 --- a/lib/noticelistitem.php +++ b/lib/noticelistitem.php @@ -218,9 +218,8 @@ class NoticeListItem extends Widget 'title' => $this->profile->nickname); $this->out->elementStart('a', $attrs); - $this->showAvatar(); - $this->out->text(' '); - $this->out->element('span',array('class' => 'fn'), $this->profile->getStreamName()); + $this->showAvatar($this->profile); + $this->out->text($this->profile->getStreamName()); $this->out->elementEnd('a'); $this->out->elementEnd('span'); @@ -275,35 +274,6 @@ class NoticeListItem extends Widget 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 * diff --git a/lib/peopletaglist.php b/lib/peopletaglist.php index 5c027d7586..7fa26c56c1 100644 --- a/lib/peopletaglist.php +++ b/lib/peopletaglist.php @@ -231,11 +231,8 @@ class PeopletagListItem extends Widget $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')'; } $this->out->elementStart('a', $attrs); - $this->showAvatar(); - $this->out->text(' '); - $this->out->element('span', 'nickname fn', - htmlspecialchars($this->profile->nickname)); - + $this->showAvatar($this->profile); + $this->out->text($this->profile->getNickname()); $this->out->elementEnd('a'); $this->out->elementEnd('span'); } @@ -272,29 +269,6 @@ class PeopletagListItem extends Widget $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() { $this->out->elementStart('div', 'entity_actions'); diff --git a/lib/peopletagsection.php b/lib/peopletagsection.php index ccceb71a63..0995394516 100644 --- a/lib/peopletagsection.php +++ b/lib/peopletagsection.php @@ -48,6 +48,8 @@ define('PEOPLETAGS_PER_SECTION', 6); */ class PeopletagSection extends Section { + protected $avatarSize = AVATAR_MINI_SIZE; + function showContent() { $tags = $this->getPeopletags(); @@ -135,9 +137,4 @@ class PeopletagSectionItem extends PeopletagListItem htmlspecialchars($this->peopletag->tag)); $this->out->elementEnd('span'); } - - function showAvatar() - { - parent::showAvatar(AVATAR_MINI_SIZE); - } } diff --git a/lib/profileblock.php b/lib/profileblock.php index 8edc5d9ba1..65c4fa99d2 100644 --- a/lib/profileblock.php +++ b/lib/profileblock.php @@ -47,7 +47,8 @@ if (!defined('STATUSNET')) { abstract class ProfileBlock extends Widget { - abstract function avatar(); + protected $avatarSize = AVATAR_PROFILE_SIZE; + abstract function name(); abstract function url(); abstract function location(); @@ -57,7 +58,7 @@ abstract class ProfileBlock extends Widget function show() { $this->showActions(); - $this->showAvatar(); + $this->showAvatar($this->profile); $this->showName(); $this->showLocation(); $this->showHomepage(); @@ -66,22 +67,6 @@ abstract class ProfileBlock extends Widget $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() { $name = $this->name(); @@ -161,11 +146,6 @@ abstract class ProfileBlock extends Widget } } - function avatarSize() - { - return AVATAR_PROFILE_SIZE; - } - function showTags() { } diff --git a/lib/profilelist.php b/lib/profilelist.php index 11ed8945e9..4478a50795 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -31,7 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/widget.php'; require_once INSTALLDIR.'/lib/peopletags.php'; /** @@ -107,11 +106,6 @@ class ProfileList extends Widget { return PROFILES_PER_PAGE; } - - function avatarSize() - { - return AVATAR_STREAM_SIZE; - } } class ProfileListItem extends Widget @@ -157,7 +151,10 @@ class ProfileListItem extends Widget $this->startProfile(); if (Event::handle('StartProfileListItemProfileElements', array($this))) { if (Event::handle('StartProfileListItemAvatar', array($this))) { + $aAttrs = $this->linkAttributes(); + $this->out->elementStart('a', $aAttrs); $this->showAvatar(); + $this->out->elementEnd('a'); Event::handle('EndProfileListItemAvatar', 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'); } - 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() { if (!empty($this->profile->fullname)) { diff --git a/lib/subscriptionlist.php b/lib/subscriptionlist.php index 36dcbf65f8..09a660052c 100644 --- a/lib/subscriptionlist.php +++ b/lib/subscriptionlist.php @@ -76,7 +76,7 @@ class SubscriptionListItem extends ProfileListItem function showProfile() { $this->startProfile(); - $this->showAvatar(); + $this->showAvatar($this->profile); $this->showFullName(); $this->showLocation(); $this->showHomepage(); diff --git a/lib/widget.php b/lib/widget.php index 11f4d08cb8..78472dd4d8 100644 --- a/lib/widget.php +++ b/lib/widget.php @@ -51,6 +51,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { class Widget { + protected $avatarSize = AVATAR_STREAM_SIZE; + /** * HTMLOutputter to use for output */ @@ -105,4 +107,22 @@ class Widget { 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())); + } } diff --git a/plugins/Directory/lib/sortablegrouplist.php b/plugins/Directory/lib/sortablegrouplist.php index 37642e9b9c..9c826539e8 100644 --- a/plugins/Directory/lib/sortablegrouplist.php +++ b/plugins/Directory/lib/sortablegrouplist.php @@ -167,37 +167,15 @@ class SortableGroupListItem extends SortableSubscriptionListItem } - function showAvatar() + function showAvatar(Profile $profile, $size=null) { - $logo = ($this->profile->stream_logo) ? - $this->profile->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE); + $logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize()); - $this->out->elementStart( - 'a', - array( - 'href' => $this->profile->homeUrl(), - 'class' => 'url entry-title', - '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'); + $this->out->element('img', array('src' => $logo, + 'class' => 'photo avatar', + 'width' => AVATAR_STREAM_SIZE, + 'height' => AVATAR_STREAM_SIZE, + 'alt' => $profile->getBestName())); } function show() @@ -226,7 +204,17 @@ class SortableGroupListItem extends SortableSubscriptionListItem function showProfile() { $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->showLocation(); $this->showHomepage();