X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FDirectory%2Flib%2Fsortablegrouplist.php;h=ab00068f6d20a5f438794e1986dc3d07a98db8b8;hb=2b4a6c7dd723c404a48b629766279c24b45f54b4;hp=72be1f20b9f922ba48e633d86aa01da4c213642d;hpb=ddc42b1baf4f7b20d0d14981268f7b6d6ce223dc;p=quix0rs-gnu-social.git diff --git a/plugins/Directory/lib/sortablegrouplist.php b/plugins/Directory/lib/sortablegrouplist.php index 72be1f20b9..ab00068f6d 100644 --- a/plugins/Directory/lib/sortablegrouplist.php +++ b/plugins/Directory/lib/sortablegrouplist.php @@ -1,5 +1,4 @@ owner = $owner; - } - function startList() { $this->out->elementStart('table', array('class' => 'profile_list xoxo')); @@ -63,12 +47,13 @@ class SortableGroupList extends SortableSubscriptionList $this->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 +95,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'); @@ -120,67 +105,53 @@ class SortableGroupList extends SortableSubscriptionList $this->out->elementStart('tbody'); } - function newListItem($profile, $odd) + function newListItem($profile) { - return new SortableGroupListItem($profile, $this->owner, $this->action, $odd); + return new SortableGroupListItem($profile, $this->owner, $this->action); } } class SortableGroupListItem extends SortableSubscriptionListItem { - /** Owner of this list */ - var $owner = null; - - function __construct($profile, $owner, $action, $alt) - { - parent::__construct($profile, $owner, $action, $alt); - - $this->alt = $alt; // is this row alternate? - $this->owner = $owner; - } - 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() { - $logo = ($this->profile->stream_logo) ? - $this->profile->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE); - - $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 - ) - ); + if (!empty($this->profile->description)) { + $cutoff = 140; // XXX Should this be configurable? + $description = htmlspecialchars($this->profile->description); + + if (mb_strlen($description) > $cutoff) { + $description = mb_substr($description, 0, $cutoff - 1) + .'…'; + } + + $this->out->elementStart('p', 'note'); + $this->out->raw($description); + $this->out->elementEnd('p'); + } - $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'); + } + + // TODO: Make sure we can do ->getAvatar() for group profiles too! + function showAvatar(Profile $profile, $size=null) + { + $logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize()); + + $this->out->element('img', array('src' => $logo, + 'class' => 'avatar u-photo', + 'width' => AVATAR_STREAM_SIZE, + 'height' => AVATAR_STREAM_SIZE, + 'alt' => $profile->getBestName())); } function show() @@ -195,7 +166,6 @@ class SortableGroupListItem extends SortableSubscriptionListItem // XXX Add events? $this->showCreatedDate(); $this->showMemberCount(); - $this->showAdmins(); if (Event::handle('StartProfileListItemActions', array($this))) { $this->showActions(); @@ -207,6 +177,42 @@ class SortableGroupListItem extends SortableSubscriptionListItem } } + 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(); @@ -247,6 +253,7 @@ 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'); } @@ -269,5 +276,4 @@ class SortableGroupListItem extends SortableSubscriptionListItem } } - }