X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FDirectory%2Flib%2Fsortablegrouplist.php;h=8bd7e1bd70118e055ba553d8ac210f58adb82469;hb=429be8e9ae1f4fb91c76eb0abeee8c919b1898bc;hp=db6bc1d068e9b14781d7e7ce33c426157120b36b;hpb=42e945a42d9578da21dbd008b705677b482ea33f;p=quix0rs-gnu-social.git diff --git a/plugins/Directory/lib/sortablegrouplist.php b/plugins/Directory/lib/sortablegrouplist.php index db6bc1d068..8bd7e1bd70 100644 --- a/plugins/Directory/lib/sortablegrouplist.php +++ b/plugins/Directory/lib/sortablegrouplist.php @@ -1,5 +1,4 @@ out->elementStart('tr'); $tableHeaders = array( + // TRANS: Column header in table for user nickname. 'nickname' => _m('Nickname'), + // TRANS: Column header in table for timestamp when user was created. 'created' => _m('Created') ); foreach ($tableHeaders as $id => $label) { - $attrs = array('id' => $id); $current = (!empty($this->action->sort) && $this->action->sort == $id); @@ -110,8 +109,8 @@ class SortableGroupList extends SortableSubscriptionList $this->out->elementEnd('th'); } + // TRANS: Column header in table for members of a group. $this->out->element('th', array('id' => 'Members'), _m('Members')); - $this->out->element('th', array('id' => 'Admins'), _m('Admins')); $this->out->element('th', array('id' => 'controls'), null); $this->out->elementEnd('tr'); @@ -139,79 +138,45 @@ class SortableGroupListItem extends SortableSubscriptionListItem $this->owner = $owner; } - function startItem() - { - $attr = array( - 'class' => 'profile', - 'id' => 'profile-' . $this->profile->id - ); - - if ($this->alt) { - $attr['class'] .= ' alt'; - } - - $this->out->elementStart('tr', $attr); - } - function showHomepage() { if (!empty($this->profile->homepage)) { $this->out->text(' '); $aAttrs = $this->homepageAttributes(); $this->out->elementStart('a', $aAttrs); - $this->out->raw($this->highlight($this->profile->homeUrl())); + $this->out->raw($this->highlight($this->profile->homepage)); $this->out->elementEnd('a'); } } - function showAvatar() + function showDescription() { - $avatar = $this->profile->stream_logo; - $aAttrs = $this->linkAttributes(); - $this->out->elementStart('a', $aAttrs); - $this->out->element( - 'img', - array( - 'src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), - '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'); - } + if (!empty($this->profile->description)) { + $cutoff = 140; // XXX Should this be configurable? + $description = htmlspecialchars($this->profile->description); - function endItem() - { - $this->out->elementEnd('tr'); - } + if (mb_strlen($description) > $cutoff) { + $description = mb_substr($description, 0, $cutoff - 1) + .'…'; + } - function startProfile() - { - $this->out->elementStart('td', 'entity_profile vcard entry-content'); - } + $this->out->elementStart('p', 'note'); + $this->out->raw($description); + $this->out->elementEnd('p'); + } - function endProfile() - { - $this->out->elementEnd('td'); } - function startActions() + // TODO: Make sure we can do ->getAvatar() for group profiles too! + function showAvatar(Profile $profile, $size=null) { - $this->out->elementStart('td', 'entity_actions'); - $this->out->elementStart('ul'); - } + $logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize()); - function endActions() - { - $this->out->elementEnd('ul'); - $this->out->elementEnd('td'); + $this->out->element('img', array('src' => $logo, + 'class' => 'avatar u-photo', + 'width' => AVATAR_STREAM_SIZE, + 'height' => AVATAR_STREAM_SIZE, + 'alt' => $profile->getBestName())); } function show() @@ -226,17 +191,53 @@ class SortableGroupListItem extends SortableSubscriptionListItem // XXX Add events? $this->showCreatedDate(); $this->showMemberCount(); - $this->showAdmins(); if (Event::handle('StartProfileListItemActions', array($this))) { $this->showActions(); Event::handle('EndProfileListItemActions', array($this)); } $this->endItem(); + Event::handle('EndProfileListItem', array($this)); } } + function showProfile() + { + $this->startProfile(); + + $this->showAvatar($this->profile->getProfile()); + $this->out->element('a', array('href' => $this->profile->homeUrl(), + 'class' => 'p-org p-nickname', + 'rel' => 'contact group'), + $this->profile->getNickname()); + + $this->showFullName(); + $this->showLocation(); + $this->showHomepage(); + $this->showDescription(); // groups have this instead of bios + // Relevant portion! + $this->showTags(); + $this->endProfile(); + } + + function endActions() + { + // delete button + $cur = common_current_user(); + list($action, $r2args) = $this->out->returnToArgs(); + $r2args['action'] = $action; + if ($cur instanceof User && $cur->hasRight(Right::DELETEGROUP)) { + $this->out->elementStart('li', 'entity_delete'); + $df = new DeleteGroupForm($this->out, $this->profile, $r2args); + $df->show(); + $this->out->elementEnd('li'); + } + + $this->out->elementEnd('ul'); + $this->out->elementEnd('td'); + } + function showActions() { $this->startActions(); @@ -250,8 +251,8 @@ class SortableGroupListItem extends SortableSubscriptionListItem function showJoinButton() { $user = $this->owner; - if ($user) { - + + if ($user instanceof User) { $this->out->elementStart('li', 'entity_subscribe'); // XXX: special-case for user looking at own // subscriptions page @@ -262,12 +263,14 @@ class SortableGroupListItem extends SortableSubscriptionListItem $jf = new JoinForm($this->out, $this->profile); $jf->show(); } + + $this->out->elementEnd('li'); } } function showMemberCount() { - $this->out->elementStart('td', 'entry_subscriber_count'); + $this->out->elementStart('td', 'entry_member_count'); $this->out->raw($this->profile->getMemberCount()); $this->out->elementEnd('td'); } @@ -275,13 +278,14 @@ class SortableGroupListItem extends SortableSubscriptionListItem function showCreatedDate() { $this->out->elementStart('td', 'entry_created'); + // @todo FIXME: Should we provide i18n for timestamps in core? $this->out->raw(date('j M Y', strtotime($this->profile->created))); $this->out->elementEnd('td'); } function showAdmins() { - $this->out->elementStart('td', 'entry_notice_count'); + $this->out->elementStart('td', 'entry_admins'); // @todo $this->out->raw('gargargar'); $this->out->elementEnd('td'); @@ -297,5 +301,4 @@ class SortableGroupListItem extends SortableSubscriptionListItem } } - }